diff options
Diffstat (limited to 'src/backends/aclCommon')
-rw-r--r-- | src/backends/aclCommon/ArmComputeTensorUtils.cpp | 27 | ||||
-rw-r--r-- | src/backends/aclCommon/ArmComputeTensorUtils.hpp | 4 |
2 files changed, 31 insertions, 0 deletions
diff --git a/src/backends/aclCommon/ArmComputeTensorUtils.cpp b/src/backends/aclCommon/ArmComputeTensorUtils.cpp index e4fdb21ecc..328a083ae9 100644 --- a/src/backends/aclCommon/ArmComputeTensorUtils.cpp +++ b/src/backends/aclCommon/ArmComputeTensorUtils.cpp @@ -232,5 +232,32 @@ arm_compute::PixelValue GetPixelValue(arm_compute::ITensor& input, float pixelVa } } +bool IsQuantMultiplierSupported(const TensorInfo& input, + const TensorInfo& output, + const TensorInfo& weights) +{ + constexpr float maxQuantMultiplier = 1.0f; + if (weights.HasMultipleQuantizationScales()) + { + for (float weightScale : weights.GetQuantizationScales()) + { + if ((input.GetQuantizationScale() * weightScale) / output.GetQuantizationScale() > maxQuantMultiplier) + { + return false; + } + } + } + else + { + if ((input.GetQuantizationScale() * weights.GetQuantizationScale()) / + output.GetQuantizationScale() > maxQuantMultiplier) + { + return false; + } + } + + return true; +} + } // namespace armcomputetensorutils } // namespace armnn diff --git a/src/backends/aclCommon/ArmComputeTensorUtils.hpp b/src/backends/aclCommon/ArmComputeTensorUtils.hpp index ef837d84d8..3fc6818b0d 100644 --- a/src/backends/aclCommon/ArmComputeTensorUtils.hpp +++ b/src/backends/aclCommon/ArmComputeTensorUtils.hpp @@ -243,5 +243,9 @@ inline TensorShape GetShape(const arm_compute::TensorShape& shape) return GetTensorShape(shape, 1U); } +bool IsQuantMultiplierSupported(const TensorInfo& input, + const TensorInfo& output, + const TensorInfo& weights); + } // namespace armcomputetensorutils } // namespace armnn |