18{
19
21 {
23 }
24
25
26 if (inputs[0]->GetNumDimensions() != 4)
27 {
29 }
30
31 std::string inputName;
32 std::string outputName = std::string("output0_");
36
37 DType inputDType0 =
ArmNNToDType(inputs[0]->GetDataType());
38 DType outputDType0 =
ArmNNToDType(outputs[0]->GetDataType());
39
40
41 if(layer == nullptr)
42 {
43 inputName = "input_0";
44 }
45
46
47
48 else
49 {
50
51 for (uint32_t i = 0; i < inputs.size(); ++i)
52 {
54 }
55
56
58 }
59
60 std::vector<TosaSerializationTensor*> tensors;
61 std::vector<TosaSerializationOperator*> operators;
62
63
64
65 if(inputName.find("input_") != std::string::npos)
66 {
68 tensors.push_back(new TosaSerializationTensor(inputName, inputShape0, inputDType0, {}));
69 }
70
71 std::vector<int32_t> reshapeDims1
72 {
73 static_cast<int32_t>(inputs[0]->GetShape()[0]),
74 static_cast<int32_t>(inputs[0]->GetShape()[1]),
75 static_cast<int32_t>(inputs[0]->GetShape()[2]),
79 };
80 TosaReshapeAttribute reshapeAttr1(reshapeDims1);
81 auto* reshapeOp1 = new TosaSerializationOperator(Op_RESHAPE,
82 Attribute_ReshapeAttribute,
83 &reshapeAttr1,
84 {inputName},
85 {outputReshapeName});
86 operators.push_back(reshapeOp1);
87 tensors.push_back(new TosaSerializationTensor(outputReshapeName, reshapeDims1, inputDType0, {}));
88
89 std::vector<int32_t> mappings {0, 1, 3, 2, 4, 5};
90 std::vector<int32_t> transposeShape
91 {
92 static_cast<int32_t>(reshapeDims1[0]),
93 static_cast<int32_t>(reshapeDims1[1]),
94 static_cast<int32_t>(reshapeDims1[3]),
95 static_cast<int32_t>(reshapeDims1[2]),
96 static_cast<int32_t>(reshapeDims1[4]),
97 static_cast<int32_t>(reshapeDims1[5])
98 };
99 TosaTransposeAttribute transposeAttr(mappings);
100 auto* transposeOp = new TosaSerializationOperator(Op_TRANSPOSE,
101 Attribute_TransposeAttribute,
102 &transposeAttr,
103 {outputReshapeName},
104 {outputTransposeName});
105 operators.push_back(transposeOp);
106 tensors.push_back(new TosaSerializationTensor(outputTransposeName, transposeShape, outputDType0, {}));
107
108 std::vector<int32_t> reshapeDims2
109 {
110 static_cast<int32_t>(inputs[0]->GetShape()[0]),
111 static_cast<int32_t
>(inputs[0]->GetShape()[1] * descriptor->
m_BlockSize),
112 static_cast<int32_t
>(inputs[0]->GetShape()[2] * descriptor->
m_BlockSize),
114 };
115 TosaReshapeAttribute reshapeAttr2(reshapeDims2);
116 auto* reshapeOp2 = new TosaSerializationOperator(Op_RESHAPE,
117 Attribute_ReshapeAttribute,
118 &reshapeAttr2,
119 {outputTransposeName},
120 {outputName});
121 operators.push_back(reshapeOp2);
123 tensors.push_back(new TosaSerializationTensor(outputName, outputShape0, outputDType0, {}));
124
125 return new TosaSerializationBasicBlock(blockName,
127 operators,
128 tensors,
129 {inputName},
130 {outputName});
131}
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 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.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
unsigned int m_BlockSize
Scalar specifying the input block size. It must be >= 1.