diff options
author | Giorgio Arena <giorgio.arena@arm.com> | 2021-09-01 14:05:00 +0100 |
---|---|---|
committer | Giorgio Arena <giorgio.arena@arm.com> | 2021-09-03 14:04:19 +0000 |
commit | 8fce496a715929372b3c448a233713d87d65f768 (patch) | |
tree | 283841880dd0c969addda1c08f50fc6e622ff07d /src/gpu/cl/operators | |
parent | b8025b3bb1b75fa94400a665e65a1d53ba9965f9 (diff) | |
download | ComputeLibrary-8fce496a715929372b3c448a233713d87d65f768.tar.gz |
Remove padding from ClPool2dKernel NCHW
- Simplify NCHW kernel structure by removing old optimized paths
- Merge quantized with fp kernels
Resolve COMPMID-4722
Signed-off-by: Giorgio Arena <giorgio.arena@arm.com>
Change-Id: I79016b119619aed6a6193295601cd6517f14b88c
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/6183
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Gian Marco Iodice <gianmarco.iodice@arm.com>
Diffstat (limited to 'src/gpu/cl/operators')
-rw-r--r-- | src/gpu/cl/operators/ClPool2d.cpp | 52 | ||||
-rw-r--r-- | src/gpu/cl/operators/ClPool2d.h | 8 |
2 files changed, 2 insertions, 58 deletions
diff --git a/src/gpu/cl/operators/ClPool2d.cpp b/src/gpu/cl/operators/ClPool2d.cpp index fdadd199fc..a5b18a2340 100644 --- a/src/gpu/cl/operators/ClPool2d.cpp +++ b/src/gpu/cl/operators/ClPool2d.cpp @@ -25,7 +25,6 @@ #include "arm_compute/runtime/CL/CLScheduler.h" -#include "src/core/CL/kernels/CLFillBorderKernel.h" #include "src/gpu/cl/ClCompileContext.h" #include "src/gpu/cl/kernels/ClPool2dKernel.h" @@ -40,62 +39,15 @@ void ClPool2d::configure(const ClCompileContext &compile_context, ITensorInfo *s auto k = std::make_unique<kernels::ClPool2dKernel>(); k->set_target(CLScheduler::get().target()); k->configure(compile_context, src, dst, info, indices); - _pooling = std::move(k); - - const DataType data_type = src->data_type(); - - // Configure border depending on operation required (quantize border in case of asymmetric data_type) - BorderMode border_mode{}; - PixelValue pixel_value(0.f); - if(is_data_type_quantized_asymmetric(data_type) && !info.exclude_padding) - { - pixel_value = PixelValue(0, data_type, src->quantization_info()); - } - - // Data layout - const auto data_layout = info.data_layout == DataLayout::UNKNOWN ? src->data_layout() : info.data_layout; - - switch(data_layout) - { - case DataLayout::NCHW: - border_mode = (PoolingType::MAX == info.pool_type) ? BorderMode::REPLICATE : BorderMode::CONSTANT; - break; - case DataLayout::NHWC: - border_mode = BorderMode::CONSTANT; - if(PoolingType::MAX == info.pool_type) - { - if(is_data_type_quantized(data_type)) - { - std::tie(pixel_value, std::ignore) = get_min_max(data_type); - } - else - { - pixel_value = PixelValue(std::numeric_limits<float>::lowest()); - } - } - break; - default: - ARM_COMPUTE_ERROR("Data layout not supported"); - } - auto b = std::make_unique<CLFillBorderKernel>(); - b->configure(compile_context, src, _pooling->border_size(), border_mode, pixel_value); - _border_handler = std::move(b); + _kernel = std::move(k); // Tune kernels - CLScheduler::get().tune_kernel_static(*_pooling); + CLScheduler::get().tune_kernel_static(*_kernel); } Status ClPool2d::validate(const ITensorInfo *src, const ITensorInfo *dst, const PoolingLayerInfo &info, const ITensorInfo *indices) { return kernels::ClPool2dKernel::validate(src, dst, info, indices); } - -void ClPool2d::run(ITensorPack &tensors) -{ - ARM_COMPUTE_ERROR_ON_MSG(tensors.empty(), "No inputs provided"); - - CLScheduler::get().enqueue_op(*_border_handler.get(), tensors, false); - CLScheduler::get().enqueue_op(*_pooling.get(), tensors, false); -} } // namespace opencl } // namespace arm_compute diff --git a/src/gpu/cl/operators/ClPool2d.h b/src/gpu/cl/operators/ClPool2d.h index a041053bb3..f353ba262e 100644 --- a/src/gpu/cl/operators/ClPool2d.h +++ b/src/gpu/cl/operators/ClPool2d.h @@ -35,7 +35,6 @@ namespace opencl { /** Basic function to simulate a pooling layer with the specified pooling operation. This function calls the following OpenCL kernels: * - * -# @ref CLFillBorderKernel (executed if padding size is different from zero) * -# @ref opencl::ClPool2d */ class ClPool2d : public IClOperator @@ -59,13 +58,6 @@ public: * @return a status */ static Status validate(const ITensorInfo *src, const ITensorInfo *dst, const PoolingLayerInfo &info, const ITensorInfo *indices = nullptr); - - // Inherited method overridden - void run(ITensorPack &tensors) override; - -private: - std::unique_ptr<ICLKernel> _pooling{ nullptr }; - std::unique_ptr<ICLKernel> _border_handler{ nullptr }; }; } // namespace opencl } // namespace arm_compute |