我通过:
创建了一个pyopencl.Image
对象 import pyopencl as cl
import numpy as np
ctx = cl.create_some_context()
image = cl.image_from_array(ctx, np.ones((16, 16), dtype=np.uint8))
如何获得图像通道类型信息(在此处,cl.channel_type.UNSIGNED_INT8
)?我想实现一个通用下载功能,该功能返回给定Image
的numpy阵列。
我尝试了两种方法:
使用Image.element_size
给我一个单个元素的字节大小,但是我无法将元素大小映射到数据类型(例如,float32和int32具有相同的元素大小)。
Image.format
返回cdata 'struct _cl_image_format &'
。查询其中一个字段image_channel_data_type
和image_channel_order
返回0。
我通过Pyopencl邮件列表收到答案。
事实证明,返回Image.format
的功能不正确。这已在github仓库中固定。