Add helpers to set CKW tensor components as OpenCL kernel arguments
* Define ckw::TensorStorage. The tensor storage represents the type of tensor memory object.
* Add helper functions for setting the CKW TensorComponent and TensorStorage as OpenCL kernel arguments.
* Refactor CL Image2D method for simpler image object creation.
Resolves: COMPMID-5784
Change-Id: I2d37d06783c1dc55f3b5692b44eb49b151f2401c
Signed-off-by: Jakub Sujak <jakub.sujak@arm.com>
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/9807
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: SiCong Li <sicong.li@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Benchmark: Arm Jenkins <bsgcomp@arm.com>
diff --git a/src/gpu/cl/kernels/ClDirectConv2dKernel.cpp b/src/gpu/cl/kernels/ClDirectConv2dKernel.cpp
index 68d7e30..f01341c 100644
--- a/src/gpu/cl/kernels/ClDirectConv2dKernel.cpp
+++ b/src/gpu/cl/kernels/ClDirectConv2dKernel.cpp
@@ -431,35 +431,20 @@
if(_export_weights_to_cl_image)
{
- const size_t image_w = weights->info()->dimension(0) / 4;
- const size_t image_h = weights->info()->dimension(1) * weights->info()->dimension(2) * weights->info()->dimension(3);
- const TensorShape shape2d(image_w, image_h);
- const size_t image_row_pitch = weights->info()->strides_in_bytes()[1];
-
- // Export cl_buffer to cl_image
- weights_cl_image = create_image2d_from_buffer(CLKernelLibrary::get().context(), weights->cl_buffer(), shape2d, weights->info()->data_type(), image_row_pitch, CLImage2DType::ReadOnly);
+ // Export tensor to cl_image
+ weights_cl_image = create_image2d_from_tensor(weights, CLImage2DType::ReadOnly);
}
if(_export_output_to_cl_image)
{
- const size_t image_w = dst->info()->dimension(0) / 4;
- const size_t image_h = dst->info()->dimension(1) * dst->info()->dimension(2) * dst->info()->dimension(3);
- const TensorShape shape2d(image_w, image_h);
- const size_t image_row_pitch = dst->info()->strides_in_bytes()[1];
-
- // Export cl_buffer to cl_image
- output_cl_image = create_image2d_from_buffer(CLKernelLibrary::get().context(), dst->cl_buffer(), shape2d, dst->info()->data_type(), image_row_pitch, CLImage2DType::WriteOnly);
+ // Export tensor to cl_image
+ output_cl_image = create_image2d_from_tensor(dst, CLImage2DType::WriteOnly);
}
if(_export_input_to_cl_image)
{
- const size_t image_w = src->info()->dimension(0) / 4;
- const size_t image_h = src->info()->dimension(1) * src->info()->dimension(2) * src->info()->dimension(3);
- const TensorShape shape2d(image_w, image_h);
- const size_t image_row_pitch = src->info()->strides_in_bytes()[1];
-
- // Export cl_buffer to cl_image
- input_cl_image = create_image2d_from_buffer(CLKernelLibrary::get().context(), src->cl_buffer(), shape2d, src->info()->data_type(), image_row_pitch, CLImage2DType::ReadOnly);
+ // Export tensor to cl_image
+ input_cl_image = create_image2d_from_tensor(src, CLImage2DType::ReadOnly);
}
unsigned int idx = 0;