15 using namespace armcomputetensorutils;
26 arm_compute::LSTMParams<arm_compute::ITensor> qLstmParams;
29 m_InputToForgetWeightsTensor = std::make_unique<arm_compute::Tensor>();
32 m_InputToCellWeightsTensor = std::make_unique<arm_compute::Tensor>();
35 m_InputToOutputWeightsTensor = std::make_unique<arm_compute::Tensor>();
38 m_RecurrentToForgetWeightsTensor = std::make_unique<arm_compute::Tensor>();
41 m_RecurrentToCellWeightsTensor = std::make_unique<arm_compute::Tensor>();
44 m_RecurrentToOutputWeightsTensor = std::make_unique<arm_compute::Tensor>();
47 m_ForgetGateBiasTensor = std::make_unique<arm_compute::Tensor>();
50 m_CellBiasTensor = std::make_unique<arm_compute::Tensor>();
53 m_OutputGateBiasTensor = std::make_unique<arm_compute::Tensor>();
59 m_CellToInputWeightsTensor = std::make_unique<arm_compute::Tensor>();
67 m_CellToForgetWeightsTensor = std::make_unique<arm_compute::Tensor>();
70 m_CellToOutputWeightsTensor = std::make_unique<arm_compute::Tensor>();
74 qLstmParams.set_peephole_params(m_CellToForgetWeightsTensor.get(),
75 m_CellToOutputWeightsTensor.get());
80 m_ProjectionWeightsTensor = std::make_unique<arm_compute::Tensor>();
83 m_ProjectionBiasTensor = std::make_unique<arm_compute::Tensor>();
90 qLstmParams.set_projection_params(
91 m_ProjectionWeightsTensor.get(),
97 m_InputLayerNormWeightsTensor = std::make_unique<arm_compute::Tensor>();
104 m_ForgetLayerNormWeightsTensor = std::make_unique<arm_compute::Tensor>();
107 m_CellLayerNormWeightsTensor = std::make_unique<arm_compute::Tensor>();
110 m_OutputLayerNormWeightsTensor = std::make_unique<arm_compute::Tensor>();
114 qLstmParams.set_layer_normalization_params(
116 m_ForgetLayerNormWeightsTensor.get(),
117 m_CellLayerNormWeightsTensor.get(),
118 m_OutputLayerNormWeightsTensor.get());
123 m_InputToInputWeightsTensor = std::make_unique<arm_compute::Tensor>();
126 m_RecurrentToInputWeightsTensor = std::make_unique<arm_compute::Tensor>();
129 m_InputGateBiasTensor = std::make_unique<arm_compute::Tensor>();
133 qLstmParams.set_cifg_params(
134 m_InputToInputWeightsTensor.get(),
135 m_RecurrentToInputWeightsTensor.get(),
137 m_InputGateBiasTensor.get());
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(),
232 m_QLstmLayer.prepare();
252 arm_compute::LSTMParams<arm_compute::ITensorInfo> aclParamsInfo;
255 const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
256 const arm_compute::TensorInfo aclOutputStateInInfo = BuildArmComputeTensorInfo(outputStateIn);
257 const arm_compute::TensorInfo aclCellStateInInfo = BuildArmComputeTensorInfo(cellStateIn);
259 const arm_compute::TensorInfo aclOutputStateOutInfo = BuildArmComputeTensorInfo(outputStateOut);
260 const arm_compute::TensorInfo aclCellStateOutInfo = BuildArmComputeTensorInfo(cellStateOut);
261 const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
264 const arm_compute::TensorInfo aclInputToForgetWeightsInfo
266 const arm_compute::TensorInfo aclInputToCellWeightsInfo
268 const arm_compute::TensorInfo aclInputToOutputWeightsInfo
270 const arm_compute::TensorInfo aclRecurrentToForgetWeightsInfo
272 const arm_compute::TensorInfo aclRecurrentToCellWeightsInfo
274 const arm_compute::TensorInfo aclRecurrentToOutputWeightsInfo
276 const arm_compute::TensorInfo aclForgetGateBiasInfo
278 const arm_compute::TensorInfo aclCellBiasInfo
279 = BuildArmComputeTensorInfo(paramsInfo.
GetCellBias());
280 const arm_compute::TensorInfo aclOutputGateBiasInfo
284 arm_compute::TensorInfo aclInputToInputWeightsInfo;
285 arm_compute::TensorInfo aclRecurrentToInputWeightsInfo;
287 arm_compute::TensorInfo aclCellToInputWeightsInfo;
288 arm_compute::TensorInfo aclCellToForgetWeightsInfo;
289 arm_compute::TensorInfo aclCellToOutputWeightsInfo;
291 arm_compute::TensorInfo aclInputGateBiasInfo;
293 arm_compute::TensorInfo aclProjectionWeightsInfo;
294 arm_compute::TensorInfo aclProjectionBiasInfo;
296 arm_compute::TensorInfo aclInputLayerNormWeightsInfo;
297 arm_compute::TensorInfo aclForgetLayerNormWeightsInfo;
298 arm_compute::TensorInfo aclCellLayerNormWeightsInfo;
299 arm_compute::TensorInfo aclOutputLayerNormWeightsInfo;
313 aclParamsInfo.set_peephole_params(&aclCellToForgetWeightsInfo,
314 &aclCellToOutputWeightsInfo);
323 aclProjectionBiasInfo = BuildArmComputeTensorInfo(paramsInfo.
GetProjectionBias());
327 aclParamsInfo.set_projection_params(
328 &aclProjectionWeightsInfo,
344 aclParamsInfo.set_layer_normalization_params(
346 &aclForgetLayerNormWeightsInfo,
347 &aclCellLayerNormWeightsInfo,
348 &aclOutputLayerNormWeightsInfo);
355 aclInputGateBiasInfo = BuildArmComputeTensorInfo(paramsInfo.
GetInputGateBias());
358 aclParamsInfo.set_cifg_params(
359 &aclInputToInputWeightsInfo,
360 &aclRecurrentToInputWeightsInfo,
362 &aclInputGateBiasInfo);
366 aclParamsInfo.set_cell_clip_params(descriptor.
m_CellClip);
375 return arm_compute::NEQLSTMLayer::validate(&aclInputInfo,
376 &aclInputToForgetWeightsInfo,
377 &aclInputToCellWeightsInfo,
378 &aclInputToOutputWeightsInfo,
379 &aclRecurrentToForgetWeightsInfo,
380 &aclRecurrentToCellWeightsInfo,
381 &aclRecurrentToOutputWeightsInfo,
382 &aclForgetGateBiasInfo,
384 &aclOutputGateBiasInfo,
386 &aclOutputStateInInfo,
387 &aclCellStateOutInfo,
388 &aclOutputStateOutInfo,
393 void NeonQLstmWorkload::FreeUnusedTensors()
395 FreeTensorIfUnused(m_InputToInputWeightsTensor);
396 FreeTensorIfUnused(m_InputToForgetWeightsTensor);
397 FreeTensorIfUnused(m_InputToCellWeightsTensor);
398 FreeTensorIfUnused(m_InputToOutputWeightsTensor);
400 FreeTensorIfUnused(m_RecurrentToInputWeightsTensor);
401 FreeTensorIfUnused(m_RecurrentToForgetWeightsTensor);
402 FreeTensorIfUnused(m_RecurrentToCellWeightsTensor);
403 FreeTensorIfUnused(m_RecurrentToOutputWeightsTensor);
405 FreeTensorIfUnused(m_CellToInputWeightsTensor);
406 FreeTensorIfUnused(m_CellToForgetWeightsTensor);
407 FreeTensorIfUnused(m_CellToOutputWeightsTensor);
409 FreeTensorIfUnused(m_InputGateBiasTensor);
410 FreeTensorIfUnused(m_ForgetGateBiasTensor);
411 FreeTensorIfUnused(m_CellBiasTensor);
412 FreeTensorIfUnused(m_OutputGateBiasTensor);
414 FreeTensorIfUnused(m_ProjectionWeightsTensor);
415 FreeTensorIfUnused(m_ProjectionBiasTensor);
417 FreeTensorIfUnused(m_InputLayerNormWeightsTensor);
418 FreeTensorIfUnused(m_ForgetLayerNormWeightsTensor);
419 FreeTensorIfUnused(m_CellLayerNormWeightsTensor);
420 FreeTensorIfUnused(m_OutputLayerNormWeightsTensor);