aboutsummaryrefslogtreecommitdiff
path: root/src/backends/tosaCommon/operatorMappings/Pooling2DOperator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/backends/tosaCommon/operatorMappings/Pooling2DOperator.cpp')
-rw-r--r--src/backends/tosaCommon/operatorMappings/Pooling2DOperator.cpp39
1 files changed, 22 insertions, 17 deletions
diff --git a/src/backends/tosaCommon/operatorMappings/Pooling2DOperator.cpp b/src/backends/tosaCommon/operatorMappings/Pooling2DOperator.cpp
index cd707edb3a..eaeb8a4cde 100644
--- a/src/backends/tosaCommon/operatorMappings/Pooling2DOperator.cpp
+++ b/src/backends/tosaCommon/operatorMappings/Pooling2DOperator.cpp
@@ -5,24 +5,29 @@
#include "Pooling2DOperator.hpp"
-TosaSerializationBasicBlock* ConvertPooling2DToTosaOperator(const std::vector<const TensorInfo*>& inputs,
+TosaSerializationBasicBlock* ConvertPooling2DToTosaOperator(const Layer* layer,
+ const std::vector<const TensorInfo*>& inputs,
const std::vector<const TensorInfo*>& outputs,
- bool isMain,
const Pooling2dDescriptor* poolDescriptor)
{
std::string poolType = (poolDescriptor->m_PoolType == PoolingAlgorithm::Max) ? "Op_MAX" : "Op_AVG";
Op opcode = (poolDescriptor->m_PoolType == PoolingAlgorithm::Max) ? Op_MAX_POOL2D : Op_AVG_POOL2D;
- // A helper function with static global variables ensures uniqueness
- // for dynamically generating input, output and block names
- std::string input0Name = poolType + std::string("_POOL2D_input0_") + GetUniqueTosaMappingID();
- std::string outputName = poolType + std::string("_POOL2D_output0_") + GetUniqueTosaMappingID();
- std::string blockName = poolType + std::string("_POOL2D_block_") + GetUniqueTosaMappingID();
+ std::string input0Name = std::string("input0_");
+ std::string outputName = std::string("output0_");
+ std::string blockName = std::string("Op_") + poolType + std::string("_POOL2D_block_") + GetUniqueTosaMappingID();
- // If it's the first block, overwrite block name with main.
- if (isMain)
+ // If a layer is present then the block will be used for execution, so input and output names need to be determined
+ // using the previous and following layers so the graph is connected correctly. For validation this doesn't matter.
+ if(layer != nullptr)
{
- blockName = std::string("main");
+ // Get the layers connected to the input slots and determine unique layer names.
+ Layer& connectedInputLayer = layer->GetInputSlot(0).GetConnectedOutputSlot()->GetOwningLayer();
+ 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);
}
std::vector<int> pad = {static_cast<int>(poolDescriptor->m_PadTop),
@@ -35,11 +40,11 @@ TosaSerializationBasicBlock* ConvertPooling2DToTosaOperator(const std::vector<co
static_cast<int>(poolDescriptor->m_StrideX)};
TosaPoolAttribute attribute(pad, kernel, stride, 0, 0, ArmNNToDType(inputs[0]->GetDataType()));
- TosaSerializationOperator* op = new TosaSerializationOperator(opcode,
- Attribute_PoolAttribute,
- &attribute,
- {input0Name},
- {outputName});
+ auto* op = new TosaSerializationOperator(opcode,
+ Attribute_PoolAttribute,
+ &attribute,
+ {input0Name},
+ {outputName});
std::vector<int32_t> inputShape0 = GetTosaTensorShape(inputs[0]->GetShape());
DType inputDType0 = ArmNNToDType(inputs[0]->GetDataType());
@@ -47,8 +52,8 @@ TosaSerializationBasicBlock* ConvertPooling2DToTosaOperator(const std::vector<co
std::vector<int32_t> outputShape0 = GetTosaTensorShape(outputs[0]->GetShape());
DType outputDType0 = ArmNNToDType(outputs[0]->GetDataType());
- TosaSerializationTensor* inputTensor0 = new TosaSerializationTensor(input0Name, inputShape0, inputDType0, {});
- TosaSerializationTensor* outputTensor0 = new TosaSerializationTensor(outputName, outputShape0, outputDType0, {});
+ auto* inputTensor0 = new TosaSerializationTensor(input0Name, inputShape0, inputDType0, {});
+ auto* outputTensor0 = new TosaSerializationTensor(outputName, outputShape0, outputDType0, {});
// operatorInputNames/operatorOutputNames ends up being the same as
// blockInputNames/blockOutputNames for one-to-one ArmNN to Tosa mappings