From 997aba2dc6a0b5a8c3b424a31ae8370b395cf0d8 Mon Sep 17 00:00:00 2001 From: Pablo Tello Date: Wed, 28 Jun 2017 11:32:05 +0100 Subject: COMPMID-421: Fixed a problem in Convolution Layer reference values for FP16. All methods in std::numeric_limits return 0. Change-Id: I2289e01853e1b2c38afdec119ef6fc8af8a9752e Reviewed-on: http://mpd-gerrit.cambridge.arm.com/79312 Reviewed-by: Anthony Barbier Tested-by: Kaizen Reviewed-by: Moritz Pflanzer --- src/core/NEON/kernels/NEGEMMMatrixMultiplyKernel.cpp | 1 + tests/TensorLibrary.h | 2 +- tests/validation/NEON/ConvolutionLayer.cpp | 9 ++++++--- tests/validation/Reference.cpp | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/core/NEON/kernels/NEGEMMMatrixMultiplyKernel.cpp b/src/core/NEON/kernels/NEGEMMMatrixMultiplyKernel.cpp index dcfbb13081..1db025723c 100644 --- a/src/core/NEON/kernels/NEGEMMMatrixMultiplyKernel.cpp +++ b/src/core/NEON/kernels/NEGEMMMatrixMultiplyKernel.cpp @@ -639,6 +639,7 @@ template void matrix_matrix_multiply_f16(const ITensor *input0, const ITensor *input1, ITensor *output, const Window &window, float alpha) { #ifdef ARM_COMPUTE_ENABLE_FP16 + const size_t in_b_stride = input1->info()->strides_in_bytes()[1] / data_size_from_type(input1->info()->data_type()); const size_t out_stride = output->info()->strides_in_bytes()[1] / data_size_from_type(output->info()->data_type()); diff --git a/tests/TensorLibrary.h b/tests/TensorLibrary.h index b05302a9b0..4d7143a206 100644 --- a/tests/TensorLibrary.h +++ b/tests/TensorLibrary.h @@ -501,7 +501,7 @@ void TensorLibrary::fill_tensor_uniform(T &&tensor, std::random_device::result_t #if ARM_COMPUTE_ENABLE_FP16 case DataType::F16: { - std::uniform_real_distribution distribution_f16(std::numeric_limits::lowest(), std::numeric_limits::max()); + std::uniform_real_distribution distribution_f16(-1000.f, 1000.f); fill(tensor, distribution_f16, seed_offset); break; } diff --git a/tests/validation/NEON/ConvolutionLayer.cpp b/tests/validation/NEON/ConvolutionLayer.cpp index 40c1e2e969..d81834bd57 100644 --- a/tests/validation/NEON/ConvolutionLayer.cpp +++ b/tests/validation/NEON/ConvolutionLayer.cpp @@ -42,7 +42,10 @@ using namespace arm_compute::test::validation; namespace { const float tolerance_f32 = 1e-03f; /**< Tolerance value for comparing reference's output against implementation's output for DataType::F32 */ -const float tolerance_qs8 = 3.0f; /**< Tolerance value for comparing reference's output against implementation's output for DataType::QS8 */ +#ifdef ARM_COMPUTE_ENABLE_FP16 +const float tolerance_f16 = 0.01f; /**< Tolerance value for comparing reference's output against implementation's output for DataType::F16 */ +#endif +const float tolerance_qs8 = 3.0f; /**< Tolerance value for comparing reference's output against implementation's output for DataType::QS8 */ Tensor compute_convolution_layer(const TensorShape &input_shape, const TensorShape &weights_shape, const TensorShape &bias_shape, const TensorShape &output_shape, DataType dt, const PadStrideInfo &conv_info, int fixed_point_position) @@ -69,7 +72,7 @@ Tensor compute_convolution_layer(const TensorShape &input_shape, const TensorSha BOOST_TEST(!dst.info()->is_resizable()); // Fill tensors - if(dt == DataType::F32) + if(dt == DataType::F16 || dt == DataType::F32) { std::uniform_real_distribution<> distribution(-1.0f, 1.0f); library->fill(NEAccessor(src), distribution, 0); @@ -144,7 +147,7 @@ BOOST_DATA_TEST_CASE(SmallConvolutionLayer, RawTensor ref_dst = Reference::compute_reference_convolution_layer(conv_set.src_shape, conv_set.weights_shape, conv_set.bias_shape, conv_set.dst_shape, dt, conv_set.info, 0); // Validate output - validate(NEAccessor(dst), ref_dst, tolerance_f32); + validate(NEAccessor(dst), ref_dst, tolerance_f16); } BOOST_AUTO_TEST_SUITE_END() #endif diff --git a/tests/validation/Reference.cpp b/tests/validation/Reference.cpp index 2388fb6fe3..0518819173 100644 --- a/tests/validation/Reference.cpp +++ b/tests/validation/Reference.cpp @@ -506,7 +506,7 @@ RawTensor Reference::compute_reference_convolution_layer(const TensorShape &inpu RawTensor ref_dst = library->get(output_shape, dt, 1, fixed_point_position); // Fill reference - if(dt == DataType::F32) + if(dt == DataType::F16 || dt == DataType::F32) { std::uniform_real_distribution<> distribution(-1.0f, 1.0f); library->fill(ref_src, distribution, 0); -- cgit v1.2.1