11 const std::vector<const TensorInfo*>& inputs,
12 const std::vector<const TensorInfo*>& outputs,
15 std::string input0Name = std::string(
"input_");
18 std::string outputName = std::string(
"output0_");
29 std::vector<TosaSerializationTensor*> tensors;
30 std::vector<TosaSerializationOperator*> operators;
36 if(input0Name.find(
"input_") != std::string::npos)
39 DType inputDType0 =
ArmNNToDType(inputs[0]->GetDataType());
41 tensors.push_back(
new TosaSerializationTensor(input0Name, inputShape0, inputDType0, {}));
45 operators.push_back(
new TosaSerializationOperator(Op_CONST, Attribute_NONE,
nullptr, {}, {input1Name}));
52 DType inputDType1 =
ArmNNToDType(inputs[1]->GetDataType());
54 tensors.push_back(
new TosaSerializationTensor(input1Name, inputShape1, inputDType1, {}));
58 auto transposeConv2dLayer = PolymorphicDowncast<const TransposeConvolution2dLayer*>(layer);
61 transposeConv2dLayer->m_Weight->GetTensorInfo().GetShape());
62 DType inputDType1 =
ArmNNToDType(transposeConv2dLayer->m_Weight->GetTensorInfo().GetDataType());
65 tensors.push_back(
new TosaSerializationTensor(input1Name, inputShape1, inputDType1, uint8Data));
69 operators.push_back(
new TosaSerializationOperator(Op_CONST, Attribute_NONE,
nullptr, {}, {input2Name}));
76 DType inputDType2 =
ArmNNToDType(inputs[2]->GetDataType());
78 tensors.push_back(
new TosaSerializationTensor(input2Name, inputShape2, inputDType2, {}));
82 auto transposeConv2dLayer = PolymorphicDowncast<const TransposeConvolution2dLayer*>(layer);
85 transposeConv2dLayer->m_Bias->GetTensorInfo().GetShape());
86 DType inputDType2 =
ArmNNToDType(transposeConv2dLayer->m_Bias->GetTensorInfo().GetDataType());
89 tensors.push_back(
new TosaSerializationTensor(input2Name, inputShape2, inputDType2, uint8Data));
95 unsigned int index = (descriptor->
m_DataLayout == DataLayout::NHWC) ? 3 : 1;
97 std::vector<uint8_t> uint8Data;
98 std::vector<float> data(outputs[0]->GetShape()[index], 0.0f);
100 TosaSerializationHandler::ConvertF32toU8(data, uint8Data);
102 tensors.push_back(
new TosaSerializationTensor(input2Name,
103 {
static_cast<int32_t
>(outputs[0]->GetShape()[index])},
110 DType outputDType0 =
ArmNNToDType(outputs[0]->GetDataType());
112 tensors.push_back(
new TosaSerializationTensor(outputName, outputShape0, outputDType0, {}));
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)};
125 std::vector<int> outputShape;
129 for (uint32_t i = 0; i < descriptor->
m_OutputShape.size(); ++i)
131 outputShape.push_back(
static_cast<int>(descriptor->
m_OutputShape[i]));
136 for (uint32_t i = 0; i < outputs[0]->GetNumDimensions(); ++i)
138 outputShape.push_back(
static_cast<int>(outputs[0]->GetShape()[i]));
142 TosaTransposeConvAttribute attribute(pad, stride, outputShape, 0, 0,
false);
144 auto* op =
new TosaSerializationOperator(Op_TRANSPOSE_CONV2D,
145 Attribute_TransposeConvAttribute,
147 {input0Name, input1Name, input2Name},
149 operators.push_back(op);
153 return new TosaSerializationBasicBlock(blockName,
157 {input0Name, input1Name, input2Name},