diff options
author | Georgios Pinitas <georgios.pinitas@arm.com> | 2017-11-29 11:06:49 +0000 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:41:58 +0000 |
commit | 45bcc3a1c287a208098ae99288273a5129ddd5eb (patch) | |
tree | f4f957dbc76f8e8e9a4871b16652e1033bcd4c73 /tests/validation/CL/FullyConnectedLayer.cpp | |
parent | 303be90ee1f03f75309b421297ba16428ea98ea5 (diff) | |
download | ComputeLibrary-45bcc3a1c287a208098ae99288273a5129ddd5eb.tar.gz |
COMPMID-661: QASYMM8 support for fully connected layer.
Change-Id: I70e04d3a175ba366432ada98e9ca893c9f81b260
Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/111094
Reviewed-by: Gian Marco Iodice <gianmarco.iodice@arm.com>
Tested-by: BSG Visual Compute Jenkins server to access repositories on http://mpd-gerrit.cambridge.arm.com <bsgcomp@arm.com>
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Diffstat (limited to 'tests/validation/CL/FullyConnectedLayer.cpp')
-rw-r--r-- | tests/validation/CL/FullyConnectedLayer.cpp | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/tests/validation/CL/FullyConnectedLayer.cpp b/tests/validation/CL/FullyConnectedLayer.cpp index 35b9d2938b..e53f5fd407 100644 --- a/tests/validation/CL/FullyConnectedLayer.cpp +++ b/tests/validation/CL/FullyConnectedLayer.cpp @@ -49,6 +49,8 @@ constexpr float tolerance_num = 0.07f; /**< Tolerance number /** Tolerance for fixed point operations */ constexpr AbsoluteTolerance<float> tolerance_fixed_point(1.f); +/** Tolerance for quantized asymmetric operations */ +constexpr AbsoluteTolerance<uint8_t> tolerance_qasymm8(1); /** CNN data types */ const auto CNNDataTypes = framework::dataset::make("DataType", @@ -57,6 +59,7 @@ const auto CNNDataTypes = framework::dataset::make("DataType", DataType::F32, DataType::QS8, DataType::QS16, + DataType::QASYMM8, }); const auto FullyConnectedParameters = combine(framework::dataset::make("TransposeWeights", { false, true }), framework::dataset::make("ReshapeWeights", { false, true })); @@ -71,7 +74,9 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(frame src_shape, weights_shape, bias_shape, dst_shape, transpose_weights, reshape_weights, data_type) { // Set fixed point position data type allowed - int fixed_point_position = is_data_type_fixed_point(data_type) ? 3 : 0; + const int fixed_point_position = is_data_type_fixed_point(data_type) ? 3 : 0; + const DataType bias_data_type = is_data_type_quantized_asymmetric(data_type) ? DataType::S32 : data_type; + const QuantizationInfo quantization_info = is_data_type_quantized_asymmetric(data_type) ? QuantizationInfo(2.f / 255.f, 127) : QuantizationInfo(); TensorShape ws(weights_shape); @@ -84,10 +89,10 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(frame } // Create tensors - CLTensor src = create_tensor<CLTensor>(src_shape, data_type, 1, fixed_point_position); - CLTensor weights = create_tensor<CLTensor>(ws, data_type, 1, fixed_point_position); - CLTensor bias = create_tensor<CLTensor>(bias_shape, data_type, 1, fixed_point_position); - CLTensor dst = create_tensor<CLTensor>(dst_shape, data_type, 1, fixed_point_position); + CLTensor src = create_tensor<CLTensor>(src_shape, data_type, 1, fixed_point_position, quantization_info); + CLTensor weights = create_tensor<CLTensor>(ws, data_type, 1, fixed_point_position, quantization_info); + CLTensor bias = create_tensor<CLTensor>(bias_shape, bias_data_type, 1, fixed_point_position, quantization_info); + CLTensor dst = create_tensor<CLTensor>(dst_shape, data_type, 1, fixed_point_position, quantization_info); ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); ARM_COMPUTE_EXPECT(weights.info()->is_resizable(), framework::LogLevel::ERRORS); @@ -143,7 +148,7 @@ TEST_SUITE_END() template <typename T> using CLFullyConnectedLayerFixedPointFixture = FullyConnectedLayerValidationFixedPointFixture<CLTensor, CLAccessor, CLFullyConnectedLayer, T, false>; -TEST_SUITE(Quantized) +TEST_SUITE(FixedPoint) TEST_SUITE(QS8) // Testing for fixed point position [1,6) as reciprocal limits the maximum fixed point position to 5 FIXTURE_DATA_TEST_CASE(RunSmall, CLFullyConnectedLayerFixedPointFixture<int8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallFullyConnectedLayerDataset(), @@ -189,6 +194,32 @@ FIXTURE_DATA_TEST_CASE(RunLarge, CLFullyConnectedLayerFixedPointFixture<int16_t> TEST_SUITE_END() TEST_SUITE_END() +template <typename T> +using CLFullyConnectedLayerQuantizedFixture = FullyConnectedLayerValidationQuantizedFixture<CLTensor, CLAccessor, CLFullyConnectedLayer, T, false>; + +TEST_SUITE(Quantized) +TEST_SUITE(QASYMM8) +FIXTURE_DATA_TEST_CASE(RunSmall, CLFullyConnectedLayerQuantizedFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine( + combine(datasets::SmallFullyConnectedLayerDataset(), + FullyConnectedParameters), + framework::dataset::make("DataType", DataType::QASYMM8)), + framework::dataset::make("QuantizationInfo", { QuantizationInfo(1.f / 255.f, 10) }))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_qasymm8); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLFullyConnectedLayerQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine( + combine(datasets::LargeFullyConnectedLayerDataset(), + FullyConnectedParameters), + framework::dataset::make("DataType", DataType::QASYMM8)), + framework::dataset::make("QuantizationInfo", { QuantizationInfo(1.f / 256.f, 10) }))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_qasymm8); +} +TEST_SUITE_END() +TEST_SUITE_END() + TEST_SUITE_END() TEST_SUITE_END() } // namespace validation |