diff options
author | Gian Marco Iodice <gianmarco.iodice@arm.com> | 2017-07-25 10:25:53 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-09-17 14:16:42 +0100 |
commit | 3a62324f8f0a35c6f2c69cbc38cc1d52863c4ba8 (patch) | |
tree | 365c2f686f40dc1cd1e3826915db581562ca2605 /src/core/CL/kernels | |
parent | b9e9cff3a9293c60b53683ccfbf2c50dbbbbf44e (diff) | |
download | ComputeLibrary-3a62324f8f0a35c6f2c69cbc38cc1d52863c4ba8.tar.gz |
COMPMID-455 - Optimizing CLIm2ColKernel
Change-Id: Iee618948cc8f310ee9af2d786240e8120e4c6ab9
Reviewed-on: http://mpd-gerrit.cambridge.arm.com/81665
Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Diffstat (limited to 'src/core/CL/kernels')
-rw-r--r-- | src/core/CL/kernels/CLCol2ImKernel.cpp | 7 | ||||
-rw-r--r-- | src/core/CL/kernels/CLIm2ColKernel.cpp | 17 | ||||
-rw-r--r-- | src/core/CL/kernels/CLWeightsReshapeKernel.cpp | 4 |
3 files changed, 24 insertions, 4 deletions
diff --git a/src/core/CL/kernels/CLCol2ImKernel.cpp b/src/core/CL/kernels/CLCol2ImKernel.cpp index cfbe7408e2..ddcc3fa41e 100644 --- a/src/core/CL/kernels/CLCol2ImKernel.cpp +++ b/src/core/CL/kernels/CLCol2ImKernel.cpp @@ -53,7 +53,12 @@ void CLCol2ImKernel::configure(const ICLTensor *input, ICLTensor *output, std::p // Create kernel std::set<std::string> build_opts = { ("-DDATA_TYPE=" + get_cl_type_from_data_type(input->info()->data_type())) }; - _kernel = static_cast<cl::Kernel>(CLKernelLibrary::get().create_kernel("col2im", build_opts)); + if(is_data_type_fixed_point(input->info()->data_type())) + { + build_opts.emplace("-DFIXED_POINT_POSITION=" + support::cpp11::to_string(input->info()->fixed_point_position())); + } + + _kernel = static_cast<cl::Kernel>(CLKernelLibrary::get().create_kernel("col2im", build_opts)); // Set static kernel arguments unsigned int idx = num_arguments_per_2D_tensor() + num_arguments_per_3D_tensor(); diff --git a/src/core/CL/kernels/CLIm2ColKernel.cpp b/src/core/CL/kernels/CLIm2ColKernel.cpp index 7d7732d5da..b72aff26c6 100644 --- a/src/core/CL/kernels/CLIm2ColKernel.cpp +++ b/src/core/CL/kernels/CLIm2ColKernel.cpp @@ -87,6 +87,7 @@ void CLIm2ColKernel::configure(const ICLTensor *input, ICLTensor *output, const build_opts.emplace("-DKERNEL_HEIGHT=" + support::cpp11::to_string(kernel_dims.height)); build_opts.emplace("-DKERNEL_DEPTH=" + support::cpp11::to_string(input->info()->dimension(2))); build_opts.emplace("-DCONVOLVED_WIDTH=" + support::cpp11::to_string(_convolved_dims.first)); + build_opts.emplace("-DCONVOLVED_HEIGHT=" + support::cpp11::to_string(_convolved_dims.second)); build_opts.emplace("-DSTRIDE_X=" + support::cpp11::to_string(conv_info.stride().first)); build_opts.emplace("-DSTRIDE_Y=" + support::cpp11::to_string(conv_info.stride().second)); build_opts.emplace("-DPAD_X=" + support::cpp11::to_string(conv_info.pad().first)); @@ -94,7 +95,14 @@ void CLIm2ColKernel::configure(const ICLTensor *input, ICLTensor *output, const build_opts.emplace("-DSRC_WIDTH=" + support::cpp11::to_string(input->info()->dimension(0))); build_opts.emplace("-DSRC_HEIGHT=" + support::cpp11::to_string(input->info()->dimension(1))); - _kernel = static_cast<cl::Kernel>(CLKernelLibrary::get().create_kernel("im2col_generic", build_opts)); + if(kernel_dims.width == 3 && kernel_dims.height == 3 && conv_info.pad().first == 0 && conv_info.pad().second == 0) + { + _kernel = static_cast<cl::Kernel>(CLKernelLibrary::get().create_kernel("im2col_kernel3x3_padx0_pady0", build_opts)); + } + else + { + _kernel = static_cast<cl::Kernel>(CLKernelLibrary::get().create_kernel("im2col_generic", build_opts)); + } _run_func = &CLIm2ColKernel::run_generic; } @@ -131,7 +139,7 @@ void CLIm2ColKernel::run_generic(const Window &window, cl::CommandQueue &queue) // Setup slice slice.set(Window::DimX, Window::Dimension(0, static_cast<int>(_convolved_dims.first), 1)); slice.set(Window::DimY, Window::Dimension(0, static_cast<int>(_convolved_dims.second), 1)); - slice.set(Window::DimZ, Window::Dimension(0, 1, 1)); + slice.set(Window::DimZ, Window::Dimension(0, static_cast<int>(_input->info()->dimension(2)), 1)); // Setup input slice // The first three dimensions of the input are increased by the inner loops @@ -144,13 +152,16 @@ void CLIm2ColKernel::run_generic(const Window &window, cl::CommandQueue &queue) slice_out.set(Window::DimY, Window::Dimension(0, _output->info()->dimension(1), 1)); slice_out.set(Window::DimZ, Window::Dimension(0, 1, 1)); + // Set the local-workgroup size + _lws_hint = cl::NDRange(4, 4, 4); + do { // Set inputs unsigned int idx = 0; add_3D_tensor_argument(idx, _input, slice_in); add_2D_tensor_argument(idx, _output, slice_out); - enqueue(queue, *this, slice); + enqueue(queue, *this, slice, _lws_hint); } while(window.slide_window_slice_3D(slice) && window.slide_window_slice_3D(slice_out) && window.slide_window_slice_3D(slice_in)); } diff --git a/src/core/CL/kernels/CLWeightsReshapeKernel.cpp b/src/core/CL/kernels/CLWeightsReshapeKernel.cpp index b802c862fc..7b80f3ff5a 100644 --- a/src/core/CL/kernels/CLWeightsReshapeKernel.cpp +++ b/src/core/CL/kernels/CLWeightsReshapeKernel.cpp @@ -78,6 +78,10 @@ void CLWeightsReshapeKernel::configure(const ICLTensor *input, const ICLTensor * std::set<std::string> build_opts; build_opts.emplace(("-DDATA_TYPE=" + get_cl_type_from_data_type(input->info()->data_type()))); build_opts.emplace(((biases != nullptr) ? "-DHAS_BIAS" : "")); + if(is_data_type_fixed_point(input->info()->data_type())) + { + build_opts.emplace("-DFIXED_POINT_POSITION=" + support::cpp11::to_string(input->info()->fixed_point_position())); + } // Create kernel _kernel = static_cast<cl::Kernel>(CLKernelLibrary::get().create_kernel("reshape_to_columns", build_opts)); |