diff options
author | Frederick Liardet <frederick.liardet@arm.com> | 2021-04-22 21:13:21 +0100 |
---|---|---|
committer | frederick.liardet <frederick.liardet@arm.com> | 2021-06-15 11:24:53 +0000 |
commit | 36dff9f81e3a95aea19fcc7246a4896930a14bc6 (patch) | |
tree | 64f3194e806bb4a8a5e6f2f30c202295c5e853c6 /tests/validation | |
parent | ee301b384f4aeb697a5c249b8bb848d784146582 (diff) | |
download | ComputeLibrary-36dff9f81e3a95aea19fcc7246a4896930a14bc6.tar.gz |
Add NHWC support to CLRemap
Add NHWC support to CLRemap, also add relevant tests.
Partially resolves COMPMID-4335.
Change-Id: I119bea99be497fb85d5cd83a10f8d4e8e1f97f17
Signed-off-by: Freddie Liardet <frederick.liardet@arm.com>
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5773
Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'tests/validation')
-rw-r--r-- | tests/validation/CL/Remap.cpp | 20 | ||||
-rw-r--r-- | tests/validation/fixtures/RemapFixture.h | 62 |
2 files changed, 58 insertions, 24 deletions
diff --git a/tests/validation/CL/Remap.cpp b/tests/validation/CL/Remap.cpp index f73073105b..bbb3cecea9 100644 --- a/tests/validation/CL/Remap.cpp +++ b/tests/validation/CL/Remap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2020 Arm Limited. + * Copyright (c) 2017-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -44,30 +44,30 @@ namespace validation namespace { constexpr AbsoluteTolerance<uint8_t> tolerance_value(1); -constexpr float tolerance_number = 0.2f; } // namespace TEST_SUITE(CL) TEST_SUITE(Remap) template <typename T> using CLRemapFixture = RemapValidationFixture<CLTensor, CLAccessor, CLRemap, T>; +template <typename T> +using CLRemapLayoutFixture = RemapValidationMixedLayoutFixture<CLTensor, CLAccessor, CLRemap, T>; -FIXTURE_DATA_TEST_CASE(RunSmall, CLRemapFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), - framework::dataset::make("DataType", - DataType::U8)), - framework::dataset::make("BorderModes", { BorderMode::UNDEFINED, BorderMode::CONSTANT }))) +FIXTURE_DATA_TEST_CASE(RunSmall, CLRemapLayoutFixture<uint8_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), + framework::dataset::make("DataType", DataType::U8)), + framework::dataset::make("BorderModes", { BorderMode::UNDEFINED, BorderMode::CONSTANT })), + framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) { // Validate output - validate(CLAccessor(_target), _reference, _valid_mask, tolerance_value, tolerance_number); + validate(CLAccessor(_target), _reference, _valid_mask, tolerance_value); } FIXTURE_DATA_TEST_CASE(RunLarge, CLRemapFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), - framework::dataset::make("DataType", - DataType::U8)), + framework::dataset::make("DataType", DataType::U8)), framework::dataset::make("BorderModes", { BorderMode::UNDEFINED, BorderMode::CONSTANT }))) { // Validate output - validate(CLAccessor(_target), _reference, _valid_mask, tolerance_value, tolerance_number); + validate(CLAccessor(_target), _reference, _valid_mask, tolerance_value); } TEST_SUITE_END() diff --git a/tests/validation/fixtures/RemapFixture.h b/tests/validation/fixtures/RemapFixture.h index 14ea23b247..2cb8e67f62 100644 --- a/tests/validation/fixtures/RemapFixture.h +++ b/tests/validation/fixtures/RemapFixture.h @@ -42,18 +42,19 @@ namespace test namespace validation { template <typename TensorType, typename AccessorType, typename FunctionType, typename T> -class RemapValidationFixture : public framework::Fixture +class RemapValidationGenericFixture : public framework::Fixture { public: template <typename...> - void setup(TensorShape shape, InterpolationPolicy policy, DataType data_type, BorderMode border_mode) + void setup(TensorShape shape, InterpolationPolicy policy, DataType data_type, BorderMode border_mode, DataLayout data_layout = DataLayout::NCHW) { std::mt19937 gen(library->seed()); std::uniform_int_distribution<uint8_t> distribution(0, 255); const T constant_border_value = static_cast<T>(distribution(gen)); - _target = compute_target(shape, policy, data_type, border_mode, constant_border_value); - _reference = compute_reference(shape, policy, data_type, border_mode, constant_border_value); + _data_layout = data_layout; + _target = compute_target(shape, policy, data_type, border_mode, constant_border_value); + _reference = compute_reference(shape, policy, data_type, border_mode, constant_border_value); } protected: @@ -64,13 +65,18 @@ protected: library->fill(tensor, distribution, i); } - TensorType compute_target(const TensorShape &shape, InterpolationPolicy policy, DataType data_type, BorderMode border_mode, T constant_border_value) + TensorType compute_target(TensorShape shape, InterpolationPolicy policy, DataType data_type, BorderMode border_mode, T constant_border_value) { + if(_data_layout == DataLayout::NHWC) + { + permute(shape, PermutationVector(2U, 0U, 1U)); + } + // Create tensors - TensorType src = create_tensor<TensorType>(shape, data_type); - TensorType map_x = create_tensor<TensorType>(shape, DataType::F32); - TensorType map_y = create_tensor<TensorType>(shape, DataType::F32); - TensorType dst = create_tensor<TensorType>(shape, data_type); + TensorType src = create_tensor<TensorType>(shape, data_type, 1, QuantizationInfo(), _data_layout); + TensorType map_x = create_tensor<TensorType>(shape, DataType::F32, 1, QuantizationInfo(), _data_layout); + TensorType map_y = create_tensor<TensorType>(shape, DataType::F32, 1, QuantizationInfo(), _data_layout); + TensorType dst = create_tensor<TensorType>(shape, data_type, 1, QuantizationInfo(), _data_layout); // Create and configure function FunctionType remap; @@ -93,9 +99,11 @@ protected: ARM_COMPUTE_ASSERT(!dst.info()->is_resizable()); // Fill tensors + int max_val = std::max({ shape.x(), shape.y(), shape.z() }); + fill(AccessorType(src), 0, 0, 255); - fill(AccessorType(map_x), 1, -5, shape.x() + 5); - fill(AccessorType(map_y), 2, -5, shape.y() + 5); + fill(AccessorType(map_x), 1, -5, max_val); + fill(AccessorType(map_y), 2, -5, max_val); // Compute function remap.run(); @@ -103,7 +111,7 @@ protected: return dst; } - SimpleTensor<T> compute_reference(const TensorShape &shape, InterpolationPolicy policy, DataType data_type, BorderMode border_mode, T constant_border_value) + SimpleTensor<T> compute_reference(const TensorShape shape, InterpolationPolicy policy, DataType data_type, BorderMode border_mode, T constant_border_value) { ARM_COMPUTE_ERROR_ON(data_type != DataType::U8); @@ -116,9 +124,11 @@ protected: _valid_mask = SimpleTensor<T> { shape, data_type }; // Fill reference + int max_val = std::max({ shape.x(), shape.y(), shape.z() }); + fill(src, 0, 0, 255); - fill(map_x, 1, -5, shape.x() + 5); - fill(map_y, 2, -5, shape.y() + 5); + fill(map_x, 1, -5, max_val); + fill(map_y, 2, -5, max_val); // Compute reference return reference::remap<T>(src, map_x, map_y, _valid_mask, policy, border_mode, constant_border_value); @@ -127,7 +137,31 @@ protected: TensorType _target{}; SimpleTensor<T> _reference{}; SimpleTensor<T> _valid_mask{}; + DataLayout _data_layout{}; +}; + +template <typename TensorType, typename AccessorType, typename FunctionType, typename T> +class RemapValidationFixture : public RemapValidationGenericFixture<TensorType, AccessorType, FunctionType, T> +{ +public: + template <typename...> + void setup(TensorShape shape, InterpolationPolicy policy, DataType data_type, BorderMode border_mode) + { + RemapValidationGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(shape, policy, data_type, border_mode); + } }; + +template <typename TensorType, typename AccessorType, typename FunctionType, typename T> +class RemapValidationMixedLayoutFixture : public RemapValidationGenericFixture<TensorType, AccessorType, FunctionType, T> +{ +public: + template <typename...> + void setup(TensorShape shape, InterpolationPolicy policy, DataType data_type, BorderMode border_mode, DataLayout data_layout) + { + RemapValidationGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(shape, policy, data_type, border_mode, data_layout); + } +}; + } // namespace validation } // namespace test } // namespace arm_compute |