14{
15 std::string input0Name = std::string("input_");
18 std::string outputName = std::string("output0_");
20
21
22
23 if(layer != nullptr)
24 {
27 }
28
29 std::vector<TosaSerializationTensor*> tensors;
30 std::vector<TosaSerializationOperator*> operators;
31
32
33
34
35
36 if(input0Name.find("input_") != std::string::npos)
37 {
39 DType inputDType0 =
ArmNNToDType(inputs[0]->GetDataType());
40
41 tensors.push_back(new TosaSerializationTensor(input0Name, inputShape0, inputDType0, {}));
42 }
43
44
45 operators.push_back(new TosaSerializationOperator(Op_CONST, Attribute_NONE, nullptr, {}, {input1Name}));
46
47
48
49 if(layer == nullptr)
50 {
52 DType inputDType1 =
ArmNNToDType(inputs[1]->GetDataType());
53
54 tensors.push_back(new TosaSerializationTensor(input1Name, inputShape1, inputDType1, {}));
55 }
56 else
57 {
59
61 transposeConv2dLayer->m_Weight->GetTensorInfo().GetShape());
62 DType inputDType1 =
ArmNNToDType(transposeConv2dLayer->m_Weight->GetTensorInfo().GetDataType());
63
65 tensors.push_back(new TosaSerializationTensor(input1Name, inputShape1, inputDType1, uint8Data));
66 }
67
68
69 operators.push_back(new TosaSerializationOperator(Op_CONST, Attribute_NONE, nullptr, {}, {input2Name}));
70
71
72
74 {
76 DType inputDType2 =
ArmNNToDType(inputs[2]->GetDataType());
77
78 tensors.push_back(new TosaSerializationTensor(input2Name, inputShape2, inputDType2, {}));
79 }
81 {
83
85 transposeConv2dLayer->m_Bias->GetTensorInfo().GetShape());
86 DType inputDType2 =
ArmNNToDType(transposeConv2dLayer->m_Bias->GetTensorInfo().GetDataType());
87
89 tensors.push_back(new TosaSerializationTensor(input2Name, inputShape2, inputDType2, uint8Data));
90 }
91 else
92 {
93
94
95 unsigned int index = (descriptor->
m_DataLayout == DataLayout::NHWC) ? 3 : 1;
96
97 std::vector<uint8_t> uint8Data;
98 std::vector<float> data(outputs[0]->GetShape()[index], 0.0f);
99
100 TosaSerializationHandler::ConvertF32toU8(data, uint8Data);
101
102 tensors.push_back(new TosaSerializationTensor(input2Name,
103 {static_cast<int32_t>(outputs[0]->GetShape()[index])},
104 DType_FP32,
105 uint8Data));
106 }
107
108
110 DType outputDType0 =
ArmNNToDType(outputs[0]->GetDataType());
111
112 tensors.push_back(new TosaSerializationTensor(outputName, outputShape0, outputDType0, {}));
113
114
115
116
117
118 std::vector<int> pad = {-
static_cast<int>(descriptor->
m_PadTop),
120 -
static_cast<int>(descriptor->
m_PadLeft),
122 std::vector<int> stride = {
static_cast<int>(descriptor->
m_StrideY),
123 static_cast<int>(descriptor->
m_StrideX)};
124
125 std::vector<int> outputShape;
126
128 {
129 for (uint32_t i = 0; i < descriptor->
m_OutputShape.size(); ++i)
130 {
131 outputShape.push_back(
static_cast<int>(descriptor->
m_OutputShape[i]));
132 }
133 }
134 else
135 {
136 for (uint32_t i = 0; i < outputs[0]->GetNumDimensions(); ++i)
137 {
138 outputShape.push_back(static_cast<int>(outputs[0]->GetShape()[i]));
139 }
140 }
141
142 TosaTransposeConvAttribute attribute(pad, stride, outputShape, 0, 0, false);
143
144 auto* op = new TosaSerializationOperator(Op_TRANSPOSE_CONV2D,
145 Attribute_TransposeConvAttribute,
146 &attribute,
147 {input0Name, input1Name, input2Name},
148 {outputName});
149 operators.push_back(op);
150
151
152
153 return new TosaSerializationBasicBlock(blockName,
155 operators,
156 tensors,
157 {input0Name, input1Name, input2Name},
158 {outputName});
159}
std::string GenerateUniqueOutputName(const Layer &layer, uint32_t layerSlot=0)
const std::string mainName
std::vector< uint8_t > ConvertConstantTensorDataToBuffer(const std::shared_ptr< ConstTensorHandle > &tensorHandle)
DType ArmNNToDType(const DataType &type)
std::string GenerateUniqueInputName(const armnn::InputSlot &slot)
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.
DestType PolymorphicDowncast(SourceType *value)
Polymorphic downcast for build in pointers only.
uint32_t m_PadRight
Padding right value in the width dimension.
uint32_t m_PadTop
Padding top value in the height dimension.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
std::vector< unsigned int > m_OutputShape
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.
bool m_BiasEnabled
Enable/disable bias.
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.