tessl install tessl/pypi-pyopencl@2025.2.0Python 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%
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.
Your implementation should provide the following functionality:
Query Device Capabilities: Check which image formats are supported by the OpenCL device for reading operations.
Create Images: Create OpenCL images from numpy arrays containing image data in various formats (RGBA, RGB, grayscale).
Format Conversion: Convert images between different channel orders (e.g., RGBA to RGB) using GPU kernels.
Transfer Operations: Transfer image data between host (numpy arrays) and device memory.
@generates
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
"""
passProvides GPU computing and image processing capabilities through OpenCL.