COMPMID-3069: Allow different quantization info in NEElementwiseMin/Max
authorMichele Di Giorgio <michele.digiorgio@arm.com>
Wed, 29 Apr 2020 16:25:20 +0000 (17:25 +0100)
committerMichele Di Giorgio <michele.digiorgio@arm.com>
Fri, 1 May 2020 08:35:56 +0000 (08:35 +0000)
Change-Id: I97f9f7e9f054b2a812a23b25cfb21033f76a9101
Signed-off-by: Michele Di Giorgio <michele.digiorgio@arm.com>
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3125
Reviewed-by: Manuel Bottini <manuel.bottini@arm.com>
Reviewed-by: Gian Marco Iodice <gianmarco.iodice@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
src/core/NEON/kernels/NEElementwiseOperationKernel.cpp
src/runtime/NEON/functions/NEElementwiseOperators.cpp
tests/validation/NEON/ElementwiseMax.cpp
tests/validation/NEON/ElementwiseMin.cpp

index 444ee8e0d3752fca7771a174bf9dd3d9716db01f..0579dc67f4107b60e5d699744a8d0701fa5d1fd5 100644 (file)
 #include "arm_compute/core/NEON/kernels/NEElementwiseOperationKernel.h"
 
 #include "arm_compute/core/CPP/Validate.h"
-#include "arm_compute/core/Error.h"
 #include "arm_compute/core/Helpers.h"
 #include "arm_compute/core/IAccessWindow.h"
-#include "arm_compute/core/ITensor.h"
 #include "arm_compute/core/NEON/NEAsymm.h"
 #include "arm_compute/core/NEON/NEFixedPoint.h"
 #include "arm_compute/core/NEON/wrapper/wrapper.h"
-#include "arm_compute/core/TensorInfo.h"
-#include "arm_compute/core/Validate.h"
 
-#include <algorithm>
 #include <arm_neon.h>
-#include <cstdint>
 #include <map>
-#include <string>
 
 namespace arm_compute
 {
-class Coordinates;
-
 namespace
 {
 float32x4x4_t load_quantized(const uint8_t *input1_ptr, const int32x4_t &offset, const float32x4_t &scale)
index 7451c6ff2b367f05a2fc000eba119e4d971dcdc1..926ae1fa21b8c8d077abfffd31572fbc9f261eff 100644 (file)
@@ -43,11 +43,6 @@ void NEElementwiseMax::configure(ITensor *input1, ITensor *input2, ITensor *outp
 Status NEElementwiseMax::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info)
 {
     ARM_COMPUTE_RETURN_ERROR_ON(act_info.enabled());
-    if(input1->data_type() == DataType::QASYMM8_SIGNED)
-    {
-        ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input1, output);
-        ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_QUANTIZATION_INFO(input1, input2, output);
-    }
     return NEArithmeticOperationKernel::validate(ArithmeticOperation::MAX, input1, input2, output);
 }
 
@@ -62,11 +57,6 @@ void NEElementwiseMin::configure(ITensor *input1, ITensor *input2, ITensor *outp
 Status NEElementwiseMin::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info)
 {
     ARM_COMPUTE_RETURN_ERROR_ON(act_info.enabled());
-    if(input1->data_type() == DataType::QASYMM8_SIGNED)
-    {
-        ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input1, output);
-        ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_QUANTIZATION_INFO(input1, input2, output);
-    }
     return NEArithmeticOperationKernel::validate(ArithmeticOperation::MIN, input1, input2, output);
 }
 
