From adfb2737046028c042f0aecaff87733a442da29f Mon Sep 17 00:00:00 2001 From: John Kesapides Date: Mon, 4 Mar 2019 16:29:22 +0000 Subject: COMPMID-1935 Add support for QASYMM8 in NEQuantizeLayer Change-Id: I2b63a644d8e34f91c830d9ac398debcbdca3e497 Signed-off-by: John Kesapides Reviewed-on: https://review.mlplatform.org/c/829 Reviewed-by: Georgios Pinitas Tested-by: Arm Jenkins --- .../validation/fixtures/QuantizationLayerFixture.h | 65 +++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) (limited to 'tests/validation/fixtures') diff --git a/tests/validation/fixtures/QuantizationLayerFixture.h b/tests/validation/fixtures/QuantizationLayerFixture.h index 8590b7193b..65de405788 100644 --- a/tests/validation/fixtures/QuantizationLayerFixture.h +++ b/tests/validation/fixtures/QuantizationLayerFixture.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 ARM Limited. + * Copyright (c) 2017-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -103,6 +103,69 @@ protected: TensorType _target{}; SimpleTensor _reference{}; }; + +template +class QAsymm8QuantizationValidationFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape shape, DataType data_type, QuantizationInfo quant_info) + { + _target = compute_target(shape, data_type, quant_info); + _reference = compute_reference(shape, data_type, quant_info); + } + +protected: + template + void fill(U &&tensor) + { + library->fill_tensor_uniform(tensor, 0); + } + + TensorType compute_target(const TensorShape &shape, DataType data_type, QuantizationInfo quant_info) + { + // Create tensors + TensorType src = create_tensor(shape, data_type); + TensorType dst = create_tensor(shape, DataType::QASYMM8, 1, quant_info); + + // Create and configure function + FunctionType quantization_layer; + quantization_layer.configure(&src, &dst); + + ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Fill tensors + fill(AccessorType(src)); + + // Compute function + quantization_layer.run(); + + return dst; + } + + SimpleTensor compute_reference(const TensorShape &shape, DataType data_type, QuantizationInfo quant_info) + { + // Create reference + SimpleTensor src{ shape, data_type }; + + // Fill reference + fill(src); + + return reference::quantization_layer(src, quant_info); + } + + TensorType _target{}; + SimpleTensor _reference{}; +}; + } // namespace validation } // namespace test } // namespace arm_compute -- cgit v1.2.1