9 const std::vector<const TensorInfo*>& inputs,
10 const std::vector<const TensorInfo*>& outputs,
13 std::vector<std::string> inputNames;
14 std::string outputName = std::string(
"output0_");
20 inputNames.emplace_back(
"input0_");
21 inputNames.emplace_back(
"input1_");
24 inputNames.emplace_back(
"input2_");
33 for (uint32_t i = 0; i < inputs.size(); ++i)
38 inputNames.push_back(inputName);
45 std::vector<TosaSerializationTensor*> tensors;
46 std::vector<TosaSerializationOperator*> operators;
52 if(inputNames[0].find(
"input0_") != std::string::npos)
55 DType inputDType0 =
ArmNNToDType(inputs[0]->GetDataType());
57 tensors.push_back(
new TosaSerializationTensor(inputNames[0], inputShape0, inputDType0, {}));
62 if(!inputs[1]->IsConstant() || layer ==
nullptr)
65 DType inputDType1 =
ArmNNToDType(inputs[1]->GetDataType());
67 tensors.push_back(
new TosaSerializationTensor(inputNames[1], inputShape1, inputDType1, {}));
72 if(!inputs[2]->IsConstant() || layer ==
nullptr)
75 DType inputDType2 =
ArmNNToDType(inputs[2]->GetDataType());
77 tensors.push_back(
new TosaSerializationTensor(inputNames[2], inputShape2, inputDType2, {}));
85 operators.push_back(
new TosaSerializationOperator(Op_CONST, Attribute_NONE,
nullptr, {}, {constantName}));
88 unsigned int index = (conv2dDescriptor->
m_DataLayout == DataLayout::NHWC) ? 3 : 1;
90 std::vector<uint8_t> uint8Data;
91 std::vector<float> data(outputs[0]->GetShape()[index], 0.0f);
93 TosaSerializationHandler::ConvertF32toU8(data, uint8Data);
95 tensors.push_back(
new TosaSerializationTensor(constantName,
96 {
static_cast<int32_t
>(outputs[0]->GetShape()[index])},
99 inputNames.emplace_back(constantName);
104 DType outputDType0 =
ArmNNToDType(outputs[0]->GetDataType());
106 tensors.push_back(
new TosaSerializationTensor(outputName, outputShape0, outputDType0, {}));
109 std::vector<int> pad = {
static_cast<int>(conv2dDescriptor->
m_PadTop),
111 static_cast<int>(conv2dDescriptor->
m_PadLeft),
112 static_cast<int>(conv2dDescriptor->
m_PadRight)};
113 std::vector<int> stride = {
static_cast<int>(conv2dDescriptor->
m_StrideY),
114 static_cast<int>(conv2dDescriptor->
m_StrideX)};
115 std::vector<int> dilation = {
static_cast<int>(conv2dDescriptor->
m_DilationY),
117 TosaConvAttribute attribute(pad, stride, dilation, 0, 0);
119 auto* op =
new TosaSerializationOperator(Op_CONV2D,
120 Attribute_ConvAttribute,
124 operators.push_back(op);
128 return new TosaSerializationBasicBlock(blockName,