Ctrl + k

or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/pyopencl@2025.2.x
tile.json

tessl/pypi-pyopencl

tessl install tessl/pypi-pyopencl@2025.2.0

Python wrapper for OpenCL enabling GPU and parallel computing with comprehensive array operations and mathematical functions

Agent Success

Agent success rate when using this tile

86%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.28x

Baseline

Agent success rate without this tile

67%

task.mdevals/scenario-3/

Image Format Converter

Build a utility that converts images between different color formats using GPU acceleration. The utility should query the device for supported image formats and perform efficient image data transfers.

Requirements

Your implementation should provide the following functionality:

  1. Query Device Capabilities: Check which image formats are supported by the OpenCL device for reading operations.

  2. Create Images: Create OpenCL images from numpy arrays containing image data in various formats (RGBA, RGB, grayscale).

  3. Format Conversion: Convert images between different channel orders (e.g., RGBA to RGB) using GPU kernels.

  4. Transfer Operations: Transfer image data between host (numpy arrays) and device memory.

Implementation

@generates

API

def query_supported_formats(context):
    """
    Query the device for supported image formats for reading.

    Args:
        context: An OpenCL context

    Returns:
        A list of supported ImageFormat objects for reading 2D images
    """
    pass

def create_image_from_array(context, queue, array, channel_order, channel_type):
    """
    Create an OpenCL image from a numpy array.

    Args:
        context: An OpenCL context
        queue: An OpenCL command queue
        array: A numpy array containing image data (2D or 3D)
        channel_order: The channel order for the image (e.g., 'RGBA', 'RGB', 'R')
        channel_type: The channel data type (e.g., 'UNORM_INT8', 'FLOAT')

    Returns:
        An OpenCL Image object
    """
    pass

def convert_image_format(queue, src_image, dst_channel_order, dst_channel_type):
    """
    Convert an image to a different format using GPU processing.

    Args:
        queue: An OpenCL command queue
        src_image: The source OpenCL Image
        dst_channel_order: The destination channel order
        dst_channel_type: The destination channel data type

    Returns:
        A new OpenCL Image with the converted format
    """
    pass

def transfer_image_to_host(queue, image):
    """
    Transfer an OpenCL image to a numpy array on the host.

    Args:
        queue: An OpenCL command queue
        image: The OpenCL Image to transfer

    Returns:
        A numpy array containing the image data
    """
    pass

Test Cases

  • Query device formats and verify at least one RGBA format is supported @test
  • Create a 256x256 RGBA image from a numpy array with shape (256, 256, 4) @test
  • Convert an RGBA image to RGB and verify output has correct dimensions @test
  • Transfer a 128x128 image to host and verify array shape is (128, 128, 4) @test

Dependencies { .dependencies }

pyopencl { .dependency }

Provides GPU computing and image processing capabilities through OpenCL.