18 : NeonBaseWorkload<QLstmQueueDescriptor>(descriptor, info)
19{
20
22 descriptor.m_Parameters,
23 info,
24 this->GetGuid());
25
26 arm_compute::LSTMParams<arm_compute::ITensor> qLstmParams;
27
28
29 m_InputToForgetWeightsTensor = std::make_unique<arm_compute::Tensor>();
30 BuildArmComputeTensor(*m_InputToForgetWeightsTensor, m_Data.m_InputToForgetWeights->GetTensorInfo());
31
32 m_InputToCellWeightsTensor = std::make_unique<arm_compute::Tensor>();
33 BuildArmComputeTensor(*m_InputToCellWeightsTensor, m_Data.m_InputToCellWeights->GetTensorInfo());
34
35 m_InputToOutputWeightsTensor = std::make_unique<arm_compute::Tensor>();
36 BuildArmComputeTensor(*m_InputToOutputWeightsTensor, m_Data.m_InputToOutputWeights->GetTensorInfo());
37
38 m_RecurrentToForgetWeightsTensor = std::make_unique<arm_compute::Tensor>();
39 BuildArmComputeTensor(*m_RecurrentToForgetWeightsTensor, m_Data.m_RecurrentToForgetWeights->GetTensorInfo());
40
41 m_RecurrentToCellWeightsTensor = std::make_unique<arm_compute::Tensor>();
42 BuildArmComputeTensor(*m_RecurrentToCellWeightsTensor, m_Data.m_RecurrentToCellWeights->GetTensorInfo());
43
44 m_RecurrentToOutputWeightsTensor = std::make_unique<arm_compute::Tensor>();
45 BuildArmComputeTensor(*m_RecurrentToOutputWeightsTensor, m_Data.m_RecurrentToOutputWeights->GetTensorInfo());
46
47 m_ForgetGateBiasTensor = std::make_unique<arm_compute::Tensor>();
48 BuildArmComputeTensor(*m_ForgetGateBiasTensor, m_Data.m_ForgetGateBias->GetTensorInfo());
49
50 m_CellBiasTensor = std::make_unique<arm_compute::Tensor>();
51 BuildArmComputeTensor(*m_CellBiasTensor, m_Data.m_CellBias->GetTensorInfo());
52
53 m_OutputGateBiasTensor = std::make_unique<arm_compute::Tensor>();
54 BuildArmComputeTensor(*m_OutputGateBiasTensor, m_Data.m_OutputGateBias->GetTensorInfo());
55
56
57 if (m_Data.m_Parameters.m_PeepholeEnabled)
58 {
59 m_CellToInputWeightsTensor = std::make_unique<arm_compute::Tensor>();
60
61 if (!m_Data.m_Parameters.m_CifgEnabled)
62 {
63
64 BuildArmComputeTensor(*m_CellToInputWeightsTensor, m_Data.m_CellToInputWeights->GetTensorInfo());
65 }
66
67 m_CellToForgetWeightsTensor = std::make_unique<arm_compute::Tensor>();
68 BuildArmComputeTensor(*m_CellToForgetWeightsTensor, m_Data.m_CellToForgetWeights->GetTensorInfo());
69
70 m_CellToOutputWeightsTensor = std::make_unique<arm_compute::Tensor>();
71 BuildArmComputeTensor(*m_CellToOutputWeightsTensor, m_Data.m_CellToOutputWeights->GetTensorInfo());
72
73
74 qLstmParams.set_peephole_params(m_CellToForgetWeightsTensor.get(),
75 m_CellToOutputWeightsTensor.get());
76 }
77
78 if (m_Data.m_Parameters.m_ProjectionEnabled)
79 {
80 m_ProjectionWeightsTensor = std::make_unique<arm_compute::Tensor>();
81 BuildArmComputeTensor(*m_ProjectionWeightsTensor, m_Data.m_ProjectionWeights->GetTensorInfo());
82
83 m_ProjectionBiasTensor = std::make_unique<arm_compute::Tensor>();
84 if (m_Data.m_ProjectionBias != nullptr)
85 {
86 BuildArmComputeTensor(*m_ProjectionBiasTensor, m_Data.m_ProjectionBias->GetTensorInfo());
87 }
88
89
90 qLstmParams.set_projection_params(
91 m_ProjectionWeightsTensor.get(),
92 m_Data.m_ProjectionBias != nullptr ? m_ProjectionBiasTensor.get() : nullptr);
93 }
94
95 if (m_Data.m_Parameters.m_LayerNormEnabled)
96 {
97 m_InputLayerNormWeightsTensor = std::make_unique<arm_compute::Tensor>();
98
99 if (!m_Data.m_Parameters.m_CifgEnabled)
100 {
101 BuildArmComputeTensor(*m_InputLayerNormWeightsTensor, m_Data.m_InputLayerNormWeights->GetTensorInfo());
102 }
103
104 m_ForgetLayerNormWeightsTensor = std::make_unique<arm_compute::Tensor>();
105 BuildArmComputeTensor(*m_ForgetLayerNormWeightsTensor, m_Data.m_ForgetLayerNormWeights->GetTensorInfo());
106
107 m_CellLayerNormWeightsTensor = std::make_unique<arm_compute::Tensor>();
108 BuildArmComputeTensor(*m_CellLayerNormWeightsTensor, m_Data.m_CellLayerNormWeights->GetTensorInfo());
109
110 m_OutputLayerNormWeightsTensor = std::make_unique<arm_compute::Tensor>();
111 BuildArmComputeTensor(*m_OutputLayerNormWeightsTensor, m_Data.m_OutputLayerNormWeights->GetTensorInfo());
112
113
114 qLstmParams.set_layer_normalization_params(
115 m_Data.m_InputLayerNormWeights != nullptr ? m_InputLayerNormWeightsTensor.get() : nullptr,
116 m_ForgetLayerNormWeightsTensor.get(),
117 m_CellLayerNormWeightsTensor.get(),
118 m_OutputLayerNormWeightsTensor.get());
119 }
120
121 if (!m_Data.m_Parameters.m_CifgEnabled)
122 {
123 m_InputToInputWeightsTensor = std::make_unique<arm_compute::Tensor>();
124 BuildArmComputeTensor(*m_InputToInputWeightsTensor, m_Data.m_InputToInputWeights->GetTensorInfo());
125
126 m_RecurrentToInputWeightsTensor = std::make_unique<arm_compute::Tensor>();
127 BuildArmComputeTensor(*m_RecurrentToInputWeightsTensor, m_Data.m_RecurrentToInputWeights->GetTensorInfo());
128
129 m_InputGateBiasTensor = std::make_unique<arm_compute::Tensor>();
130 BuildArmComputeTensor(*m_InputGateBiasTensor, m_Data.m_InputGateBias->GetTensorInfo());
131
132
133 qLstmParams.set_cifg_params(
134 m_InputToInputWeightsTensor.get(),
135 m_RecurrentToInputWeightsTensor.get(),
136 m_Data.m_CellToInputWeights != nullptr ? m_CellToInputWeightsTensor.get() : nullptr,
137 m_InputGateBiasTensor.get());
138 }
139
140
141 const arm_compute::ITensor& input = static_cast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
142 arm_compute::ITensor& outputStateIn = static_cast<IAclTensorHandle*>(m_Data.m_Inputs[1])->GetTensor();
143 const arm_compute::ITensor& cellStateIn = static_cast<IAclTensorHandle*>(m_Data.m_Inputs[2])->GetTensor();
144
145 arm_compute::ITensor& outputStateOut = static_cast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
146 arm_compute::ITensor& cellStateOut = static_cast<IAclTensorHandle*>(m_Data.m_Outputs[1])->GetTensor();
147 arm_compute::ITensor& output = static_cast<IAclTensorHandle*>(m_Data.m_Outputs[2])->GetTensor();
148
149
150 qLstmParams.set_cell_clip_params(m_Data.m_Parameters.m_CellClip);
151 qLstmParams.set_projection_clip_params(m_Data.m_Parameters.m_ProjectionClip);
152 qLstmParams.set_hidden_state_params(m_Data.m_Parameters.m_HiddenStateZeroPoint,
153 m_Data.m_Parameters.m_HiddenStateScale);
154 qLstmParams.set_matmul_scale_params(m_Data.m_Parameters.m_InputIntermediateScale,
155 m_Data.m_Parameters.m_ForgetIntermediateScale,
156 m_Data.m_Parameters.m_CellIntermediateScale,
157 m_Data.m_Parameters.m_OutputIntermediateScale);
158
159
160 m_QLstmLayer.configure(&input,
161 m_InputToForgetWeightsTensor.get(),
162 m_InputToCellWeightsTensor.get(),
163 m_InputToOutputWeightsTensor.get(),
164 m_RecurrentToForgetWeightsTensor.get(),
165 m_RecurrentToCellWeightsTensor.get(),
166 m_RecurrentToOutputWeightsTensor.get(),
167 m_ForgetGateBiasTensor.get(),
168 m_CellBiasTensor.get(),
169 m_OutputGateBiasTensor.get(),
170 &cellStateIn,
171 &outputStateIn,
172 &cellStateOut,
173 &outputStateOut,
174 &output,
175 qLstmParams);
176
177
181
185
189
190
191 if (!m_Data.m_Parameters.m_CifgEnabled)
192 {
196 }
197
198 if (m_Data.m_Parameters.m_ProjectionEnabled)
199 {
201
202 if (m_Data.m_ProjectionBias != nullptr)
203 {
205 }
206 }
207
208 if (m_Data.m_Parameters.m_PeepholeEnabled)
209 {
210 if (!m_Data.m_Parameters.m_CifgEnabled)
211 {
213 }
214
217 }
218
219 if (m_Data.m_Parameters.m_LayerNormEnabled)
220 {
221 if (!m_Data.m_Parameters.m_CifgEnabled)
222 {
224 }
225
229 }
230
231
232 m_QLstmLayer.prepare();
233
234 FreeUnusedTensors();
235}
#define ARMNN_REPORT_PROFILING_WORKLOAD_DESC(name, desc, infos, guid)
void InitializeArmComputeTensorData(arm_compute::Tensor &tensor, TensorInfo tensorInfo, const ITensorHandle *handle)