From 1b50bd4d74d479f80c48ee1cd7b223245162aac3 Mon Sep 17 00:00:00 2001 From: Sheri Zhang Date: Tue, 27 Oct 2020 00:24:07 +0000 Subject: COMPMID-3793: Remove OpenCL padding: CLWidthConcatenateLayerKernel Signed-off-by: Sheri Zhang Change-Id: I705044a9429bb9a08268368b09463c2af85616d5 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/4253 Tested-by: Arm Jenkins Reviewed-by: Manuel Bottini Comments-Addressed: Arm Jenkins --- .../CL/kernels/CLWidthConcatenateLayerKernel.cpp | 32 ++++++---------------- 1 file changed, 9 insertions(+), 23 deletions(-) (limited to 'src/core/CL/kernels/CLWidthConcatenateLayerKernel.cpp') diff --git a/src/core/CL/kernels/CLWidthConcatenateLayerKernel.cpp b/src/core/CL/kernels/CLWidthConcatenateLayerKernel.cpp index 8b0aaf3227..a9a601dc8e 100644 --- a/src/core/CL/kernels/CLWidthConcatenateLayerKernel.cpp +++ b/src/core/CL/kernels/CLWidthConcatenateLayerKernel.cpp @@ -38,21 +38,6 @@ namespace arm_compute { namespace { -constexpr unsigned int num_elems_processed_per_iteration = 16; - -std::pair validate_and_configure_window(ITensorInfo *input, unsigned int width_offset, ITensorInfo *output) -{ - // The window needs to be based on input as we copy all the widths of input - Window win = calculate_max_window(*input, Steps(num_elems_processed_per_iteration)); - AccessWindowHorizontal input_access(input, 0, num_elems_processed_per_iteration); - AccessWindowHorizontal output_access(output, width_offset, num_elems_processed_per_iteration); - bool window_changed = update_window_and_padding(win, input_access, output_access); - - Window win_collapsed = win.collapse(win, Window::DimZ); - - Status err = (window_changed) ? ARM_COMPUTE_CREATE_ERROR(ErrorCode::RUNTIME_ERROR, "Insufficient Padding!") : Status{}; - return std::make_pair(err, win_collapsed); -} Status validate_arguments(const ITensorInfo *input, unsigned int width_offset, const ITensorInfo *output) { ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input, output); @@ -73,14 +58,12 @@ Status validate_arguments(const ITensorInfo *input, unsigned int width_offset, c } // namespace CLWidthConcatenateLayerKernel::CLWidthConcatenateLayerKernel() - : _width_offset(0) { } Status CLWidthConcatenateLayerKernel::validate(const ITensorInfo *input, unsigned int width_offset, const ITensorInfo *output) { ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, width_offset, output)); - ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window(input->clone().get(), width_offset, output->clone().get()).first); return Status{}; } @@ -89,13 +72,16 @@ void CLWidthConcatenateLayerKernel::configure(const CLCompileContext &compile_co ARM_COMPUTE_ERROR_ON_NULLPTR(input, output); ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input, width_offset, output)); - _width_offset = width_offset; + auto padding_info = get_padding_info({ input, output }); + + const unsigned int num_elems_processed_per_iteration = adjust_vec_size(16, input->dimension(0)); // Add build options CLBuildOptions build_opts; build_opts.add_option("-DDATA_TYPE=" + get_cl_type_from_data_type(input->data_type())); build_opts.add_option("-DVEC_SIZE=" + support::cpp11::to_string(num_elems_processed_per_iteration)); - build_opts.add_option("-DWIDTH_OFFSET=" + support::cpp11::to_string(_width_offset)); + build_opts.add_option("-DVEC_SIZE_LEFTOVER=" + support::cpp11::to_string(input->dimension(0) % num_elems_processed_per_iteration)); + build_opts.add_option("-DWIDTH_OFFSET=" + support::cpp11::to_string(width_offset)); build_opts.add_option("-DDEPTH=" + support::cpp11::to_string(input->dimension(2))); if(is_data_type_quantized_asymmetric(input->data_type()) && input->quantization_info() != output->quantization_info()) @@ -112,13 +98,13 @@ void CLWidthConcatenateLayerKernel::configure(const CLCompileContext &compile_co // Create kernel _kernel = create_kernel(compile_context, "concatenate_width", build_opts.options()); // Configure kernel window - auto win_config = validate_and_configure_window(input, width_offset, output); - ARM_COMPUTE_ERROR_THROW_ON(std::get<0>(win_config)); - - ICLKernel::configure_internal(std::get<1>(win_config)); + Window win = calculate_max_window(*input, Steps(num_elems_processed_per_iteration)); + ICLKernel::configure_internal(win.collapse(win, Window::DimZ)); // Set output valid region output->set_valid_region(ValidRegion(Coordinates(), output->tensor_shape())); + + ARM_COMPUTE_ERROR_ON(has_padding_changed(padding_info)); } void CLWidthConcatenateLayerKernel::run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue) -- cgit v1.2.1