aboutsummaryrefslogtreecommitdiff
path: root/src/armnnTfLiteParser/TfLiteParser.cpp
diff options
context:
space:
mode:
authorBruno Goncalves <bruno.slackware@gmail.com>2018-12-19 12:52:01 -0200
committerBruno Goncalves <bruno.slackware@gmail.com>2019-01-21 18:36:18 -0200
commit6c2355b1f7dd722eb908dd505826df8df6756471 (patch)
tree520f8bacda2223dc4ff272405d1390aeefff89bd /src/armnnTfLiteParser/TfLiteParser.cpp
parent2235ceea7b94fd8ae3933ff75ba6428fa697c6b9 (diff)
downloadarmnn-6c2355b1f7dd722eb908dd505826df8df6756471.tar.gz
Added ParsePad method to TfLiteParser
Change-Id: I2e671f66cf1b0a24b4ca9e96b554dc7db3af9655
Diffstat (limited to 'src/armnnTfLiteParser/TfLiteParser.cpp')
-rw-r--r--src/armnnTfLiteParser/TfLiteParser.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/armnnTfLiteParser/TfLiteParser.cpp b/src/armnnTfLiteParser/TfLiteParser.cpp
index e3306b317f..0e8d3c5b68 100644
--- a/src/armnnTfLiteParser/TfLiteParser.cpp
+++ b/src/armnnTfLiteParser/TfLiteParser.cpp
@@ -453,6 +453,7 @@ TfLiteParser::TfLiteParser()
m_ParserFunctions[tflite::BuiltinOperator_ADD] = &TfLiteParser::ParseAdd;
m_ParserFunctions[tflite::BuiltinOperator_MUL] = &TfLiteParser::ParseMul;
m_ParserFunctions[tflite::BuiltinOperator_MEAN] = &TfLiteParser::ParseMean;
+ m_ParserFunctions[tflite::BuiltinOperator_PAD] = &TfLiteParser::ParsePad;
}
void TfLiteParser::ResetParser()
@@ -1086,6 +1087,41 @@ void TfLiteParser::ParseMean(size_t subgraphIndex, size_t operatorIndex)
RegisterOutputSlots(subgraphIndex, operatorIndex, layer, {outputTensorIndexes[0]});
}
+void TfLiteParser::ParsePad(size_t subgraphIndex, size_t operatorIndex)
+{
+ CHECK_MODEL(m_Model, subgraphIndex, operatorIndex);
+
+ TfLiteParser::TensorRawPtrVector inputs = GetInputs(m_Model, subgraphIndex, operatorIndex);
+
+ TfLiteParser::TensorRawPtrVector outputs = GetOutputs(m_Model, subgraphIndex, operatorIndex);
+ CHECK_VALID_SIZE(outputs.size(), 1);
+
+ armnn::TensorInfo padTensorInfo = ToTensorInfo(inputs[1]);
+ BufferRawPtr bufferPtr = GetBuffer(m_Model, inputs[1]->buffer);
+
+ std::vector<unsigned int> padBuffer(padTensorInfo.GetNumElements());
+ ::memcpy(padBuffer.data(), bufferPtr->data.data(), padTensorInfo.GetNumBytes());
+
+ size_t step = 2;
+ armnn::PadDescriptor desc;
+ for (unsigned int i = 0; i < padTensorInfo.GetNumElements() / step; ++i)
+ {
+ desc.m_PadList.emplace_back(padBuffer[i * step], padBuffer[i * step + 1]);
+ }
+
+ auto layerName = boost::str(boost::format("Pad:%1%:%2%") % subgraphIndex % operatorIndex);
+ IConnectableLayer* layer = m_Network->AddPadLayer(desc, layerName.c_str());
+
+ 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[0]});
+}
+
void TfLiteParser::ParseRelu(size_t subgraphIndex, size_t operatorIndex)
{
CHECK_MODEL(m_Model, subgraphIndex, operatorIndex);