diff options
Diffstat (limited to 'src/dynamic_fusion/runtime/gpu/cl/ClKernelRuntime.cpp')
-rw-r--r-- | src/dynamic_fusion/runtime/gpu/cl/ClKernelRuntime.cpp | 81 |
1 files changed, 67 insertions, 14 deletions
diff --git a/src/dynamic_fusion/runtime/gpu/cl/ClKernelRuntime.cpp b/src/dynamic_fusion/runtime/gpu/cl/ClKernelRuntime.cpp index 6a57482bb2..92ca8557f1 100644 --- a/src/dynamic_fusion/runtime/gpu/cl/ClKernelRuntime.cpp +++ b/src/dynamic_fusion/runtime/gpu/cl/ClKernelRuntime.cpp @@ -24,6 +24,9 @@ #include "ClKernelRuntime.h" #include "arm_compute/core/CL/ICLTensor.h" #include "src/core/CL/CLUtils.h" +#ifdef ACL_INTERNAL_TEST_CKW_IN_DF +#include "src/dynamic_fusion/runtime/gpu/cl/ckw_driver/GpuCkwKernelArgumentsHelpers.h" +#endif // ACL_INTERNAL_TEST_CKW_IN_DF #include "src/dynamic_fusion/sketch/gpu/GpuKernelSourceCode.h" #include "src/gpu/cl/ClKernelLibrary.h" @@ -57,6 +60,8 @@ void ClKernelRuntime::configure(const ClCompileContext &compile_ctx, const GpuKe _arguments = code.arguments(); } +#ifndef ACL_INTERNAL_TEST_CKW_IN_DF + inline void ClKernelRuntime::add_tensor_argument(unsigned int &idx, const GpuKernelArgumentInfo &arg, const ICLTensor *tensor, const Window &arg_slice, std::vector<cl::Image2D> &cl_images) { ARM_COMPUTE_ERROR_ON_NULLPTR(tensor); @@ -163,21 +168,65 @@ inline void ClKernelRuntime::add_tensor_argument(unsigned int &idx, const GpuKer } } +#else // ACL_INTERNAL_TEST_CKW_IN_DF +inline void ClKernelRuntime::add_kernel_argument(unsigned int &idx, const GpuKernelArgumentBinding &arg, const ICLTensor *tensor, std::vector<cl::Image2D> &cl_images) +{ + switch(arg.type()) + { + case GpuKernelArgumentBinding::Type::TensorStorage: + { + switch(arg.tensor_storage_type()) + { + case TensorStorageType::ClBufferUint8Ptr: + { + cl_add_buffer_argument(_kernel, idx, tensor->cl_buffer()); + break; + } + case TensorStorageType::ClImage2dReadOnly: + { + cl::Image2D tensor_image2d = create_image2d_from_tensor(tensor, CLImage2DType::ReadOnly); + cl_images.push_back(tensor_image2d); + cl_add_texture_argument(_kernel, idx, tensor_image2d); + break; + } + case TensorStorageType::ClImage2dWriteOnly: + { + cl::Image2D tensor_image2d = create_image2d_from_tensor(tensor, CLImage2DType::WriteOnly); + cl_images.push_back(tensor_image2d); + cl_add_texture_argument(_kernel, idx, tensor_image2d); + break; + } + default: + { + ARM_COMPUTE_ERROR("Do not accept other TensorStorageType"); + break; + } + } + break; + } + case GpuKernelArgumentBinding::Type::TensorComponent: + { + cl_add_tensor_component_argument(_kernel, idx, tensor, arg.tensor_component_type()); + break; + } + default: + { + ARM_COMPUTE_ERROR("Do not accept other types of kernel arguments"); + break; + } + } +} + +#endif // ACL_INTERNAL_TEST_CKW_IN_DF void ClKernelRuntime::run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue) { ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(ICLKernel::window(), window); Window slice = window.first_slice_window_3D(); - // Don't slice matrix along the z dimension if matrix has just 2 dimensions and matrix A more than 2 - // This scenario can happen when the matrix multiplication is used to perform a convolution operation - Window slice_fixed_z = slice; - slice_fixed_z.set(Window::DimX, Window::Dimension(0, 1, 1)); - slice_fixed_z.set(Window::DimY, Window::Dimension(0, 1, 1)); /// NOTE: Parameters extracted from old kernels. So far they seem to be constant /// but we may need to make them into another configuration passed from GpuWorkloadSourceCode if needed in the future - constexpr bool slide_along_dimz = true; constexpr bool skip_sliding_window = false; constexpr bool use_dummy_work_items = false; @@ -185,23 +234,27 @@ void ClKernelRuntime::run_op(ITensorPack &tensors, const Window &window, cl::Com do { // Set kernel arguments - Window arg_slice = slice; // CLImages created from tensor arguments. Need to be retained until enqueue std::vector<cl::Image2D> cl_images; +#ifndef ACL_INTERNAL_TEST_CKW_IN_DF for(auto id_arg : _arguments) { const auto arg = id_arg.second; auto tensor = utils::cast::polymorphic_downcast<ICLTensor *>(tensors.get_tensor(id_arg.first)); ARM_COMPUTE_ERROR_ON_NULLPTR(tensor); ARM_COMPUTE_ERROR_ON_NULLPTR(tensor->info()); - if(!slide_along_dimz) - { - // The stride_z for matrix must be zero if we do not slice - ARM_COMPUTE_ERROR_ON(tensor->info()->strides_in_bytes()[3] != 0); - arg_slice = slice_fixed_z; - } - add_tensor_argument(idx, *arg.kernel_argument_info(), tensor, arg_slice, cl_images); + add_tensor_argument(idx, *arg.kernel_argument_info(), tensor, slice, cl_images); + } + +#else // ACL_INTERNAL_TEST_CKW_IN_DF + for(const auto &arg : _arguments) + { + auto tensor = utils::cast::polymorphic_downcast<ICLTensor *>(tensors.get_tensor(arg.id())); + ARM_COMPUTE_ERROR_ON_NULLPTR(tensor); + ARM_COMPUTE_ERROR_ON_NULLPTR(tensor->info()); + add_kernel_argument(idx, arg, tensor, cl_images); } +#endif // ACL_INTERNAL_TEST_CKW_IN_DF // Dispatch kernel enqueue(queue, *this, slice, lws_hint(), use_dummy_work_items); |