index fc6bb9454d756707ca2aaeeb1a06c9c128e34e95..bd61ba50a33f4f31d188b47fdebfd1ab0cb96e91 100644 (file)
@@ -41,7 +41,8 @@ namespace validation
 {
 namespace
 {
-RelativeTolerance<float> tolerance_fp32(0.000001f);
+constexpr RelativeTolerance<float>  tolerance_fp32(0.000001f);
+constexpr AbsoluteTolerance<int8_t> tolerance_qasymm8_signed(1);
 /** Input data sets **/
 const auto ElementwiseMaxQASYMM8Dataset = combine(combine(framework::dataset::make("DataType", DataType::QASYMM8), framework::dataset::make("DataType", DataType::QASYMM8)),
                                                   framework::dataset::make("DataType",
@@ -79,8 +80,6 @@ DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(
                                                         TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32),            // Mismatching shapes
                                                         TensorInfo(TensorShape(8U, 8U, 3U), 1, DataType::QASYMM8_SIGNED),   // OK
                                                         TensorInfo(TensorShape(8U, 8U, 3U), 1, DataType::QASYMM8_SIGNED),   // Mismatching data types
-                                                        TensorInfo(TensorShape(8U, 8U, 3U), 1, DataType::QASYMM8_SIGNED,QuantizationInfo(0.1f, 2) ),   // Mismatching qinfo
-
                                                       }),
                framework::dataset::make("Input2Info",{ TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32),
                                                        TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S32),
@@ -89,8 +88,6 @@ DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(
                                                        TensorInfo(TensorShape(48U, 11U, 2U), 1, DataType::F32),
                                                        TensorInfo(TensorShape(8U, 8U, 3U), 1, DataType::QASYMM8_SIGNED),
                                                        TensorInfo(TensorShape(8U, 8U, 3U), 1, DataType::QASYMM8),
-                                                       TensorInfo(TensorShape(8U, 8U, 3U), 1, DataType::QASYMM8_SIGNED,QuantizationInfo(0.4f, 5) ),   // Mismatching qinfo
-
                                                      })),
                framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32),
                                                        TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S32),
@@ -99,10 +96,9 @@ DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(
                                                        TensorInfo(TensorShape(48U, 11U, 2U), 1, DataType::F32),
                                                        TensorInfo(TensorShape(8U, 8U, 3U), 1, DataType::QASYMM8_SIGNED),
                                                        TensorInfo(TensorShape(8U, 8U, 3U), 1, DataType::QASYMM8_SIGNED),
-                                                       TensorInfo(TensorShape(8U, 8U, 3U), 1, DataType::QASYMM8_SIGNED,QuantizationInfo(0.3f,4 ) ),   // Mismatching qinfo
                                                      })),
 
-               framework::dataset::make("Expected", { true, true, true, false, false, true, false, false,false})),
+               framework::dataset::make("Expected", { true, true, true, false, false, true, false, false })),
                input1_info, input2_info, output_info, expected)
 {
     ARM_COMPUTE_EXPECT(bool(NEElementwiseMax::validate(
@@ -162,12 +158,12 @@ TEST_SUITE_END()
 TEST_SUITE(QASYMM8_SIGNED)
 FIXTURE_DATA_TEST_CASE(RunSmall, NEElementwiseMaxQuantizedFixture<int8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(datasets::SmallShapes(),
                                                                                                                       ElementwiseMaxQASYMM8SignedDataset),
-                                                                                                                      framework::dataset::make("QuantizationInfo", { QuantizationInfo(10.f, 2) })),
-                                                                                                                      framework::dataset::make("QuantizationInfo", { QuantizationInfo(10.f, 2) })),
-                                                                                                                      framework::dataset::make("QuantizationInfo", { QuantizationInfo(10.f, 2) })))
+                                                                                                                      framework::dataset::make("QuantizationInfo", { QuantizationInfo(10.f, 20) })),
+                                                                                                                      framework::dataset::make("QuantizationInfo", { QuantizationInfo(1.f, 0) })),
+                                                                                                                      framework::dataset::make("QuantizationInfo", { QuantizationInfo(2.f, -27) })))
 {
     // Validate output
-    validate(Accessor(_target), _reference);
+    validate(Accessor(_target), _reference, tolerance_qasymm8_signed);
 }
 
 TEST_SUITE_END()
