aboutsummaryrefslogtreecommitdiff
path: root/src/backends/tosaCommon/operatorMappings/Pooling2DOperator.cpp
diff options
context:
space:
mode:
authorMatthew Sloyan <matthew.sloyan@arm.com>2022-12-14 10:16:27 +0000
committerTeresaARM <teresa.charlinreyes@arm.com>2022-12-15 12:21:16 +0000
commitda6bf9e2eac374cd92147d3c60a8af8bd6bc5a37 (patch)
tree9999b8d92c2b14b4bb349cbfd250dc33af252fb7 /src/backends/tosaCommon/operatorMappings/Pooling2DOperator.cpp
parentfc9d5e7d1e0c1a4d7fed4ebc363832e03c3e2543 (diff)
downloadarmnn-da6bf9e2eac374cd92147d3c60a8af8bd6bc5a37.tar.gz
IVGCVSW-7168 Support simple model in the TOSA Reference Backend
* Fixed issue where duplicate tensors where being created. * Fixed issue where output name could be generated with the wrong id. * Updated bias tensor for Conv2d, so the size matches the channel. Signed-off-by: Matthew Sloyan <matthew.sloyan@arm.com> Change-Id: I1de6947e036b3e629ec6446d24d69e50603a5593
Diffstat (limited to 'src/backends/tosaCommon/operatorMappings/Pooling2DOperator.cpp')
-rw-r--r--src/backends/tosaCommon/operatorMappings/Pooling2DOperator.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/backends/tosaCommon/operatorMappings/Pooling2DOperator.cpp b/src/backends/tosaCommon/operatorMappings/Pooling2DOperator.cpp
index 265901e1ae..ee02425c17 100644
--- a/src/backends/tosaCommon/operatorMappings/Pooling2DOperator.cpp
+++ b/src/backends/tosaCommon/operatorMappings/Pooling2DOperator.cpp
@@ -26,8 +26,7 @@ TosaSerializationBasicBlock* ConvertPooling2DToTosaOperator(const Layer* layer,
input0Name = GenerateUniqueName(connectedInputLayer, 0);
// Get the layer connected to the output slot and determine unique layer name.
- Layer& connectedOutputLayer = layer->GetOutputSlot().GetConnection(0)->GetOwningLayer();
- outputName = GenerateUniqueName(connectedOutputLayer, 0);
+ outputName = GenerateUniqueOutputName(*layer, 0);
}
std::vector<int> pad = {static_cast<int>(poolDescriptor->m_PadTop),
@@ -46,20 +45,29 @@ TosaSerializationBasicBlock* ConvertPooling2DToTosaOperator(const Layer* layer,
{input0Name},
{outputName});
- std::vector<int32_t> inputShape0 = GetTosaTensorShape(inputs[0]->GetShape());
- DType inputDType0 = ArmNNToDType(inputs[0]->GetDataType());
+ std::vector<TosaSerializationTensor*> tensors;
+
+ // Only add input tensors if connected layer is an input layer.
+ // As intermediate or constant tensors will be created separately.
+ // There also can't be duplicate tensor.
+ if(input0Name.find("input0_") != std::string::npos)
+ {
+ std::vector<int32_t> inputShape0 = GetTosaTensorShape(inputs[0]->GetShape());
+ DType inputDType0 = ArmNNToDType(inputs[0]->GetDataType());
+
+ tensors.push_back(new TosaSerializationTensor(input0Name, inputShape0, inputDType0, {}));
+ }
std::vector<int32_t> outputShape0 = GetTosaTensorShape(outputs[0]->GetShape());
DType outputDType0 = ArmNNToDType(outputs[0]->GetDataType());
- auto* inputTensor0 = new TosaSerializationTensor(input0Name, inputShape0, inputDType0, {});
- auto* outputTensor0 = new TosaSerializationTensor(outputName, outputShape0, outputDType0, {});
+ tensors.push_back(new TosaSerializationTensor(outputName, outputShape0, outputDType0, {}));
// operatorInputNames/operatorOutputNames ends up being the same as
// blockInputNames/blockOutputNames for one-to-one ArmNN to TOSA mappings
return new TosaSerializationBasicBlock(blockName, // name
{op}, // operators
- {inputTensor0, outputTensor0}, // tensors
+ tensors, // tensors
{input0Name}, // inputs
{outputName}); // outputs
} \ No newline at end of file