提交 4a75a8a3 编写于 作者: D dolphin8

use clcreateimage

上级 a3e4c8de
...@@ -120,8 +120,6 @@ class CLImage { ...@@ -120,8 +120,6 @@ class CLImage {
private: private:
void InitCLImage(cl_context context, float *tensor_data, const DDim &dim) { void InitCLImage(cl_context context, float *tensor_data, const DDim &dim) {
DLOG << " tensor dim: " << dim; DLOG << " tensor dim: " << dim;
cl_image_format cf = {.image_channel_order = CL_RGBA,
.image_channel_data_type = CL_HALF_FLOAT};
// NCHW -> [W * (C+3)/4, H * N] // NCHW -> [W * (C+3)/4, H * N]
tensor_dims_ = dim; tensor_dims_ = dim;
if (tensor_data) { if (tensor_data) {
...@@ -194,14 +192,29 @@ class CLImage { ...@@ -194,14 +192,29 @@ class CLImage {
cl_int err; cl_int err;
DLOG << " image width: " << width; DLOG << " image width: " << width;
DLOG << " image height: " << height; DLOG << " image height: " << height;
cl_image_ = clCreateImage2D(
context, // cl_context context cl_image_format cf = {
CL_MEM_READ_WRITE | .image_channel_order = CL_RGBA,
(imageData ? CL_MEM_COPY_HOST_PTR : 0), // cl_mem_flags flags .image_channel_data_type = CL_HALF_FLOAT
};
cl_image_desc cid = {
.image_type = CL_MEM_OBJECT_IMAGE2D,
.image_width = width,
.image_height = height,
.image_depth = 1,
.image_array_size = 1,
.image_row_pitch = 0,
.image_slice_pitch = 0,
.num_mip_levels = 0,
.num_samples = 0,
// .buffer = nullptr
};
cid.buffer = nullptr;
cl_image_ = clCreateImage(
context,
CL_MEM_READ_WRITE | (imageData ? CL_MEM_COPY_HOST_PTR : 0),
&cf, // const cl_image_format *image_format &cf, // const cl_image_format *image_format
width, // size_t image_width &cid, // const cl_image_desc *image_desc
height, // size_t image_height
0, // size_t image_row_pitch
reinterpret_cast<void *>(imageData.get()), // void *host_ptr reinterpret_cast<void *>(imageData.get()), // void *host_ptr
&err); &err);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册