15 using namespace armcomputetensorutils;
20 arm_compute::LSTMParams<arm_compute::ITensor> qLstmParams;
23 m_InputToForgetWeightsTensor = std::make_unique<arm_compute::Tensor>();
26 m_InputToCellWeightsTensor = std::make_unique<arm_compute::Tensor>();
29 m_InputToOutputWeightsTensor = std::make_unique<arm_compute::Tensor>();
32 m_RecurrentToForgetWeightsTensor = std::make_unique<arm_compute::Tensor>();
35 m_RecurrentToCellWeightsTensor = std::make_unique<arm_compute::Tensor>();
38 m_RecurrentToOutputWeightsTensor = std::make_unique<arm_compute::Tensor>();
41 m_ForgetGateBiasTensor = std::make_unique<arm_compute::Tensor>();
44 m_CellBiasTensor = std::make_unique<arm_compute::Tensor>();
47 m_OutputGateBiasTensor = std::make_unique<arm_compute::Tensor>();
53 m_CellToInputWeightsTensor = std::make_unique<arm_compute::Tensor>();
61 m_CellToForgetWeightsTensor = std::make_unique<arm_compute::Tensor>();
64 m_CellToOutputWeightsTensor = std::make_unique<arm_compute::Tensor>();
68 qLstmParams.set_peephole_params(m_CellToForgetWeightsTensor.get(),
69 m_CellToOutputWeightsTensor.get());
74 m_ProjectionWeightsTensor = std::make_unique<arm_compute::Tensor>();
77 m_ProjectionBiasTensor = std::make_unique<arm_compute::Tensor>();
84 qLstmParams.set_projection_params(
85 m_ProjectionWeightsTensor.get(),
91 m_InputLayerNormWeightsTensor = std::make_unique<arm_compute::Tensor>();
98 m_ForgetLayerNormWeightsTensor = std::make_unique<arm_compute::Tensor>();
101 m_CellLayerNormWeightsTensor = std::make_unique<arm_compute::Tensor>();
104 m_OutputLayerNormWeightsTensor = std::make_unique<arm_compute::Tensor>();
108 qLstmParams.set_layer_normalization_params(
110 m_ForgetLayerNormWeightsTensor.get(),
111 m_CellLayerNormWeightsTensor.get(),
112 m_OutputLayerNormWeightsTensor.get());
117 m_InputToInputWeightsTensor = std::make_unique<arm_compute::Tensor>();
120 m_RecurrentToInputWeightsTensor = std::make_unique<arm_compute::Tensor>();
123 m_InputGateBiasTensor = std::make_unique<arm_compute::Tensor>();
127 qLstmParams.set_cifg_params(
128 m_InputToInputWeightsTensor.get(),
129 m_RecurrentToInputWeightsTensor.get(),
131 m_InputGateBiasTensor.get());
154 m_QLstmLayer.configure(&input,
155 m_InputToForgetWeightsTensor.get(),
156 m_InputToCellWeightsTensor.get(),
157 m_InputToOutputWeightsTensor.get(),
158 m_RecurrentToForgetWeightsTensor.get(),
159 m_RecurrentToCellWeightsTensor.get(),
160 m_RecurrentToOutputWeightsTensor.get(),
161 m_ForgetGateBiasTensor.get(),
162 m_CellBiasTensor.get(),
163 m_OutputGateBiasTensor.get(),
226 m_QLstmLayer.prepare();
245 arm_compute::LSTMParams<arm_compute::ITensorInfo> aclParamsInfo;
248 const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
249 const arm_compute::TensorInfo aclOutputStateInInfo = BuildArmComputeTensorInfo(outputStateIn);
250 const arm_compute::TensorInfo aclCellStateInInfo = BuildArmComputeTensorInfo(cellStateIn);
252 const arm_compute::TensorInfo aclOutputStateOutInfo = BuildArmComputeTensorInfo(outputStateOut);
253 const arm_compute::TensorInfo aclCellStateOutInfo = BuildArmComputeTensorInfo(cellStateOut);
254 const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
257 const arm_compute::TensorInfo aclInputToForgetWeightsInfo
259 const arm_compute::TensorInfo aclInputToCellWeightsInfo
261 const arm_compute::TensorInfo aclInputToOutputWeightsInfo
263 const arm_compute::TensorInfo aclRecurrentToForgetWeightsInfo
265 const arm_compute::TensorInfo aclRecurrentToCellWeightsInfo
267 const arm_compute::TensorInfo aclRecurrentToOutputWeightsInfo
269 const arm_compute::TensorInfo aclForgetGateBiasInfo
271 const arm_compute::TensorInfo aclCellBiasInfo
272 = BuildArmComputeTensorInfo(paramsInfo.
GetCellBias());
273 const arm_compute::TensorInfo aclOutputGateBiasInfo
277 arm_compute::TensorInfo aclInputToInputWeightsInfo;
278 arm_compute::TensorInfo aclRecurrentToInputWeightsInfo;
280 arm_compute::TensorInfo aclCellToInputWeightsInfo;
281 arm_compute::TensorInfo aclCellToForgetWeightsInfo;
282 arm_compute::TensorInfo aclCellToOutputWeightsInfo;
284 arm_compute::TensorInfo aclInputGateBiasInfo;
286 arm_compute::TensorInfo aclProjectionWeightsInfo;
287 arm_compute::TensorInfo aclProjectionBiasInfo;
289 arm_compute::TensorInfo aclInputLayerNormWeightsInfo;
290 arm_compute::TensorInfo aclForgetLayerNormWeightsInfo;
291 arm_compute::TensorInfo aclCellLayerNormWeightsInfo;
292 arm_compute::TensorInfo aclOutputLayerNormWeightsInfo;
306 aclParamsInfo.set_peephole_params(&aclCellToForgetWeightsInfo,
307 &aclCellToOutputWeightsInfo);
316 aclProjectionBiasInfo = BuildArmComputeTensorInfo(paramsInfo.
GetProjectionBias());
320 aclParamsInfo.set_projection_params(
321 &aclProjectionWeightsInfo,
337 aclParamsInfo.set_layer_normalization_params(
339 &aclForgetLayerNormWeightsInfo,
340 &aclCellLayerNormWeightsInfo,
341 &aclOutputLayerNormWeightsInfo);
348 aclInputGateBiasInfo = BuildArmComputeTensorInfo(paramsInfo.
GetInputGateBias());
351 aclParamsInfo.set_cifg_params(
352 &aclInputToInputWeightsInfo,
353 &aclRecurrentToInputWeightsInfo,
355 &aclInputGateBiasInfo);
359 aclParamsInfo.set_cell_clip_params(descriptor.
m_CellClip);
368 return arm_compute::NEQLSTMLayer::validate(&aclInputInfo,
369 &aclInputToForgetWeightsInfo,
370 &aclInputToCellWeightsInfo,
371 &aclInputToOutputWeightsInfo,
372 &aclRecurrentToForgetWeightsInfo,
373 &aclRecurrentToCellWeightsInfo,
374 &aclRecurrentToOutputWeightsInfo,
375 &aclForgetGateBiasInfo,
377 &aclOutputGateBiasInfo,
379 &aclOutputStateInInfo,
380 &aclCellStateOutInfo,
381 &aclOutputStateOutInfo,
386 void NeonQLstmWorkload::FreeUnusedTensors()
388 FreeTensorIfUnused(m_InputToInputWeightsTensor);
389 FreeTensorIfUnused(m_InputToForgetWeightsTensor);
390 FreeTensorIfUnused(m_InputToCellWeightsTensor);
391 FreeTensorIfUnused(m_InputToOutputWeightsTensor);
393 FreeTensorIfUnused(m_RecurrentToInputWeightsTensor);
394 FreeTensorIfUnused(m_RecurrentToForgetWeightsTensor);
395 FreeTensorIfUnused(m_RecurrentToCellWeightsTensor);
396 FreeTensorIfUnused(m_RecurrentToOutputWeightsTensor);
398 FreeTensorIfUnused(m_CellToInputWeightsTensor);
399 FreeTensorIfUnused(m_CellToForgetWeightsTensor);
400 FreeTensorIfUnused(m_CellToOutputWeightsTensor);
402 FreeTensorIfUnused(m_InputGateBiasTensor);
403 FreeTensorIfUnused(m_ForgetGateBiasTensor);
404 FreeTensorIfUnused(m_CellBiasTensor);
405 FreeTensorIfUnused(m_OutputGateBiasTensor);
407 FreeTensorIfUnused(m_ProjectionWeightsTensor);
408 FreeTensorIfUnused(m_ProjectionBiasTensor);
410 FreeTensorIfUnused(m_InputLayerNormWeightsTensor);
411 FreeTensorIfUnused(m_ForgetLayerNormWeightsTensor);
412 FreeTensorIfUnused(m_CellLayerNormWeightsTensor);
413 FreeTensorIfUnused(m_OutputLayerNormWeightsTensor);
const ConstCpuTensorHandle * m_CellToForgetWeights
NeonQLstmWorkload(const QLstmQueueDescriptor &descriptor, const WorkloadInfo &info)
const ConstCpuTensorHandle * m_ProjectionWeights
bool m_PeepholeEnabled
Enable/disable peephole.
const ConstCpuTensorHandle * m_ProjectionBias
float m_HiddenStateScale
Hidden State quantization scale.
const ConstCpuTensorHandle * m_ForgetLayerNormWeights
const QLstmQueueDescriptor m_Data
float m_OutputIntermediateScale
Output intermediate quantization scale.
const ConstCpuTensorHandle * m_CellLayerNormWeights
const ConstCpuTensorHandle * m_RecurrentToCellWeights
const ConstCpuTensorHandle * m_RecurrentToInputWeights
arm_compute::Status NeonQLstmWorkloadValidate(const TensorInfo &input, const TensorInfo &cellStateIn, const TensorInfo &outputStateIn, const TensorInfo &cellStateOut, const TensorInfo &outputStateOut, const TensorInfo &output, const QLstmDescriptor &descriptor, const LstmInputParamsInfo ¶msInfo)
const ConstCpuTensorHandle * m_OutputGateBias
const ConstCpuTensorHandle * m_CellBias
Copyright (c) 2020 ARM Limited.
LayerDescriptor m_Parameters
virtual void Execute() const override
const ConstCpuTensorHandle * m_CellToOutputWeights
const ConstCpuTensorHandle * m_OutputLayerNormWeights
bool m_LayerNormEnabled
Enable/disable layer normalization.
const ConstCpuTensorHandle * m_InputToForgetWeights
float m_ProjectionClip
Clipping threshold value for the projection.
float m_InputIntermediateScale
Input intermediate quantization scale.
A QLstmDescriptor for the QLstmLayer.
float m_ForgetIntermediateScale
Forget intermediate quantization scale.
void InitializeArmComputeTensorData(arm_compute::Tensor &tensor, const ConstCpuTensorHandle *handle)
const ConstCpuTensorHandle * m_CellToInputWeights
float m_CellClip
Clipping threshold value for the cell state.
const ConstCpuTensorHandle * m_RecurrentToOutputWeights
std::vector< ITensorHandle * > m_Outputs
bool m_ProjectionEnabled
Enable/disable the projection layer.
const ConstCpuTensorHandle * m_InputGateBias
Contains information about inputs and outputs to a layer.
std::vector< ITensorHandle * > m_Inputs
const ConstCpuTensorHandle * m_InputLayerNormWeights
const ConstCpuTensorHandle * m_RecurrentToForgetWeights
const ConstCpuTensorHandle * m_ForgetGateBias
float m_CellIntermediateScale
Cell intermediate quantization scale.
const ConstCpuTensorHandle * m_InputToOutputWeights
bool m_CifgEnabled
Enable/disable CIFG (coupled input & forget gate).
const TensorInfo & GetTensorInfo() const
const ConstCpuTensorHandle * m_InputToInputWeights
int32_t m_HiddenStateZeroPoint
Hidden State zero point.
const ConstCpuTensorHandle * m_InputToCellWeights