diff options
author | Aron Virginas-Tar <Aron.Virginas-Tar@arm.com> | 2019-11-04 15:00:19 +0000 |
---|---|---|
committer | Áron Virginás-Tar <aron.virginas-tar@arm.com> | 2019-11-05 12:36:31 +0000 |
commit | b67f95796b03c1a5d3b3fa6a40f6baf85bdd09cb (patch) | |
tree | d96468d22624886f9495dbaf8b381f232d347b8b /src/armnnUtils/TensorUtils.hpp | |
parent | 13b653fd246b31279ae6cb42261671462b52d1be (diff) | |
download | armnn-b67f95796b03c1a5d3b3fa6a40f6baf85bdd09cb.tar.gz |
IVGCVSW-3836 Add support for Int32 per-axis scales
* Added ScaledInt32PerAxisDecoder implementation
* Added new case for Signed32 in MakeDecoder that returns a
ScaledInt32PerAxisDecoder if the tensor info has multiple
quantization scales
Signed-off-by: Aron Virginas-Tar <Aron.Virginas-Tar@arm.com>
Change-Id: I8b3c11091644da993044d2a0fe2aba6b06b5af56
Diffstat (limited to 'src/armnnUtils/TensorUtils.hpp')
-rw-r--r-- | src/armnnUtils/TensorUtils.hpp | 28 |
1 files changed, 2 insertions, 26 deletions
diff --git a/src/armnnUtils/TensorUtils.hpp b/src/armnnUtils/TensorUtils.hpp index 32af179bdc..b67431d757 100644 --- a/src/armnnUtils/TensorUtils.hpp +++ b/src/armnnUtils/TensorUtils.hpp @@ -34,32 +34,8 @@ unsigned int GetNumElementsBetween(const armnn::TensorShape& shape, unsigned int GetUnsignedAxis(const unsigned int inputDimension, const int axis); -inline unsigned int GetNumElementsAfter(const armnn::TensorShape& shape, - unsigned int axis) -{ - unsigned int numDim = shape.GetNumDimensions(); - BOOST_ASSERT(0 >= axis); - BOOST_ASSERT(axis < numDim - 1); - unsigned int count = 1; - for (unsigned int i = axis; i < numDim; i++) - { - count *= shape[i]; - } - return count; -} - -inline std::pair<unsigned int, std::vector<float>> GetPerAxisParams(const armnn::TensorInfo& info) -{ - const std::vector<float>& scales = info.GetQuantizationScales(); - armnn::Optional<unsigned int> quantizationDim = info.GetQuantizationDim(); - if (scales.size() < 1 || !quantizationDim.has_value()) - { - throw armnn::InvalidArgumentException( - "We currently support only per-axis symmetric quantization for QuantizedSymm8."); - } - unsigned int axisFactor = GetNumElementsAfter(info.GetShape(), quantizationDim.value()); +unsigned int GetNumElementsAfter(const armnn::TensorShape& shape, unsigned int axis); - return {axisFactor, scales}; -} +std::pair<unsigned int, std::vector<float>> GetPerAxisParams(const armnn::TensorInfo& info); } // namespace armnnUtils |