11 const std::vector<const TensorInfo*>& inputs,
12 const std::vector<const TensorInfo*>& outputs,
15 std::string input0Name = std::string(
"input0_");
18 std::string outputName = std::string(
"output0_");
33 std::vector<TosaSerializationTensor*> tensors;
34 std::vector<TosaSerializationOperator*> operators;
40 if(input0Name.find(
"input0_") != std::string::npos)
43 DType inputDType0 =
ArmNNToDType(inputs[0]->GetDataType());
45 tensors.push_back(
new TosaSerializationTensor(input0Name, inputShape0, inputDType0, {}));
49 operators.push_back(
new TosaSerializationOperator(Op_CONST, Attribute_NONE,
nullptr, {}, {input1Name}));
56 DType inputDType1 =
ArmNNToDType(inputs[1]->GetDataType());
58 tensors.push_back(
new TosaSerializationTensor(input1Name, inputShape1, inputDType1, {}));
62 auto transposeConv2dLayer = PolymorphicDowncast<const TransposeConvolution2dLayer*>(layer);
65 transposeConv2dLayer->m_Weight->GetTensorInfo().GetShape());
66 DType inputDType1 =
ArmNNToDType(transposeConv2dLayer->m_Weight->GetTensorInfo().GetDataType());
69 tensors.push_back(
new TosaSerializationTensor(input1Name, inputShape1, inputDType1, uint8Data));
73 operators.push_back(
new TosaSerializationOperator(Op_CONST, Attribute_NONE,
nullptr, {}, {input2Name}));
80 DType inputDType2 =
ArmNNToDType(inputs[2]->GetDataType());
82 tensors.push_back(
new TosaSerializationTensor(input2Name, inputShape2, inputDType2, {}));
86 auto transposeConv2dLayer = PolymorphicDowncast<const TransposeConvolution2dLayer*>(layer);
89 transposeConv2dLayer->m_Bias->GetTensorInfo().GetShape());
90 DType inputDType2 =
ArmNNToDType(transposeConv2dLayer->m_Bias->GetTensorInfo().GetDataType());
93 tensors.push_back(
new TosaSerializationTensor(input2Name, inputShape2, inputDType2, uint8Data));
99 unsigned int index = (descriptor->
m_DataLayout == DataLayout::NHWC) ? 3 : 1;
101 std::vector<uint8_t> uint8Data;
102 std::vector<float> data(outputs[0]->GetShape()[index], 0.0f);
104 TosaSerializationHandler::ConvertF32toU8(data, uint8Data);
106 tensors.push_back(
new TosaSerializationTensor(input2Name,
107 {
static_cast<int32_t
>(outputs[0]->GetShape()[index])},
114 DType outputDType0 =
ArmNNToDType(outputs[0]->GetDataType());
116 tensors.push_back(
new TosaSerializationTensor(outputName, outputShape0, outputDType0, {}));
122 std::vector<int> pad = {-
static_cast<int>(descriptor->
m_PadTop),
124 -
static_cast<int>(descriptor->
m_PadLeft),
126 std::vector<int> stride = {
static_cast<int>(descriptor->
m_StrideY),
127 static_cast<int>(descriptor->
m_StrideX)};
129 std::vector<int> outputShape;
133 for (uint32_t i = 0; i < descriptor->
m_OutputShape.size(); ++i)
135 outputShape.push_back(
static_cast<int>(descriptor->
m_OutputShape[i]));
140 for (uint32_t i = 0; i < outputs[0]->GetNumDimensions(); ++i)
142 outputShape.push_back(
static_cast<int>(outputs[0]->GetShape()[i]));
146 TosaTransposeConvAttribute attribute(pad, stride, outputShape, 0, 0);
148 auto* op =
new TosaSerializationOperator(Op_TRANSPOSE_CONV2D,
149 Attribute_TransposeConvAttribute,
151 {input0Name, input1Name, input2Name},
153 operators.push_back(op);
157 return new TosaSerializationBasicBlock(blockName,
161 {input0Name, input1Name, input2Name},