diff options
author | Adnan AlSinan <adnan.alsinan@arm.com> | 2022-04-06 16:19:31 +0100 |
---|---|---|
committer | Adnan AlSinan <adnan.alsinan@arm.com> | 2022-04-13 11:55:45 +0000 |
commit | 9104cd559222b98f2b21f14d4fd561ed4a4e9bc2 (patch) | |
tree | 628b30de762e8e1dc3d21c5dcb76a92212fa00af /tests/validation | |
parent | 16c5697085c256c19fb8ba4bef6188d61f30a88b (diff) | |
download | ComputeLibrary-9104cd559222b98f2b21f14d4fd561ed4a4e9bc2.tar.gz |
Add support for int8 CpuPool3d
- Add implementation for the CPU pooling 3d layer.
- NDHWC data layout support.
- Support QASYMM8/QASYMM8_SIGNED.
- Add Pooling helper file for Pool3d/2d common functions.
Resolves COMPMID-4668
Change-Id: Iadf042036b076099c2353d6e2fe9fc623bc263d8
Signed-off-by: Adnan AlSinan <adnan.alsinan@arm.com>
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/7387
Reviewed-by: Gunes Bayir <gunes.bayir@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'tests/validation')
-rw-r--r-- | tests/validation/NEON/Pooling3dLayer.cpp | 78 | ||||
-rw-r--r-- | tests/validation/fixtures/Pooling3dLayerFixture.h | 37 |
2 files changed, 100 insertions, 15 deletions
diff --git a/tests/validation/NEON/Pooling3dLayer.cpp b/tests/validation/NEON/Pooling3dLayer.cpp index ae5ca466b3..07054462f5 100644 --- a/tests/validation/NEON/Pooling3dLayer.cpp +++ b/tests/validation/NEON/Pooling3dLayer.cpp @@ -55,12 +55,43 @@ const auto Pooling3dLayerDatasetFPSmall = combine(combine(combine(combine(datase framework::dataset::make("Padding", { Padding3D(0, 0, 0), Padding3D(1, 1, 1), Padding3D(1, 0, 0) })), framework::dataset::make("ExcludePadding", { true, false })); +const auto Pooling3dLayerDatasetQASYMM8Small = combine(combine(combine(combine(framework::dataset::make("PoolingType", { PoolingType::MAX, PoolingType::AVG }), + framework::dataset::make("PoolingSize", { Size3D(3, 3, 3) })), + framework::dataset::make("Stride", { Size3D(1, 1, 1), Size3D(2, 1, 1), Size3D(1, 2, 1), Size3D(2, 2, 1) })), + framework::dataset::make("Padding", { Padding3D(0, 0, 0), Padding3D(1, 1, 1), Padding3D(1, 0, 0) })), + framework::dataset::make("ExcludePadding", { true })); + +const auto Pooling3dLayerDatasetQASYMM8Large = combine(combine(combine(combine(framework::dataset::make("PoolingType", { PoolingType::MAX, PoolingType::AVG }), + framework::dataset::make("PoolingSize", { Size3D(3, 3, 3) })), + framework::dataset::make("Stride", { Size3D(1, 1, 1), Size3D(2, 2, 1) })), + framework::dataset::make("Padding", { Padding3D(0, 0, 0), Padding3D(1, 1, 0) })), + framework::dataset::make("ExcludePadding", { true })); + using ShapeDataset = framework::dataset::ContainerDataset<std::vector<TensorShape>>; constexpr AbsoluteTolerance<float> tolerance_f32(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for 32-bit floating-point type */ #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC -constexpr AbsoluteTolerance<float> tolerance_f16(0.01f); /**< Tolerance value for comparing reference's output against implementation's output for 16-bit floating-point type */ -#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */ +constexpr AbsoluteTolerance<float> tolerance_f16(0.01f); /**< Tolerance value for comparing reference's output against implementation's output for 16-bit floating-point type */ +#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */ +constexpr AbsoluteTolerance<uint8_t> tolerance_qasymm8(1); /**< Tolerance value for comparing reference's output against implementation's output for unsigned 8-bit asymmetric type */ +constexpr AbsoluteTolerance<int8_t> tolerance_qasymm8_s(1); /**< Tolerance value for comparing reference's output against implementation's output for signed 8-bit asymmetric type */ + +const auto qasymm8_in_qinfo_dataset = framework::dataset::make("InputQuantInfo", { QuantizationInfo(.2f, 10) }); +const auto qasymm8_out_qinfo_dataset = framework::dataset::make("OutputQuantInfo", +{ + QuantizationInfo(.2f, 10), // Same qinfo + QuantizationInfo(.1f, 5), // Multiplier <= 1 + QuantizationInfo(2.f, 3) // Multiplier > 1 +}); + +const auto qasymm8_signed_in_qinfo_dataset = framework::dataset::make("InputQuantInfo", { QuantizationInfo(.2f, -10) }); +const auto qasymm8_signed_out_qinfo_dataset = framework::dataset::make("OutputQuantInfo", +{ + QuantizationInfo(.2f, -10), // Same qinfo + QuantizationInfo(.1f, -5), // Multiplier <= 1 + QuantizationInfo(2.f, -3) // Multiplier > 1 +}); + } //namespace TEST_SUITE(NEON) @@ -280,8 +311,49 @@ FIXTURE_DATA_TEST_CASE(RunLarge, NEPoolingLayer3dFixture<half>, framework::Datas TEST_SUITE_END() // GlobalPooling TEST_SUITE_END() // FP16 #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */ - TEST_SUITE_END() // Float +TEST_SUITE(Quantized) + +template <typename T> +using NEPooling3dLayerQuantizedFixture = Pooling3dLayerValidationQuantizedFixture<Tensor, Accessor, NEPooling3dLayer, T>; + +TEST_SUITE(QASYMM8) +FIXTURE_DATA_TEST_CASE(RunSmall, NEPooling3dLayerQuantizedFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::Small5dShapes(), + combine(Pooling3dLayerDatasetQASYMM8Small, + framework::dataset::make("DataType", DataType::QASYMM8))), + qasymm8_in_qinfo_dataset), + qasymm8_out_qinfo_dataset)) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_qasymm8); +} + +FIXTURE_DATA_TEST_CASE(RunLarge, NEPooling3dLayerQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large5dShapes(), + combine(Pooling3dLayerDatasetQASYMM8Large, + framework::dataset::make("DataType", DataType::QASYMM8))), + qasymm8_in_qinfo_dataset), + qasymm8_out_qinfo_dataset)) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_qasymm8); +} + +TEST_SUITE_END() // QASYMM8 + +TEST_SUITE(QASYMM8_SIGNED) + +FIXTURE_DATA_TEST_CASE(RunSmall, NEPooling3dLayerQuantizedFixture<int8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::Small5dShapes(), + combine(Pooling3dLayerDatasetQASYMM8Small, + framework::dataset::make("DataType", DataType::QASYMM8_SIGNED))), + qasymm8_signed_in_qinfo_dataset), + qasymm8_signed_out_qinfo_dataset)) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_qasymm8_s); +} + +TEST_SUITE_END() // QASYMM8_SIGNED +TEST_SUITE_END() // Quantized TEST_SUITE_END() // Pooling3dLayer TEST_SUITE_END() // NEON } // namespace validation diff --git a/tests/validation/fixtures/Pooling3dLayerFixture.h b/tests/validation/fixtures/Pooling3dLayerFixture.h index c1b3519e80..563f1dcced 100644 --- a/tests/validation/fixtures/Pooling3dLayerFixture.h +++ b/tests/validation/fixtures/Pooling3dLayerFixture.h @@ -46,10 +46,10 @@ class Pooling3dLayerValidationGenericFixture : public framework::Fixture { public: template <typename...> - void setup(TensorShape shape, Pooling3dLayerInfo pool_info, DataType data_type) + void setup(TensorShape shape, Pooling3dLayerInfo pool_info, DataType data_type, QuantizationInfo input_qinfo = QuantizationInfo(), QuantizationInfo output_qinfo = QuantizationInfo()) { - _target = compute_target(shape, pool_info, data_type); - _reference = compute_reference(shape, pool_info, data_type); + _target = compute_target(shape, pool_info, data_type, input_qinfo, output_qinfo); + _reference = compute_reference(shape, pool_info, data_type, input_qinfo, output_qinfo); } protected: @@ -68,17 +68,17 @@ protected: } else // data type is quantized_asymmetric { - ARM_COMPUTE_ERROR("Passed Type Not Supported"); + library->fill_tensor_uniform(tensor, 0); } } TensorType compute_target(TensorShape shape, Pooling3dLayerInfo info, - DataType data_type) + DataType data_type, QuantizationInfo input_qinfo, QuantizationInfo output_qinfo) { // Create tensors - TensorType src = create_tensor<TensorType>(shape, data_type, 1, QuantizationInfo(), DataLayout::NDHWC); + TensorType src = create_tensor<TensorType>(shape, data_type, 1, input_qinfo, DataLayout::NDHWC); const TensorShape dst_shape = misc::shape_calculator::compute_pool3d_shape((src.info()->tensor_shape()), info); - TensorType dst = create_tensor<TensorType>(dst_shape, data_type, 1, QuantizationInfo(), DataLayout::NDHWC); + TensorType dst = create_tensor<TensorType>(dst_shape, data_type, 1, output_qinfo, DataLayout::NDHWC); // Create and configure function FunctionType pool_layer; @@ -103,17 +103,17 @@ protected: return dst; } - SimpleTensor<T> compute_reference(TensorShape shape, Pooling3dLayerInfo info, DataType data_type) + SimpleTensor<T> compute_reference(TensorShape shape, Pooling3dLayerInfo info, DataType data_type, QuantizationInfo input_qinfo, QuantizationInfo output_qinfo) { // Create reference - SimpleTensor<T> src(shape, data_type, 1, QuantizationInfo(), DataLayout::NDHWC); + SimpleTensor<T> src(shape, data_type, 1, input_qinfo, DataLayout::NDHWC); // Fill reference fill(src); - return reference::pooling_3d_layer<T>(src, info); + return reference::pooling_3d_layer<T>(src, info, output_qinfo); } - TensorType _target{}; - SimpleTensor<T> _reference{}; + TensorType _target{}; + SimpleTensor<T> _reference{}; }; template <typename TensorType, typename AccessorType, typename FunctionType, typename T> @@ -129,6 +129,19 @@ public: }; template <typename TensorType, typename AccessorType, typename FunctionType, typename T> +class Pooling3dLayerValidationQuantizedFixture : public Pooling3dLayerValidationGenericFixture<TensorType, AccessorType, FunctionType, T> +{ +public: + template <typename...> + void setup(TensorShape shape, PoolingType pool_type, Size3D pool_size, Size3D stride, Padding3D padding, bool exclude_padding, DataType data_type, + QuantizationInfo input_qinfo = QuantizationInfo(), QuantizationInfo output_qinfo = QuantizationInfo()) + { + Pooling3dLayerValidationGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(shape, Pooling3dLayerInfo(pool_type, pool_size, stride, padding, exclude_padding), + data_type, input_qinfo, output_qinfo); + } +}; + +template <typename TensorType, typename AccessorType, typename FunctionType, typename T> class Pooling3dLayerGlobalValidationFixture : public Pooling3dLayerValidationGenericFixture<TensorType, AccessorType, FunctionType, T> { public: |