From 45bcc3a1c287a208098ae99288273a5129ddd5eb Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Wed, 29 Nov 2017 11:06:49 +0000 Subject: 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 Tested-by: BSG Visual Compute Jenkins server to access repositories on http://mpd-gerrit.cambridge.arm.com Reviewed-by: Anthony Barbier --- tests/validation/CL/FullyConnectedLayer.cpp | 43 +++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 6 deletions(-) (limited to 'tests/validation/CL/FullyConnectedLayer.cpp') 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 tolerance_fixed_point(1.f); +/** Tolerance for quantized asymmetric operations */ +constexpr AbsoluteTolerance 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(src_shape, data_type, 1, fixed_point_position); - CLTensor weights = create_tensor(ws, data_type, 1, fixed_point_position); - CLTensor bias = create_tensor(bias_shape, data_type, 1, fixed_point_position); - CLTensor dst = create_tensor(dst_shape, data_type, 1, fixed_point_position); + CLTensor src = create_tensor(src_shape, data_type, 1, fixed_point_position, quantization_info); + CLTensor weights = create_tensor(ws, data_type, 1, fixed_point_position, quantization_info); + CLTensor bias = create_tensor(bias_shape, bias_data_type, 1, fixed_point_position, quantization_info); + CLTensor dst = create_tensor(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 using CLFullyConnectedLayerFixedPointFixture = FullyConnectedLayerValidationFixedPointFixture; -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, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallFullyConnectedLayerDataset(), @@ -189,6 +194,32 @@ FIXTURE_DATA_TEST_CASE(RunLarge, CLFullyConnectedLayerFixedPointFixture TEST_SUITE_END() TEST_SUITE_END() +template +using CLFullyConnectedLayerQuantizedFixture = FullyConnectedLayerValidationQuantizedFixture; + +TEST_SUITE(Quantized) +TEST_SUITE(QASYMM8) +FIXTURE_DATA_TEST_CASE(RunSmall, CLFullyConnectedLayerQuantizedFixture, 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, 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 -- cgit v1.2.1