From 44bcc02a40e2e4fdfab6eb4ff91a2547ed0d98a0 Mon Sep 17 00:00:00 2001 From: Sadik Armagan Date: Tue, 18 Jun 2019 17:21:36 +0100 Subject: IVGCVSW-3136 Run VTS tests with 1.2 Driver * Updated android-nn-driver to run VTS tests with 1.2 Driver Change-Id: I99a73b1e32dcf5bc655d88c2dbe0e610e245ea15 Signed-off-by: Sadik Armagan --- ConversionUtils.hpp | 88 ++++++++++++++++++++++++-------------------- ModelToINetworkConverter.cpp | 14 +++---- 2 files changed, 56 insertions(+), 46 deletions(-) diff --git a/ConversionUtils.hpp b/ConversionUtils.hpp index 8b63f780..03f46696 100644 --- a/ConversionUtils.hpp +++ b/ConversionUtils.hpp @@ -900,6 +900,7 @@ LayerInputHandle ConvertToLayerInputHandle(const HalOperation& operation, ConversionData& data) { using HalOperand = typename HalPolicy::Operand; + using HalOperandType = typename HalPolicy::OperandType; using HalOperandLifeTime = typename HalPolicy::OperandLifeTime; const HalOperand* operand = GetInputOperand(operation, inputIndex, model); @@ -915,58 +916,67 @@ LayerInputHandle ConvertToLayerInputHandle(const HalOperation& operation, return LayerInputHandle(); } - armnn::TensorInfo operandTensorInfo = GetTensorInfoForOperand(*operand); - - switch (operand->lifetime) + try { - case HalOperandLifeTime::TEMPORARY_VARIABLE: // intentional fallthrough - case HalOperandLifeTime::MODEL_INPUT: - case HalOperandLifeTime::MODEL_OUTPUT: - { - // The tensor is either an operand internal to the model, or a model input. - // It can be associated with an ArmNN output slot for an existing layer. + armnn::TensorInfo operandTensorInfo = GetTensorInfoForOperand(*operand); - // m_OutputSlotForOperand[...] can be nullptr if the previous layer could not be converted - const uint32_t operandIndex = operation.inputs[inputIndex]; - return LayerInputHandle(true, data.m_OutputSlotForOperand[operandIndex], operandTensorInfo); - break; - } - case HalOperandLifeTime::CONSTANT_COPY: - case HalOperandLifeTime::CONSTANT_REFERENCE: + switch (operand->lifetime) { - // The tensor has an already known constant value, and can be converted into an ArmNN Constant layer. - ConstTensorPin tensorPin = ConvertOperandToConstTensorPin(*operand, model, data); - if (tensorPin.IsValid()) + case HalOperandLifeTime::TEMPORARY_VARIABLE: // intentional fallthrough + case HalOperandLifeTime::MODEL_INPUT: + case HalOperandLifeTime::MODEL_OUTPUT: { - if (!IsLayerSupportedForAnyBackend(__func__, - armnn::IsConstantSupported, - data.m_Backends, - tensorPin.GetConstTensor().GetInfo())) + // The tensor is either an operand internal to the model, or a model input. + // It can be associated with an ArmNN output slot for an existing layer. + + // m_OutputSlotForOperand[...] can be nullptr if the previous layer could not be converted + const uint32_t operandIndex = operation.inputs[inputIndex]; + return LayerInputHandle(true, data.m_OutputSlotForOperand[operandIndex], operandTensorInfo); + break; + } + case HalOperandLifeTime::CONSTANT_COPY: + case HalOperandLifeTime::CONSTANT_REFERENCE: + { + // The tensor has an already known constant value, and can be converted into an ArmNN Constant layer. + ConstTensorPin tensorPin = ConvertOperandToConstTensorPin(*operand, model, data); + if (tensorPin.IsValid()) + { + if (!IsLayerSupportedForAnyBackend(__func__, + armnn::IsConstantSupported, + data.m_Backends, + tensorPin.GetConstTensor().GetInfo())) + { + return LayerInputHandle(); + } + + armnn::IConnectableLayer* constantLayer = + data.m_Network->AddConstantLayer(tensorPin.GetConstTensor()); + armnn::IOutputSlot& outputSlot = constantLayer->GetOutputSlot(0); + outputSlot.SetTensorInfo(tensorPin.GetConstTensor().GetInfo()); + + return LayerInputHandle(true, &outputSlot, operandTensorInfo); + } + else { + Fail("%s: invalid operand tensor", __func__); return LayerInputHandle(); } - - armnn::IConnectableLayer* constantLayer = data.m_Network->AddConstantLayer(tensorPin.GetConstTensor()); - armnn::IOutputSlot& outputSlot = constantLayer->GetOutputSlot(0); - outputSlot.SetTensorInfo(tensorPin.GetConstTensor().GetInfo()); - - return LayerInputHandle(true, &outputSlot, operandTensorInfo); + break; } - else + default: { - Fail("%s: invalid operand tensor", __func__); + // Unsupported lifetime for an input tensor + Fail("%s: unsupported lifetime for input tensor: %s", + __func__, toString(operand->lifetime).c_str()); return LayerInputHandle(); } - break; - } - default: - { - // Unsupported lifetime for an input tensor - Fail("%s: unsupported lifetime for input tensor: %s", - __func__, toString(operand->lifetime).c_str()); - return LayerInputHandle(); } } + catch (UnsupportedOperand& e) + { + Fail("%s: Operand type %s not supported in ArmnnDriver", __func__, toString(e.m_type).c_str()); + return LayerInputHandle(); + } } template::ModelToINetworkConverter(const std::vector< template void ModelToINetworkConverter::Convert() { - using HalModel = typename HalPolicy::Model; - using Operand = typename HalPolicy::Operand; - using OperandType = typename HalPolicy::OperationType; + using HalModel = typename HalPolicy::Model; + using HalOperand = typename HalPolicy::Operand; + using HalOperandType = typename HalPolicy::OperandType; ALOGV("ModelToINetworkConverter::Convert(): %s", GetModelSummary(m_Model).c_str()); @@ -70,7 +70,7 @@ void ModelToINetworkConverter::Convert() { // inputs in android nn are represented by operands uint32_t inputIndex = m_Model.inputIndexes[i]; - const Operand& operand = m_Model.operands[inputIndex]; + const HalOperand& operand = m_Model.operands[inputIndex]; const armnn::TensorInfo& tensor = GetTensorInfoForOperand(operand); armnn::IConnectableLayer* layer = m_Data.m_Network->AddInputLayer(i); @@ -81,7 +81,7 @@ void ModelToINetworkConverter::Convert() m_Data.m_OutputSlotForOperand[inputIndex] = &outputSlot; } } - catch (UnsupportedOperand& e) + catch (UnsupportedOperand& e) { Fail("%s: Operand type %s not supported in ArmnnDriver", __func__, toString(e.m_type).c_str()); m_ConversionResult = ConversionResult::UnsupportedFeature; @@ -109,7 +109,7 @@ void ModelToINetworkConverter::Convert() { ok = HalPolicy::ConvertOperation(operation, m_Model, m_Data); } - catch (UnsupportedOperand& e) + catch (UnsupportedOperand& e) { Fail("%s: Operand type %s not supported in ArmnnDriver", __func__, toString(e.m_type).c_str()); ok = false; @@ -139,7 +139,7 @@ void ModelToINetworkConverter::Convert() { // outputs in android nn are represented by operands uint32_t outputIndex = m_Model.outputIndexes[i]; - const Operand& operand = m_Model.operands[outputIndex]; + const HalOperand& operand = m_Model.operands[outputIndex]; const armnn::TensorInfo& tensor = GetTensorInfoForOperand(operand); armnn::IConnectableLayer* layer = m_Data.m_Network->AddOutputLayer(i); -- cgit v1.2.1