aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Jackson <matthew.jackson@arm.com>2019-08-20 17:18:33 +0100
committerÁron Virginás-Tar <aron.virginas-tar@arm.com>2019-08-21 12:09:47 +0000
commitccb25ea483747d4f7f319e0d3f1c9c6507931011 (patch)
treeed49ee9057c35d0388e21945a3d94948f53d6142
parent7599aa47f29531ebcbb3badea73ec181616bb29b (diff)
downloadarmnn-ccb25ea483747d4f7f319e0d3f1c9c6507931011.tar.gz
IVGCVSW-3650 Fix Transpose Convolution inputs in TfLite parser
* Reordered and edited inputs in ParseTransposeConv method * Updated test cases to reflect changes Signed-off-by: Matthew Jackson <matthew.jackson@arm.com> Change-Id: Icd090cf6ab340eed4f098ef8641daf7c6e0d0949
-rw-r--r--src/armnnTfLiteParser/TfLiteParser.cpp29
-rw-r--r--src/armnnTfLiteParser/test/TransposeConv.cpp89
2 files changed, 30 insertions, 88 deletions
diff --git a/src/armnnTfLiteParser/TfLiteParser.cpp b/src/armnnTfLiteParser/TfLiteParser.cpp
index 0e11a5c3e1..d1cef31446 100644
--- a/src/armnnTfLiteParser/TfLiteParser.cpp
+++ b/src/armnnTfLiteParser/TfLiteParser.cpp
@@ -879,12 +879,12 @@ void TfLiteParser::ParseTransposeConv(size_t subgraphIndex, size_t operatorIndex
desc.m_DataLayout = armnn::DataLayout::NHWC;
auto inputs = GetInputs(m_Model, subgraphIndex, operatorIndex);
- CHECK_VALID_SIZE(inputs.size(), 2, 3);
+ CHECK_VALID_SIZE(inputs.size(), 3);
auto outputs = GetOutputs(m_Model, subgraphIndex, operatorIndex);
CHECK_VALID_SIZE(outputs.size(), 1);
- armnn::TensorInfo inputTensorInfo = ToTensorInfo(inputs[0]);
+ armnn::TensorInfo inputTensorInfo = ToTensorInfo(inputs[2]);
armnn::TensorInfo filterTensorInfo = ToTensorInfo(inputs[1]);
// TfLite uses NHWC tensors
@@ -917,25 +917,10 @@ void TfLiteParser::ParseTransposeConv(size_t subgraphIndex, size_t operatorIndex
armnn::IConnectableLayer* layer = nullptr;
auto layerName = boost::str(boost::format("TransposeConv:%1%:%2%") % subgraphIndex % operatorIndex);
- if (inputs.size() == 3)
- {
- desc.m_BiasEnabled = true;
- armnn::TensorInfo biasTensorInfo = ToTensorInfo(inputs[2]);
- auto biasTensorAndData = CreateConstTensor(inputs[2],
- biasTensorInfo,
- armnn::Optional<armnn::PermutationVector&>());
- layer = m_Network->AddTransposeConvolution2dLayer(desc,
- filterTensorAndData.first,
- Optional<ConstTensor>(biasTensorAndData.first),
- layerName.c_str());
- }
- else
- {
- layer = m_Network->AddTransposeConvolution2dLayer(desc,
- filterTensorAndData.first,
- EmptyOptional(),
- layerName.c_str());
- }
+ layer = m_Network->AddTransposeConvolution2dLayer(desc,
+ filterTensorAndData.first,
+ EmptyOptional(),
+ layerName.c_str());
BOOST_ASSERT(layer != nullptr);
@@ -944,7 +929,7 @@ void TfLiteParser::ParseTransposeConv(size_t subgraphIndex, size_t operatorIndex
// only the tensors for the inputs are relevant, exclude the const (filter) tensor
auto inputTensorIndexes = AsUnsignedVector(GetInputTensorIds(m_Model, subgraphIndex, operatorIndex));
- RegisterInputSlots(subgraphIndex, operatorIndex, layer, {inputTensorIndexes[0]});
+ RegisterInputSlots(subgraphIndex, operatorIndex, layer, {inputTensorIndexes[2]});
auto outputTensorIndexes = AsUnsignedVector(GetOutputTensorIds(m_Model, subgraphIndex, operatorIndex));
RegisterOutputSlots(subgraphIndex, operatorIndex, layer, {outputTensorIndexes[0]});
diff --git a/src/armnnTfLiteParser/test/TransposeConv.cpp b/src/armnnTfLiteParser/test/TransposeConv.cpp
index 05b48ecf0b..53212b58f9 100644
--- a/src/armnnTfLiteParser/test/TransposeConv.cpp
+++ b/src/armnnTfLiteParser/test/TransposeConv.cpp
@@ -15,31 +15,10 @@ struct TransposeConvFixture : public ParserFlatbuffersFixture
const std::string& outputShape,
const std::string& filterShape,
const std::string& filterData,
- const bool biasEnabled,
- const std::string& biasShape,
- const std::string& biasData,
const std::string& strideX,
const std::string& strideY,
const std::string& dataType)
{
- std::string biasString;
- if (biasEnabled)
- {
- biasString = R"(
- {
- "shape": )" + biasShape + R"(,
- "type": "INT32",
- "buffer": 2,
- "name": "biasTensor",
- "quantization": {
- "min": [ 0.0 ],
- "max": [ 255.0 ],
- "scale": [ 1.0 ],
- "zero_point": [ 0 ],
- }
- },)";
-
- }
m_JsonString = R"(
{
"version": 3,
@@ -47,10 +26,10 @@ struct TransposeConvFixture : public ParserFlatbuffersFixture
"subgraphs": [ {
"tensors": [
{
- "shape": )" + inputShape + R"(,
- "type": ")" + dataType + R"(",
+ "shape": [ 4 ],
+ "type": "UINT8",
"buffer": 0,
- "name": "inputTensor",
+ "name": "outputShapeTensor",
"quantization": {
"min": [ 0.0 ],
"max": [ 255.0 ],
@@ -69,11 +48,23 @@ struct TransposeConvFixture : public ParserFlatbuffersFixture
"scale": [ 1.0 ],
"zero_point": [ 0 ],
}
- },)" + biasString + R"(
+ },
+ {
+ "shape": )" + inputShape + R"(,
+ "type": ")" + dataType + R"(",
+ "buffer": 2,
+ "name": "inputTensor",
+ "quantization": {
+ "min": [ 0.0 ],
+ "max": [ 255.0 ],
+ "scale": [ 1.0 ],
+ "zero_point": [ 0 ],
+ }
+ },
{
"shape": )" + outputShape + R"(,
"type": ")" + dataType + R"(",
- "buffer": )" + (biasEnabled ? "3" : "2") + R"(,
+ "buffer": 3,
"name": "outputTensor",
"quantization": {
"min": [ 0.0 ],
@@ -83,13 +74,13 @@ struct TransposeConvFixture : public ParserFlatbuffersFixture
}
}
],
- "inputs": [ 0 ],
- "outputs": [ )" + (biasEnabled ? "3" : "2") + R"( ],
+ "inputs": [ 2 ],
+ "outputs": [ 3 ],
"operators": [
{
"opcode_index": 0,
- "inputs": [ 0, 1)" + (biasEnabled ? ", 2" : "") + R"( ],
- "outputs": [ )" + (biasEnabled ? "3" : "2") + R"( ],
+ "inputs": [ 0, 1, 2 ],
+ "outputs": [ 3 ],
"builtin_options_type": "TransposeConvOptions",
"builtin_options": {
"padding": "SAME",
@@ -101,9 +92,9 @@ struct TransposeConvFixture : public ParserFlatbuffersFixture
],
} ],
"buffers" : [
- { },
+ { "data": )" + outputShape + R"( },
{ "data": )" + filterData + R"( },
- { )" + (biasEnabled ? (R"("data": )" + biasData) : "") + R"( },
+ { },
{ }
]
}
@@ -119,9 +110,6 @@ struct SimpleTransposeConvFixture : TransposeConvFixture
"[ 1, 3, 3, 1 ]", // outputShape
"[ 1, 2, 2, 1 ]", // filterShape
"[ 0, 1, 2, 4 ]", // filterData
- false, // biasEnabled
- "", // biasShape
- "", // biasData
"1", // strideX
"1", // strideY
"UINT8") // dataType
@@ -143,35 +131,4 @@ BOOST_FIXTURE_TEST_CASE( ParseSimpleTransposeConv, SimpleTransposeConvFixture )
});
}
-struct TransposeConvWithBiasFixture : TransposeConvFixture
-{
- TransposeConvWithBiasFixture()
- : TransposeConvFixture("[ 1, 2, 2, 1 ]", // inputShape
- "[ 1, 3, 3, 1 ]", // outputShape
- "[ 1, 2, 2, 1 ]", // filterShape
- "[ 0, 1, 2, 4 ]", // filterData
- true, // biasEnabled
- "[ 1 ]", // biasShape
- "[ 2, 0, 0, 0 ]", // biasData
- "1", // strideX
- "1", // strideY
- "UINT8") // dataType
- {}
-};
-
-BOOST_FIXTURE_TEST_CASE( ParseTransposeConvWithBias, TransposeConvWithBiasFixture )
-{
- RunTest<4, armnn::DataType::QuantisedAsymm8>(
- 0,
- {
- 1, 2,
- 3, 4
- },
- {
- 2, 3, 5,
- 4, 13, 14,
- 8, 22, 18
- });
-}
-
BOOST_AUTO_TEST_SUITE_END()