diff options
author | Finn Williams <Finn.Williams@arm.com> | 2019-12-06 09:55:55 +0000 |
---|---|---|
committer | Finn Williams <Finn.Williams@arm.com> | 2019-12-10 12:55:18 +0000 |
commit | ed66d14ec0840282f74241dda46e02194278c3cc (patch) | |
tree | b960d3a61e5251bf6a515be8bae4974e1a84bced /src/armnnTfLiteParser/TfLiteParser.cpp | |
parent | 836b27bd73d62795e82d0ce666d728c94c216067 (diff) | |
download | armnn-ed66d14ec0840282f74241dda46e02194278c3cc.tar.gz |
IVGCVSW-4191 Add DEQUANTIZE to the TfLite Parser
!armnn:2421
Change-Id: Icdb02b7248ed408c3c8ad2e3e38df5b7cda1c545
Signed-off-by: Finn Williams <Finn.Williams@arm.com>
Diffstat (limited to 'src/armnnTfLiteParser/TfLiteParser.cpp')
-rw-r--r-- | src/armnnTfLiteParser/TfLiteParser.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/armnnTfLiteParser/TfLiteParser.cpp b/src/armnnTfLiteParser/TfLiteParser.cpp index f06e244223..6853512c8f 100644 --- a/src/armnnTfLiteParser/TfLiteParser.cpp +++ b/src/armnnTfLiteParser/TfLiteParser.cpp @@ -314,6 +314,12 @@ armnn::TensorInfo ToTensorInfo(TfLiteParser::TensorRawPtr tensorPtr, const std:: case tflite::TensorType_FLOAT32: type = armnn::DataType::Float32; break; + case tflite::TensorType_INT8: + type = armnn::DataType::QSymmS8; + break; + case tflite::TensorType_INT16: + type = armnn::DataType::QuantisedSymm16; + break; case tflite::TensorType_INT32: type = armnn::DataType::Signed32; break; @@ -440,6 +446,7 @@ TfLiteParser::TfLiteParser(const Optional<ITfLiteParser::TfLiteParserOptions>& o m_ParserFunctions[tflite::BuiltinOperator_CONCATENATION] = &TfLiteParser::ParseConcatenation; m_ParserFunctions[tflite::BuiltinOperator_CONV_2D] = &TfLiteParser::ParseConv2D; m_ParserFunctions[tflite::BuiltinOperator_DEPTHWISE_CONV_2D] = &TfLiteParser::ParseDepthwiseConv2D; + m_ParserFunctions[tflite::BuiltinOperator_DEQUANTIZE] = &TfLiteParser::ParseDequantize; m_ParserFunctions[tflite::BuiltinOperator_CUSTOM] = &TfLiteParser::ParseCustomOperator; m_ParserFunctions[tflite::BuiltinOperator_FULLY_CONNECTED] = &TfLiteParser::ParseFullyConnected; m_ParserFunctions[tflite::BuiltinOperator_LOGISTIC] = &TfLiteParser::ParseLogistic; @@ -923,6 +930,31 @@ void TfLiteParser::ParseDepthwiseConv2D(size_t subgraphIndex, size_t operatorInd RegisterOutputSlots(subgraphIndex, operatorIndex, layer, {outputTensorIndexes[0]}); } +void TfLiteParser::ParseDequantize(size_t subgraphIndex, size_t operatorIndex) +{ + CHECK_MODEL(m_Model, subgraphIndex, operatorIndex); + + auto inputs = GetInputs(m_Model, subgraphIndex, operatorIndex); + CHECK_VALID_SIZE(inputs.size(), 1); + + auto outputs = GetOutputs(m_Model, subgraphIndex, operatorIndex); + CHECK_VALID_SIZE(outputs.size(), 1); + + auto layerName = boost::str(boost::format("Dequantize:%1%:%2%") % subgraphIndex % operatorIndex); + + IConnectableLayer* layer = m_Network->AddDequantizeLayer(layerName.c_str()); + BOOST_ASSERT(layer != nullptr); + + TensorInfo outputTensorInfo = ToTensorInfo(outputs[0]); + layer->GetOutputSlot(0).SetTensorInfo(outputTensorInfo); + + auto inputTensorIndexes = AsUnsignedVector(GetInputTensorIds(m_Model, subgraphIndex, operatorIndex)); + RegisterInputSlots(subgraphIndex, operatorIndex, layer, {inputTensorIndexes[0]}); + + auto outputTensorIndexes = AsUnsignedVector(GetOutputTensorIds(m_Model, subgraphIndex, operatorIndex)); + RegisterOutputSlots(subgraphIndex, operatorIndex, layer, outputTensorIndexes); +} + void TfLiteParser::ParseTranspose(size_t subgraphIndex, size_t operatorIndex) { CHECK_MODEL(m_Model, subgraphIndex, operatorIndex); |