From a52e4cf36ec86b63660f5a687073fa0985384dc1 Mon Sep 17 00:00:00 2001 From: Pablo Tello Date: Mon, 1 Apr 2019 14:55:18 +0100 Subject: COMPMID-2060: Support different qinfo in PoolingLayer CL and Neon back ends now support different qinfos Change-Id: I638d5f258ab2f99b40659601b4c5398d2c34c43b Signed-off-by: Pablo Tello Reviewed-on: https://review.mlplatform.org/c/927 Tested-by: Arm Jenkins Comments-Addressed: Arm Jenkins Reviewed-by: Michalis Spyrou Reviewed-by: Gian Marco Iodice --- tests/validation/fixtures/PoolingLayerFixture.h | 44 +++++++++++++------------ 1 file changed, 23 insertions(+), 21 deletions(-) (limited to 'tests/validation/fixtures') diff --git a/tests/validation/fixtures/PoolingLayerFixture.h b/tests/validation/fixtures/PoolingLayerFixture.h index 3e34f98271..1813ef4c84 100644 --- a/tests/validation/fixtures/PoolingLayerFixture.h +++ b/tests/validation/fixtures/PoolingLayerFixture.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 ARM Limited. + * Copyright (c) 2017-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -26,6 +26,7 @@ #include "arm_compute/core/TensorShape.h" #include "arm_compute/core/Types.h" +#include "arm_compute/core/utils/misc/ShapeCalculator.h" #include "arm_compute/runtime/Tensor.h" #include "tests/AssetsLibrary.h" #include "tests/Globals.h" @@ -47,13 +48,16 @@ class PoolingLayerValidationGenericFixture : public framework::Fixture { public: template - void setup(TensorShape shape, PoolingLayerInfo pool_info, DataType data_type, DataLayout data_layout, QuantizationInfo quantization_info) + void setup(TensorShape shape, PoolingLayerInfo pool_info, DataType data_type, DataLayout data_layout) { - _quantization_info = quantization_info; - _pool_info = pool_info; - - _target = compute_target(shape, pool_info, data_type, data_layout, quantization_info); - _reference = compute_reference(shape, pool_info, data_type, quantization_info); + std::mt19937 gen(library->seed()); + std::uniform_int_distribution<> offset_dis(0, 20); + const QuantizationInfo input_qinfo(1.f / 255.f, offset_dis(gen)); + const QuantizationInfo output_qinfo(1.f / 255.f, offset_dis(gen)); + + _pool_info = pool_info; + _target = compute_target(shape, pool_info, data_type, data_layout, input_qinfo, output_qinfo); + _reference = compute_reference(shape, pool_info, data_type, input_qinfo, output_qinfo); } protected: @@ -72,7 +76,7 @@ protected: } TensorType compute_target(TensorShape shape, PoolingLayerInfo info, - DataType data_type, DataLayout data_layout, QuantizationInfo quantization_info) + DataType data_type, DataLayout data_layout, QuantizationInfo input_qinfo, QuantizationInfo output_qinfo) { // Change shape in case of NHWC. if(data_layout == DataLayout::NHWC) @@ -81,8 +85,9 @@ protected: } // Create tensors - TensorType src = create_tensor(shape, data_type, 1, quantization_info, data_layout); - TensorType dst; + TensorType src = create_tensor(shape, data_type, 1, input_qinfo, data_layout); + const TensorShape dst_shape = misc::shape_calculator::compute_pool_shape(*(src.info()), info); + TensorType dst = create_tensor(dst_shape, data_type, 1, output_qinfo, data_layout); // Create and configure function FunctionType pool_layer; @@ -107,21 +112,19 @@ protected: return dst; } - SimpleTensor compute_reference(const TensorShape &shape, PoolingLayerInfo info, - DataType data_type, QuantizationInfo quantization_info) + SimpleTensor compute_reference(const TensorShape &shape, PoolingLayerInfo info, DataType data_type, QuantizationInfo input_qinfo, QuantizationInfo output_qinfo) { // Create reference - SimpleTensor src{ shape, data_type, 1, quantization_info }; + SimpleTensor src{ shape, data_type, 1, input_qinfo }; // Fill reference fill(src); - return reference::pooling_layer(src, info); + return reference::pooling_layer(src, info, output_qinfo); } TensorType _target{}; SimpleTensor _reference{}; - QuantizationInfo _quantization_info{}; PoolingLayerInfo _pool_info{}; }; @@ -133,7 +136,7 @@ public: void setup(TensorShape shape, PoolingType pool_type, Size2D pool_size, PadStrideInfo pad_stride_info, bool exclude_padding, DataType data_type, DataLayout data_layout) { PoolingLayerValidationGenericFixture::setup(shape, PoolingLayerInfo(pool_type, pool_size, pad_stride_info, exclude_padding), - data_type, data_layout, QuantizationInfo()); + data_type, data_layout); } }; @@ -142,11 +145,10 @@ class PoolingLayerValidationQuantizedFixture : public PoolingLayerValidationGene { public: template - void setup(TensorShape shape, PoolingType pool_type, Size2D pool_size, PadStrideInfo pad_stride_info, bool exclude_padding, DataType data_type, - QuantizationInfo quantization_info, DataLayout data_layout = DataLayout::NCHW) + void setup(TensorShape shape, PoolingType pool_type, Size2D pool_size, PadStrideInfo pad_stride_info, bool exclude_padding, DataType data_type, DataLayout data_layout = DataLayout::NCHW) { PoolingLayerValidationGenericFixture::setup(shape, PoolingLayerInfo(pool_type, pool_size, pad_stride_info, exclude_padding), - data_type, data_layout, quantization_info); + data_type, data_layout); } }; @@ -157,7 +159,7 @@ public: template void setup(TensorShape src_shape, PoolingLayerInfo pool_info, DataType data_type) { - PoolingLayerValidationGenericFixture::setup(src_shape, pool_info, data_type, DataLayout::NCHW, QuantizationInfo()); + PoolingLayerValidationGenericFixture::setup(src_shape, pool_info, data_type, DataLayout::NCHW); } }; @@ -168,7 +170,7 @@ public: template void setup(TensorShape shape, PoolingType pool_type, DataType data_type, DataLayout data_layout = DataLayout::NCHW) { - PoolingLayerValidationGenericFixture::setup(shape, PoolingLayerInfo(pool_type), data_type, DataLayout::NCHW, QuantizationInfo()); + PoolingLayerValidationGenericFixture::setup(shape, PoolingLayerInfo(pool_type), data_type, DataLayout::NCHW); } }; -- cgit v1.2.1