index 9b950a06a799838f8668cc062bd91e90c3fd5c17..0fc6f5fead183498aabcf3f11e6cf9779ef43c36 100644 (file)
@@ -41,7 +41,8 @@ namespace validation
 {
 namespace
 {
-RelativeTolerance<float> tolerance_fp32(0.000001f);
+constexpr RelativeTolerance<float>  tolerance_fp32(0.000001f);
+constexpr AbsoluteTolerance<int8_t> tolerance_qasymm8_signed(1);
 /** Input data sets **/
 const auto ElementwiseMinQASYMM8Dataset = combine(combine(framework::dataset::make("DataType", DataType::QASYMM8), framework::dataset::make("DataType", DataType::QASYMM8)),
                                                   framework::dataset::make("DataType",
@@ -79,7 +80,6 @@ DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(
                                                         TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32),                // Mismatching shapes
                                                         TensorInfo(TensorShape(4U, 4U, 2U), 1, DataType::QASYMM8_SIGNED),       // Ok
                                                         TensorInfo(TensorShape(4U, 4U, 2U), 1, DataType::QASYMM8_SIGNED),       // Mismatching types, cannot mix QASYMM8_SIGNED with QASYMM8
-                                                        TensorInfo(TensorShape(1U, 2U, 3U), 1, DataType::QASYMM8_SIGNED,QuantizationInfo(0.1f, 2) ),   // Mismatching qinfo
                                                       }),
                framework::dataset::make("Input2Info",{ TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32),
                                                        TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S32),
@@ -88,7 +88,6 @@ DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(
                                                        TensorInfo(TensorShape(48U, 11U, 2U), 1, DataType::F32),
                                                        TensorInfo(TensorShape(4U, 4U, 2U), 1, DataType::QASYMM8_SIGNED),
                                                        TensorInfo(TensorShape(4U, 4U, 2U), 1, DataType::QASYMM8),
-                                                       TensorInfo(TensorShape(1U, 2U, 3U), 1, DataType::QASYMM8_SIGNED,QuantizationInfo(0.5f, 1) ),
                                                      })),
                framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32),
                                                        TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S32),
@@ -97,10 +96,9 @@ DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(
                                                        TensorInfo(TensorShape(48U, 11U, 2U), 1, DataType::F32),
                                                        TensorInfo(TensorShape(4U, 4U, 2U), 1, DataType::QASYMM8_SIGNED),
                                                        TensorInfo(TensorShape(4U, 4U, 2U), 1, DataType::QASYMM8_SIGNED),
-                                                       TensorInfo(TensorShape(1U, 2U, 3U), 1, DataType::QASYMM8_SIGNED,QuantizationInfo(0.5f, 1) ),
                                                      })),
                framework::dataset::make("Expected", { true, true, true, false,
-                                                      false,true,false,false})),
+                                                      false,true,false})),
                input1_info, input2_info, output_info, expected)
 {
     ARM_COMPUTE_EXPECT(bool(NEElementwiseMin::validate(
@@ -161,12 +159,12 @@ TEST_SUITE_END()
 TEST_SUITE(QASYMM8_SIGNED)
 FIXTURE_DATA_TEST_CASE(RunSmall, NEElementwiseMinQuantizedFixture<int8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(datasets::SmallShapes(),
                                                                                                                       ElementwiseMaxQASYMM8SignedDataset),
-                                                                                                                      framework::dataset::make("QuantizationInfo", { QuantizationInfo(10.f, 2) })),
-                                                                                                                      framework::dataset::make("QuantizationInfo", { QuantizationInfo(10.f, 2) })),
-                                                                                                                      framework::dataset::make("QuantizationInfo", { QuantizationInfo(10.f, 2) })))
+                                                                                                                      framework::dataset::make("QuantizationInfo", { QuantizationInfo(10.f, 20) })),
+                                                                                                                      framework::dataset::make("QuantizationInfo", { QuantizationInfo(1.f, 0) })),
+                                                                                                                      framework::dataset::make("QuantizationInfo", { QuantizationInfo(2.f, -27) })))
 {
     // Validate output
-    validate(Accessor(_target), _reference);
+    validate(Accessor(_target), _reference, tolerance_qasymm8_signed);
 }
 
 TEST_SUITE_END()