From b57be0da77370e5e71fe82dfa281f528279e8127 Mon Sep 17 00:00:00 2001 From: Michele Di Giorgio Date: Fri, 31 Aug 2018 16:26:25 +0100 Subject: COMPMID-1330: Add support for NormalizePlanarYUV operator in CL Change-Id: Id0754b9e2bc3ef7ff2c4c21c3b89709588c41bd3 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/146637 Tested-by: Jenkins Reviewed-by: Georgios Pinitas Reviewed-by: Giorgio Arena --- .../fixtures/NormalizePlanarYUVLayerFixture.h | 39 ++++++++++++---------- 1 file changed, 22 insertions(+), 17 deletions(-) (limited to 'tests/validation/fixtures') diff --git a/tests/validation/fixtures/NormalizePlanarYUVLayerFixture.h b/tests/validation/fixtures/NormalizePlanarYUVLayerFixture.h index 09905cfef7..cc73e530ef 100644 --- a/tests/validation/fixtures/NormalizePlanarYUVLayerFixture.h +++ b/tests/validation/fixtures/NormalizePlanarYUVLayerFixture.h @@ -45,16 +45,16 @@ class NormalizePlanarYUVLayerValidationFixture : public framework::Fixture { public: template - void setup(TensorShape shape0, TensorShape shape1, DataType dt) + void setup(TensorShape shape0, TensorShape shape1, DataType dt, DataLayout data_layout) { _data_type = dt; - _target = compute_target(shape0, shape1, dt); + _target = compute_target(shape0, shape1, dt, data_layout); _reference = compute_reference(shape0, shape1, dt); } protected: template - void fill(U &&src_tensor, U &&mean_tensor, U &&sd_tensor) + void fill(U &&src_tensor, U &&mean_tensor, U &&std_tensor) { if(is_data_type_float(_data_type)) { @@ -62,43 +62,48 @@ protected: float max_bound = 0.f; std::tie(min_bound, max_bound) = get_normalize_planar_yuv_layer_test_bounds(); std::uniform_real_distribution<> distribution(min_bound, max_bound); - std::uniform_real_distribution<> distribution_sd(0.1, max_bound); + std::uniform_real_distribution<> distribution_std(0.1, max_bound); library->fill(src_tensor, distribution, 0); library->fill(mean_tensor, distribution, 1); - library->fill(sd_tensor, distribution_sd, 2); + library->fill(std_tensor, distribution_std, 2); } } - TensorType compute_target(const TensorShape &shape0, const TensorShape &shape1, DataType dt) + TensorType compute_target(TensorShape shape0, const TensorShape &shape1, DataType dt, DataLayout data_layout) { + if(data_layout == DataLayout::NHWC) + { + permute(shape0, PermutationVector(2U, 0U, 1U)); + } + // Create tensors - TensorType src = create_tensor(shape0, dt, 1); - TensorType dst = create_tensor(shape0, dt, 1); + TensorType src = create_tensor(shape0, dt, 1, QuantizationInfo(), data_layout); + TensorType dst = create_tensor(shape0, dt, 1, QuantizationInfo(), data_layout); TensorType mean = create_tensor(shape1, dt, 1); - TensorType sd = create_tensor(shape1, dt, 1); + TensorType std = create_tensor(shape1, dt, 1); // Create and configure function FunctionType norm; - norm.configure(&src, &dst, &mean, &sd); + norm.configure(&src, &dst, &mean, &std); ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); ARM_COMPUTE_EXPECT(mean.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(sd.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(std.info()->is_resizable(), framework::LogLevel::ERRORS); // Allocate tensors src.allocator()->allocate(); dst.allocator()->allocate(); mean.allocator()->allocate(); - sd.allocator()->allocate(); + std.allocator()->allocate(); ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); ARM_COMPUTE_EXPECT(!mean.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!sd.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!std.info()->is_resizable(), framework::LogLevel::ERRORS); // Fill tensors - fill(AccessorType(src), AccessorType(mean), AccessorType(sd)); + fill(AccessorType(src), AccessorType(mean), AccessorType(std)); // Compute function norm.run(); @@ -111,12 +116,12 @@ protected: // Create reference SimpleTensor ref_src{ shape0, dt, 1 }; SimpleTensor ref_mean{ shape1, dt, 1 }; - SimpleTensor ref_sd{ shape1, dt, 1 }; + SimpleTensor ref_std{ shape1, dt, 1 }; // Fill reference - fill(ref_src, ref_mean, ref_sd); + fill(ref_src, ref_mean, ref_std); - return reference::normalize_planar_yuv_layer(ref_src, ref_mean, ref_sd); + return reference::normalize_planar_yuv_layer(ref_src, ref_mean, ref_std); } TensorType _target{}; -- cgit v1.2.1