aboutsummaryrefslogtreecommitdiff
path: root/src/armnnUtils
diff options
context:
space:
mode:
Diffstat (limited to 'src/armnnUtils')
-rw-r--r--src/armnnUtils/TensorUtils.cpp29
-rw-r--r--src/armnnUtils/TensorUtils.hpp28
2 files changed, 31 insertions, 26 deletions
diff --git a/src/armnnUtils/TensorUtils.cpp b/src/armnnUtils/TensorUtils.cpp
index 0dbb75c33a..630490ff14 100644
--- a/src/armnnUtils/TensorUtils.cpp
+++ b/src/armnnUtils/TensorUtils.cpp
@@ -138,4 +138,33 @@ unsigned int GetUnsignedAxis(const unsigned int inputDimension, const int axis)
return uAxis;
}
+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;
+}
+
+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(
+ std::string("Per-axis quantization params not set for tensor of type ") +
+ armnn::GetDataTypeName(info.GetDataType()), CHECK_LOCATION());
+ }
+ unsigned int axisFactor = GetNumElementsAfter(info.GetShape(), quantizationDim.value());
+
+ return { axisFactor, scales };
+}
+
+
} // namespace armnnUtils
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