diff options
author | mathad01 <matthew.haddon@arm.com> | 2021-04-28 11:42:57 +0100 |
---|---|---|
committer | matthew.haddon <matthew.haddon@arm.com> | 2021-05-05 08:43:20 +0000 |
commit | df9a32264780f0d478c0a5ad735296368a5b9edf (patch) | |
tree | 5a13b74a8b22c9e0a41c42fd96e75a85afa9a0ef /src/backends/backendsCommon | |
parent | e4a41dc5d5fc0f283c01b3260affdfdf6cfc1895 (diff) | |
download | armnn-df9a32264780f0d478c0a5ad735296368a5b9edf.tar.gz |
IVGCVSW-5882 Produce warning if bias quantization scale mismatch
* Changed behaviour of bias scale tolerance check such that if
input quant * weight quant != bias quant +/- tolerance
Then instead of throwing an error we send a warning.
* Updated tests to reflect changes
Signed-off-by: mathad01 <matthew.haddon@arm.com>
Change-Id: Ifd97c574fe13805660df4636e9616b2d786b490d
Diffstat (limited to 'src/backends/backendsCommon')
-rw-r--r-- | src/backends/backendsCommon/WorkloadData.cpp | 13 | ||||
-rw-r--r-- | src/backends/backendsCommon/test/WorkloadDataValidation.cpp | 2 |
2 files changed, 7 insertions, 8 deletions
diff --git a/src/backends/backendsCommon/WorkloadData.cpp b/src/backends/backendsCommon/WorkloadData.cpp index 100d23ee39..470d460ef3 100644 --- a/src/backends/backendsCommon/WorkloadData.cpp +++ b/src/backends/backendsCommon/WorkloadData.cpp @@ -8,6 +8,7 @@ #include <armnnUtils/DataLayoutIndexed.hpp> #include <armnnUtils/TensorUtils.hpp> #include <armnn/utility/NumericCast.hpp> +#include <armnn/Logging.hpp> #include <algorithm> #include <iomanip> @@ -212,15 +213,13 @@ void ValidateBiasTensorQuantization(const TensorInfo& biasTensor, // Helper lambda function to validate a single bias quantization scale value auto VerifyBiasQuantizationScale = [&descName](float biasScale, float expectedScale) -> void { - constexpr float tolerance = 0.000001f; + constexpr float tolerance = 0.0001f; if (std::abs(biasScale - expectedScale) > tolerance) { // Print the float values with extra precision to see very small differences - std::stringstream msg; - msg << std::setprecision(10) << descName << ": Expected " << expectedScale << - " quantization scale for bias tensor (the product of the input and weight scales), but got " << - biasScale; - throw InvalidArgumentException(msg.str(), CHECK_LOCATION()); + ARMNN_LOG(warning) << std::setprecision(6) << descName << ": Expected " << expectedScale << + " for bias quantization scale (product of input and weight scales), but got " << + biasScale << ". Using scale provided."; } }; @@ -3707,4 +3706,4 @@ void ReduceQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const ValidateTensorDataTypesMatch(inputTensorInfo, outputTensorInfo, descriptorName, "input", "output"); } -} // namespace armnn +} // namespace armnn
\ No newline at end of file diff --git a/src/backends/backendsCommon/test/WorkloadDataValidation.cpp b/src/backends/backendsCommon/test/WorkloadDataValidation.cpp index 2eb4a06f29..5ac548f42a 100644 --- a/src/backends/backendsCommon/test/WorkloadDataValidation.cpp +++ b/src/backends/backendsCommon/test/WorkloadDataValidation.cpp @@ -676,7 +676,7 @@ BOOST_AUTO_TEST_CASE(BiasPerAxisQuantization_Validate) ScopedCpuTensorHandle biasHandle2(biasInfo2); queueDescriptor.m_Bias = &biasHandle2; - BOOST_CHECK_THROW(queueDescriptor.Validate(workloadInfo), InvalidArgumentException); + BOOST_CHECK_NO_THROW(queueDescriptor.Validate(workloadInfo)); // Test 3: mismatched number of quantization scales const std::vector<float> biasPerAxisScales3 = { 3.75f, 5.25f, 5.25f }; |