26 if (inputs[0]->GetNumDimensions() != 4)
31 std::string inputName;
32 std::string outputName = std::string(
"output0_");
37 DType inputDType0 =
ArmNNToDType(inputs[0]->GetDataType());
38 DType outputDType0 =
ArmNNToDType(outputs[0]->GetDataType());
43 inputName =
"input_0";
51 for (uint32_t i = 0; i < inputs.size(); ++i)
60 std::vector<TosaSerializationTensor*> tensors;
61 std::vector<TosaSerializationOperator*> operators;
65 if(inputName.find(
"input_") != std::string::npos)
68 tensors.push_back(
new TosaSerializationTensor(inputName, inputShape0, inputDType0, {}));
71 std::vector<int32_t> reshapeDims1
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]),
80 TosaReshapeAttribute reshapeAttr1(reshapeDims1);
81 auto* reshapeOp1 =
new TosaSerializationOperator(Op_RESHAPE,
82 Attribute_ReshapeAttribute,
86 operators.push_back(reshapeOp1);
87 tensors.push_back(
new TosaSerializationTensor(outputReshapeName, reshapeDims1, inputDType0, {}));
89 std::vector<int32_t> mappings {0, 1, 3, 2, 4, 5};
90 std::vector<int32_t> transposeShape
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])
99 TosaTransposeAttribute transposeAttr(mappings);
100 auto* transposeOp =
new TosaSerializationOperator(Op_TRANSPOSE,
101 Attribute_TransposeAttribute,
104 {outputTransposeName});
105 operators.push_back(transposeOp);
106 tensors.push_back(
new TosaSerializationTensor(outputTransposeName, transposeShape, outputDType0, {}));
108 std::vector<int32_t> reshapeDims2
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),
115 TosaReshapeAttribute reshapeAttr2(reshapeDims2);
116 auto* reshapeOp2 =
new TosaSerializationOperator(Op_RESHAPE,
117 Attribute_ReshapeAttribute,
119 {outputTransposeName},
121 operators.push_back(reshapeOp2);
123 tensors.push_back(
new TosaSerializationTensor(outputName, outputShape0, outputDType0, {}));
125 return new TosaSerializationBasicBlock(blockName,
std::string GenerateUniqueOutputName(const Layer &layer, uint32_t layerSlot=0)
const std::string mainName
DType ArmNNToDType(const DataType &type)
std::vector< int32_t > GetTosaTensorShape(const TensorShape &shape)
std::string GenerateUniqueInputName(const armnn::InputSlot &slot)
std::string GetUniqueTosaMappingID()
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.