【发布时间】:2016-09-16 14:10:57
【问题描述】:
我想使用 pyopencl 从一个 numpy 数组构建一个 OpenCL 3D RGBA 图像。我知道cl.image_from_array() 函数,它基本上就是这样做的,但没有对cl.enqueue_copy() 公开的命令队列或事件提供任何控制。所以我真的很想使用后一个函数,将 3D RGBA 图像从主机传输到设备,但我似乎无法正确获取图像构造函数的语法。
所以在这种环境下
import pyopencl as cl
import numpy as np
platform = cl.get_platforms()[0]
devs = platform.get_devices()
device1 = devs[1]
mf = cl.mem_flags
ctx = cl.Context([device1])
Queue1=cl.CommandQueue(ctx,properties=cl.command_queue_properties.PROFILING_ENABLE)
我想做一些类似于
的事情 d_colortest = cl.image_from_array(ctx,np.zeros((256,256,256,4)).astype(np.float32),num_channels=4,mode='w')
使用函数
d_image = cl.Image(...)
event = cl.enqueue_copy(...)
【问题讨论】:
标签: python image numpy opencl pyopencl