From fc884b4141a28fbd3c62f665341ec88158fcd332 Mon Sep 17 00:00:00 2001 From: Finn Williams Date: Thu, 11 Jun 2020 17:35:44 +0100 Subject: Add support for Rank and scalar tensors !armnn:3330 Signed-off-by: Finn Williams Change-Id: Icc429d9fabb570193d12bffef0e00dda7b51032f --- Utils.hpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'Utils.hpp') diff --git a/Utils.hpp b/Utils.hpp index b61ddb21..d58d2735 100644 --- a/Utils.hpp +++ b/Utils.hpp @@ -150,18 +150,24 @@ inline V1_2::OutputShape ComputeShape(const armnn::TensorInfo& info) { V1_2::OutputShape shape; - android::hardware::hidl_vec dimensions; - armnn::TensorShape tensorShape = info.GetShape(); - const unsigned int numDims = tensorShape.GetNumDimensions(); - dimensions.resize(numDims); - - for (unsigned int outputIdx = 0u; outputIdx < numDims; ++outputIdx) + // Android will expect scalars as a zero dimensional tensor + if(tensorShape.GetDimensionality() == armnn::Dimensionality::Scalar) + { + shape.dimensions = android::hardware::hidl_vec{}; + } + else { - dimensions[outputIdx] = tensorShape[outputIdx]; + android::hardware::hidl_vec dimensions; + const unsigned int numDims = tensorShape.GetNumDimensions(); + dimensions.resize(numDims); + for (unsigned int outputIdx = 0u; outputIdx < numDims; ++outputIdx) + { + dimensions[outputIdx] = tensorShape[outputIdx]; + } + shape.dimensions = dimensions; } - shape.dimensions = dimensions; shape.isSufficient = true; return shape; -- cgit v1.2.1