【问题标题】:Derive channel type from pyopencl.Image object从 pyopencl.Image 对象派生通道类型
【发布时间】:2017-04-24 23:38:04
【问题描述】:

我通过以下方式创建了一个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_typeimage_channel_order 中的任何一个字段都会返回0。

【问题讨论】:

    标签: opencl gpgpu pyopencl


    【解决方案1】:

    我通过 PyOpenCl 邮件列表收到了 answer

    原来返回Image.format的功能不正确。这已在github repo 中修复。

    【讨论】:

      猜你喜欢
      • 2018-11-05
      • 1970-01-01
      • 2011-01-05
      • 2015-08-10
      • 2015-05-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多