12{
13 std::string padInputName = std::string("input_");
15 std::string poolOutputName = std::string("output0_");
17
18
19
20 if(layer != nullptr)
21 {
24 }
25
26 std::vector<int> paddings;
28 {
29 paddings = {0,
30 0,
31 static_cast<int>(poolDescriptor->
m_PadTop),
33 static_cast<int>(poolDescriptor->
m_PadLeft),
35 0,
36 0
37 };
38 }
39 else
40 {
41 paddings = {0,
42 0,
43 0,
44 0,
45 static_cast<int>(poolDescriptor->
m_PadTop),
47 static_cast<int>(poolDescriptor->
m_PadLeft),
49 };
50 }
51
52 std::vector<TosaSerializationTensor*> tensors;
53 std::vector<TosaSerializationOperator*> operators;
54
55 TosaPadAttribute padAttribute(paddings, 0, 0.0f);
56 operators.push_back(new TosaSerializationOperator(Op_PAD,
57 Attribute_PadAttribute,
58 &padAttribute,
59 {padInputName},
60 {padOutputName}));
61
62 std::vector<int> pad = {0, 0, 0, 0};
63 std::vector<int> kernel = {
static_cast<int>(poolDescriptor->
m_PoolHeight),
65 std::vector<int> stride = {
static_cast<int>(poolDescriptor->
m_StrideY),
66 static_cast<int>(poolDescriptor->
m_StrideX)};
67 std::vector<int> dilation = {1, 1};
68
70 DType inputDType =
ArmNNToDType(inputs[0]->GetDataType());
72 padOutputName,
74 inputDType,
75 kernel,
76 pad,
77 stride,
78 dilation,
79 tensors,
80 operators,
81 true);
82
83 TosaPoolAttribute poolAttribute(pad, kernel, stride, 0, 0,
ArmNNToDType(inputs[0]->GetDataType()));
84
85 operators.push_back(new TosaSerializationOperator(Op_AVG_POOL2D,
86 Attribute_PoolAttribute,
87 &poolAttribute,
88 {sliceOutputName},
89 {poolOutputName}));
90
91
92
93
94 if(padInputName.find("input_") != std::string::npos)
95 {
96 tensors.push_back(new TosaSerializationTensor(padInputName, inputShape, inputDType, {}));
97 }
98
100 DType outputDType =
ArmNNToDType(outputs[0]->GetDataType());
101
102 std::vector<int32_t> intermediateShape;
104 {
105 intermediateShape = {inputShape[0],
106 inputShape[1] + paddings[2] + paddings[3],
107 inputShape[2] + paddings[4] + paddings[5],
108 inputShape[3]};
109 }
110 else
111 {
112 intermediateShape = {inputShape[0],
113 inputShape[1],
114 inputShape[2] + paddings[4] + paddings[5],
115 inputShape[3] + paddings[6] + paddings[7]};
116 }
117
118 tensors.push_back(new TosaSerializationTensor(padOutputName, intermediateShape, inputDType, {}));
119 tensors.push_back(new TosaSerializationTensor(poolOutputName, outputShape, outputDType, {}));
120
121
122
123 return new TosaSerializationBasicBlock(blockName,
125 operators,
126 tensors,
127 {padInputName},
128 {poolOutputName});
129}
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.
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.