From b5fdf38f0c6596958fab2b84882f2792a31e585a Mon Sep 17 00:00:00 2001 From: Mike Kelly Date: Tue, 11 Jun 2019 16:35:25 +0100 Subject: IVGCVSW-3181 Add HAL 1.2 support to android-nn-driver * Updated Android.mk to build HAL 1.2 driver * Added 1.2 HalPolicy and ArmnnDriver * Added 1.2 ArmnnPreparedModel * Updated converters and utilities to accept new HAL 1.2 operands and operand types. Signed-off-by: Sadik Armagan Signed-off-by: Mike Kelly Change-Id: I62856deab24e106f72cccce09468db4971756fa6 --- Utils.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) (limited to 'Utils.cpp') diff --git a/Utils.cpp b/Utils.cpp index f5599f7d..c3c6310b 100644 --- a/Utils.cpp +++ b/Utils.cpp @@ -63,7 +63,7 @@ void* GetMemoryFromPool(DataLocation location, const std::vector(operand.type); } armnn::TensorInfo ret(operand.dimensions.size(), operand.dimensions.data(), type); @@ -101,12 +101,56 @@ armnn::TensorInfo GetTensorInfoForOperand(const V1_0::Operand& operand) return ret; } +#ifdef ARMNN_ANDROID_NN_V1_2 // Using ::android::hardware::neuralnetworks::V1_2 + +armnn::TensorInfo GetTensorInfoForOperand(const V1_2::Operand& operand) +{ + armnn::DataType type; + + switch (operand.type) + { + case V1_2::OperandType::TENSOR_FLOAT32: + type = armnn::DataType::Float32; + break; + case V1_2::OperandType::TENSOR_QUANT8_ASYMM: + type = armnn::DataType::QuantisedAsymm8; + break; + case V1_2::OperandType::TENSOR_QUANT16_SYMM: + type = armnn::DataType::QuantisedSymm16; + break; + case V1_2::OperandType::TENSOR_INT32: + type = armnn::DataType::Signed32; + break; + default: + throw UnsupportedOperand(operand.type); + } + + armnn::TensorInfo ret(operand.dimensions.size(), operand.dimensions.data(), type); + + ret.SetQuantizationScale(operand.scale); + ret.SetQuantizationOffset(operand.zeroPoint); + + return ret; +} + +#endif + std::string GetOperandSummary(const V1_0::Operand& operand) { return android::hardware::details::arrayToString(operand.dimensions, operand.dimensions.size()) + " " + toString(operand.type); } +#ifdef ARMNN_ANDROID_NN_V1_2 // Using ::android::hardware::neuralnetworks::V1_2 + +std::string GetOperandSummary(const V1_2::Operand& operand) +{ + return android::hardware::details::arrayToString(operand.dimensions, operand.dimensions.size()) + " " + + toString(operand.type); +} + +#endif + using DumpElementFunction = void (*)(const armnn::ConstTensor& tensor, unsigned int elementIndex, std::ofstream& fileStream); -- cgit v1.2.1