12{
13 std::string poolType = (poolDescriptor->
m_PoolType == PoolingAlgorithm::Max) ?
"Op_MAX" :
"Op_AVG";
14 Op opcode = (poolDescriptor->
m_PoolType == PoolingAlgorithm::Max) ? Op_MAX_POOL2D : Op_AVG_POOL2D;
15
16 std::string inputName = std::string("input_");
17 std::string outputName = std::string("output0_");
18 std::string blockName = std::string(
"Op_") + poolType + std::string(
"_POOL2D_block_") +
GetUniqueTosaMappingID();
19
20
21
22 if(layer != nullptr)
23 {
26 }
27
28 DType accType = DType_INT32;
29 DType inputDType0 =
ArmNNToDType(inputs[0]->GetDataType());
30 if (inputDType0 == DType_FP32)
31 {
32 accType = DType_FP32;
33 }
34 else if (inputDType0 == DType_FP16)
35 {
36 accType = DType_FP16;
37 }
38
39 std::vector<TosaSerializationTensor*> tensors;
40 std::vector<TosaSerializationOperator*> operators;
41
42
43
44
46 if(inputName.find("input_") != std::string::npos)
47 {
48 tensors.push_back(new TosaSerializationTensor(inputName, inputShape0, inputDType0, {}));
49 }
50
52 DType outputDType0 =
ArmNNToDType(outputs[0]->GetDataType());
53
54 tensors.push_back(new TosaSerializationTensor(outputName, outputShape0, outputDType0, {}));
55
56 std::vector<int> pad = {
static_cast<int>(poolDescriptor->
m_PadTop),
58 static_cast<int>(poolDescriptor->
m_PadLeft),
60 std::vector<int> kernel = {
static_cast<int>(poolDescriptor->
m_PoolHeight),
62 std::vector<int> stride = {
static_cast<int>(poolDescriptor->
m_StrideY),
63 static_cast<int>(poolDescriptor->
m_StrideX)};
64 std::vector<int> dilation = {1, 1};
65
67 inputName,
69 inputDType0,
70 kernel,
71 pad,
72 stride,
73 dilation,
74 tensors,
75 operators,
76 true);
77
78 TosaPoolAttribute attribute(pad, kernel, stride, 0, 0, accType);
79
80 operators.push_back(new TosaSerializationOperator(opcode,
81 Attribute_PoolAttribute,
82 &attribute,
83 {sliceOutputName},
84 {outputName}));
85
86
87
88 return new TosaSerializationBasicBlock(blockName,
90 operators,
91 tensors,
92 {sliceOutputName},
93 {outputName});
94}
std::string GenerateUniqueOutputName(const Layer &layer, uint32_t layerSlot=0)
const std::string mainName
DType ArmNNToDType(const DataType &type)
std::string GenerateUniqueInputName(const armnn::InputSlot &slot)
std::string GetInputSlicedToItsUsedSize(const std::vector< int32_t > &inputShape, const std::string &inputName, const DataLayout layout, const DType datatype, const std::vector< int32_t > &kernel, const std::vector< int32_t > &pad, const std::vector< int32_t > &stride, const std::vector< int32_t > &dilations, std::vector< TosaSerializationTensor * > &tensors, std::vector< TosaSerializationOperator * > &operators, const bool isPoolingOp=false)
std::string GetUniqueTosaMappingID()
std::vector< int32_t > GetTosaTensorShape(const TensorShape &shape)
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
uint32_t m_PadRight
Padding right value in the width dimension.
PoolingAlgorithm m_PoolType
The pooling algorithm to use (Max. Average, L2).
uint32_t m_PoolHeight
Pooling height value.
uint32_t m_PadTop
Padding top value in the height dimension.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
uint32_t m_PoolWidth
Pooling width value.
uint32_t m_PadBottom
Padding bottom value in the height dimension.
uint32_t m_PadLeft
Padding left value in the width dimension.
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.