aboutsummaryrefslogtreecommitdiff
path: root/tests/validation/fixtures/RemapFixture.h
diff options
context:
space:
mode:
authorFrederick Liardet <frederick.liardet@arm.com>2021-04-22 21:13:21 +0100
committerfrederick.liardet <frederick.liardet@arm.com>2021-06-15 11:24:53 +0000
commit36dff9f81e3a95aea19fcc7246a4896930a14bc6 (patch)
tree64f3194e806bb4a8a5e6f2f30c202295c5e853c6 /tests/validation/fixtures/RemapFixture.h
parentee301b384f4aeb697a5c249b8bb848d784146582 (diff)
downloadComputeLibrary-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/fixtures/RemapFixture.h')
-rw-r--r--tests/validation/fixtures/RemapFixture.h62
1 files changed, 48 insertions, 14 deletions
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