From 7b23732bc8815c7084d4b5f453340fcd740a00fe Mon Sep 17 00:00:00 2001 From: Manuel Bottini Date: Wed, 14 Jul 2021 17:07:23 +0100 Subject: Port CLCol2ImKernel to ClCol2ImKernel Resolves: COMPMID-4517 Change-Id: I50cb02116a1ab86fc29200371944c4774e830746 Signed-off-by: Manuel Bottini Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5949 Reviewed-by: Michele Di Giorgio Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins --- tests/CL/Helper.h | 33 +++++++++++++++++++++++++++++++ tests/validation/CL/Col2Im.cpp | 20 +++++++++---------- tests/validation/fixtures/Col2ImFixture.h | 11 ++++++++--- 3 files changed, 51 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/CL/Helper.h b/tests/CL/Helper.h index b99911e1e6..e3e64c9405 100644 --- a/tests/CL/Helper.h +++ b/tests/CL/Helper.h @@ -218,6 +218,39 @@ private: CLFillBorderKernel _border_handler{}; /**< Kernel to handle borders */ std::unique_ptr _kernel{}; /**< Kernel to run */ }; + +/** As above but this also setups a Zero border on the input tensor of the kernel's bordersize */ +template +class ClSynthetizeOperatorWithBorder : public opencl::IClOperator +{ +public: + /** Configure the kernel. + * + * @param[in] first First configuration argument. + * @param[in] args Rest of the configuration arguments. + */ + template + void configure(T first, Args &&... args) + { + auto k = std::make_unique(); + k->configure(CLKernelLibrary::get().get_compile_context(), first, std::forward(args)...); + _kernel = std::move(k); + + auto b = std::make_unique(); + b->configure(CLKernelLibrary::get().get_compile_context(), first, BorderSize(_kernel->border_size()), BorderMode::CONSTANT, PixelValue()); + _border_handler = std::move(b); + } + + void run(ITensorPack &tensors) override + { + CLScheduler::get().enqueue(*_border_handler); + CLScheduler::get().enqueue_op(*_kernel, tensors); + } + +private: + std::unique_ptr _border_handler{ nullptr }; /**< Kernel to handle borders */ + std::unique_ptr _kernel{}; /**< Kernel to run */ +}; } // namespace test } // namespace arm_compute #endif /* ARM_COMPUTE_TEST_CL_HELPER_H */ diff --git a/tests/validation/CL/Col2Im.cpp b/tests/validation/CL/Col2Im.cpp index b651bf8918..96096d314d 100644 --- a/tests/validation/CL/Col2Im.cpp +++ b/tests/validation/CL/Col2Im.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020 Arm Limited. + * Copyright (c) 2018-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -22,7 +22,7 @@ * SOFTWARE. */ #include "arm_compute/core/Types.h" -#include "src/core/CL/kernels/CLCol2ImKernel.h" +#include "src/core/gpu/cl/kernels/ClCol2ImKernel.h" #include "tests/CL/CLAccessor.h" #include "tests/CL/Helper.h" #include "tests/framework/Asserts.h" @@ -40,7 +40,7 @@ namespace validation TEST_SUITE(CL) TEST_SUITE(Col2Im) -using CLCol2Im = CLSynthetizeFunction; +using ClCol2Im = ClSynthetizeOperatorWithBorder; /** Negative tests * @@ -59,7 +59,7 @@ TEST_CASE(Negative, framework::DatasetMode::ALL) const auto input = TensorInfo(TensorShape(10U, 12U, 1U, 2U), 1, DataType::SIZET); const auto output = TensorInfo(TensorShape(3U, 4U, 10U, 1U, 2U), 1, DataType::F32); const auto conv_size = Size2D(3, 4); - const auto status = CLCol2ImKernel::validate(&input, &output, conv_size); + const auto status = opencl::kernels::ClCol2ImKernel::validate(&input, &output, conv_size); ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS); } @@ -68,7 +68,7 @@ TEST_CASE(Negative, framework::DatasetMode::ALL) const auto input = TensorInfo(TensorShape(10U, 12U, 1U, 2U), 1, DataType::F32); const auto output = TensorInfo(TensorShape(3U, 4U, 10U, 1U, 2U), 1, DataType::F32, DataLayout::NHWC); const auto conv_size = Size2D(3, 4); - const auto status = CLCol2ImKernel::validate(&input, &output, conv_size); + const auto status = opencl::kernels::ClCol2ImKernel::validate(&input, &output, conv_size); ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS); } @@ -77,13 +77,13 @@ TEST_CASE(Negative, framework::DatasetMode::ALL) const auto input = TensorInfo(TensorShape(10U, 12U, 1U, 2U), 1, DataType::F32); const auto output = TensorInfo(TensorShape(3U, 4U, 10U, 2U, 2U), 1, DataType::F32); const auto conv_size = Size2D(3, 4); - const auto status = CLCol2ImKernel::validate(&input, &output, conv_size); + const auto status = opencl::kernels::ClCol2ImKernel::validate(&input, &output, conv_size); ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS); } } template -using CLCol2ImFixture = Col2ImValidationFixture; +using ClCol2ImFixture = Col2ImOpValidationFixture; /** Test kernel for single-precision floating point * @@ -99,7 +99,7 @@ using CLCol2ImFixture = Col2ImValidationFixture, + ClCol2ImFixture, framework::DatasetMode::ALL, combine(combine(combine(combine( framework::dataset::make("InputShape", { TensorShape(8U, 16U, 3U, 1U), TensorShape(17U, 16U, 3U, 1U), TensorShape(7U, 16U, 3U, 1U) }), @@ -125,7 +125,7 @@ FIXTURE_DATA_TEST_CASE(FP32, * Kernel tested col2im */ FIXTURE_DATA_TEST_CASE(F16, - CLCol2ImFixture, + ClCol2ImFixture, framework::DatasetMode::ALL, combine(combine(combine(combine( framework::dataset::make("InputShape", TensorShape(17U, 16U, 3U, 1U)), @@ -151,7 +151,7 @@ FIXTURE_DATA_TEST_CASE(F16, * Kernel tested col2im */ FIXTURE_DATA_TEST_CASE(QASYMM8, - CLCol2ImFixture, + ClCol2ImFixture, framework::DatasetMode::ALL, combine(combine(combine(combine( framework::dataset::make("InputShape", TensorShape(17U, 16U, 3U, 1U)), diff --git a/tests/validation/fixtures/Col2ImFixture.h b/tests/validation/fixtures/Col2ImFixture.h index 88d420aa3d..ee7a14f844 100644 --- a/tests/validation/fixtures/Col2ImFixture.h +++ b/tests/validation/fixtures/Col2ImFixture.h @@ -45,7 +45,7 @@ namespace validation using namespace arm_compute::misc::shape_calculator; template -class Col2ImValidationFixture : public framework::Fixture +class Col2ImOpValidationFixture : public framework::Fixture { public: template @@ -74,7 +74,7 @@ protected: // Create and configure function FunctionType col2im_func; - col2im_func.configure(&src, &dst, convolved_dims, num_groups); + col2im_func.configure(src.info(), dst.info(), convolved_dims, num_groups); ARM_COMPUTE_ASSERT(src.info()->is_resizable()); ARM_COMPUTE_ASSERT(dst.info()->is_resizable()); @@ -89,8 +89,13 @@ protected: // Fill tensors fill(AccessorType(src), 0); + arm_compute::ITensorPack pack = + { + { arm_compute::TensorType::ACL_SRC, &src }, + { arm_compute::TensorType::ACL_DST, &dst } + }; // Compute function - col2im_func.run(); + col2im_func.run(pack); return dst; } -- cgit v1.2.1