MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / create_image2d_from_tensor

Function create_image2d_from_tensor

src/core/CL/CLUtils.cpp:37–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35namespace arm_compute
36{
37cl::Image2D create_image2d_from_tensor(const ICLTensor *tensor, CLImage2DType image_type)
38{
39 ARM_COMPUTE_ERROR_ON_NULLPTR(tensor);
40
41 const cl::Context &ctx = CLKernelLibrary::get().context();
42 const cl::Buffer &buffer = tensor->cl_buffer();
43 const ITensorInfo *info = tensor->info();
44 ARM_COMPUTE_ERROR_ON_MSG(info->lock_paddings(), "Tensor paddings must not be locked to allow extending paddings to "
45 "satisfy cl_image pitch alignment requirement");
46
47 const size_t image_w{info->dimension(0) / 4};
48 const size_t image_h{info->tensor_shape().total_size() / info->dimension(0)};
49 const size_t max_image_w{CLKernelLibrary::get().get_device().getInfo<CL_DEVICE_IMAGE2D_MAX_WIDTH>()};
50 const size_t max_image_h{CLKernelLibrary::get().get_device().getInfo<CL_DEVICE_IMAGE2D_MAX_HEIGHT>()};
51
52 ARM_COMPUTE_UNUSED(max_image_w, max_image_h);
53 ARM_COMPUTE_ERROR_ON_MSG(image_w > max_image_w, "Image width exceeds maximum width for exporting to cl_image");
54 ARM_COMPUTE_ERROR_ON_MSG(image_h > max_image_h, "Image height exceeds maximum height for exporting to cl_image");
55
56 const TensorShape shape2d(image_w, image_h);
57 const size_t image_row_pitch = info->strides_in_bytes()[1];
58
59 return create_image2d_from_buffer(ctx, buffer, shape2d, info->data_type(), image_row_pitch, image_type);
60}
61
62cl::Image2D create_image2d_from_buffer(const cl::Context &ctx,
63 const cl::Buffer &buffer,

Callers 1

run_opMethod · 0.85

Calls 7

contextMethod · 0.80
infoMethod · 0.45
lock_paddingsMethod · 0.45
dimensionMethod · 0.45
total_sizeMethod · 0.45
data_typeMethod · 0.45

Tested by

no test coverage detected