23.11
|
Go to the documentation of this file.
45 "satisfy cl_image pitch alignment requirement");
47 const size_t image_w{
info->dimension(0) / 4};
48 const size_t image_h{
info->tensor_shape().total_size() /
info->dimension(0)};
57 const size_t image_row_pitch =
info->strides_in_bytes()[1];
63 const cl::Buffer &buffer,
66 size_t image_row_pitch,
70 "The extension cl_khr_image2d_from_buffer is not supported on the target platform");
72 "Impossible to retrieve the cl_image pitch alignment");
75 cl_channel_type cl_data_type;
80 cl_data_type = CL_FLOAT;
83 cl_data_type = CL_HALF_FLOAT;
90 cl_int err = CL_SUCCESS;
92 const cl_image_format format = {CL_RGBA, cl_data_type};
95 memset(&desc, 0,
sizeof(desc));
96 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
97 desc.mem_object = buffer();
98 desc.image_row_pitch = image_row_pitch;
99 desc.image_width = shape2d[0];
100 desc.image_height = shape2d[1];
105 cl_image =
clCreateImage(ctx(), CL_MEM_READ_ONLY, &format, &desc,
nullptr, &err);
108 cl_image =
clCreateImage(ctx(), CL_MEM_WRITE_ONLY, &format, &desc,
nullptr, &err);
117 return cl::Image2D(cl_image);
122 if (error_code != CL_SUCCESS)
124 std::string error_message = function_name +
" - Error code: " +
std::to_string(error_code);
cl::Context & context()
Accessor for the associated CL context.
cl::Image2D create_image2d_from_tensor(const ICLTensor *tensor, CLImage2DType image_type)
Create a cl::Image2D object from a tensor.
CLImage2DType
OpenCL Image2D types.
Interface for OpenCL tensor.
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
bool image2d_from_buffer_supported(const cl::Device &device)
Helper function to check whether the cl_khr_image2d_from_buffer extension is supported.
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
Manages all the OpenCL kernels compilation and caching, provides accessors for the OpenCL Context.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
void handle_cl_error(const std::string &function_name, cl_int error_code)
Check for CL error code and throw exception accordingly.
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
const cl::Buffer & cl_buffer() const override
Interface to be implemented by the child class to return a reference to the OpenCL buffer containing ...
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
CLTensor * tensor
Pointer to the auxiliary tensor.
cl_mem clCreateImage(cl_context context, cl_mem_flags flags, const cl_image_format *image_format, const cl_image_desc *image_desc, void *host_ptr, cl_int *errcode_ret)
cl::Image2D create_image2d_from_buffer(const cl::Context &ctx, const cl::Buffer &buffer, const TensorShape &shape2d, DataType data_type, size_t image_row_pitch, CLImage2DType image_type)
Create a cl::Image2D object from an OpenCL buffer.
Copyright (c) 2017-2023 Arm Limited.
std::string to_string(const ClComponentElementwiseBinary::Attributes::ElementwiseOp &op)
Formatted output of the arm_compute::experimental::dynamic_fusion::ClComponentElementwiseBinary::Attr...
@ F16
16-bit floating-point number
size_t get_cl_image_pitch_alignment(const cl::Device &device)
Helper function to get the cl_image pitch alignment in pixels.
TensorInfo * info() const override
Interface to be implemented by the child class to return the tensor's metadata.
Store the tensor's metadata.
@ F32
32-bit floating-point number
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
DataType
Available data types.
const cl::Device & get_device()
Gets the CL device for which the programs are created.