ArmNN
 21.02
ClLstmFloatWorkload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
7 #include <cl/ClTensorHandle.hpp>
9 #include <cl/ClLayerSupport.hpp>
11 
13 
14 #include <arm_compute/runtime/CL/functions/CLLSTMLayer.h>
15 
16 #include "ClWorkloadUtils.hpp"
17 
18 namespace armnn
19 {
20 using namespace armcomputetensorutils;
21 
23  const WorkloadInfo &info,
24  const arm_compute::CLCompileContext& clCompileContext)
25  : FloatWorkload<LstmQueueDescriptor>(descriptor, info)
26 {
27  arm_compute::LSTMParams<arm_compute::ICLTensor> lstm_param;
28 
29  // Basic parameters
30  m_InputToForgetWeightsTensor = std::make_unique<arm_compute::CLTensor>();
31  BuildArmComputeTensor(*m_InputToForgetWeightsTensor, m_Data.m_InputToForgetWeights->GetTensorInfo());
32 
33  m_InputToCellWeightsTensor = std::make_unique<arm_compute::CLTensor>();
34  BuildArmComputeTensor(*m_InputToCellWeightsTensor, m_Data.m_InputToCellWeights->GetTensorInfo());
35 
36  m_InputToOutputWeightsTensor = std::make_unique<arm_compute::CLTensor>();
37  BuildArmComputeTensor(*m_InputToOutputWeightsTensor, m_Data.m_InputToOutputWeights->GetTensorInfo());
38 
39  m_RecurrentToForgetWeightsTensor = std::make_unique<arm_compute::CLTensor>();
40  BuildArmComputeTensor(*m_RecurrentToForgetWeightsTensor, m_Data.m_RecurrentToForgetWeights->GetTensorInfo());
41 
42  m_RecurrentToCellWeightsTensor = std::make_unique<arm_compute::CLTensor>();
43  BuildArmComputeTensor(*m_RecurrentToCellWeightsTensor, m_Data.m_RecurrentToCellWeights->GetTensorInfo());
44 
45  m_RecurrentToOutputWeightsTensor = std::make_unique<arm_compute::CLTensor>();
46  BuildArmComputeTensor(*m_RecurrentToOutputWeightsTensor, m_Data.m_RecurrentToOutputWeights->GetTensorInfo());
47 
48  m_ForgetGateBiasTensor = std::make_unique<arm_compute::CLTensor>();
49  BuildArmComputeTensor(*m_ForgetGateBiasTensor, m_Data.m_ForgetGateBias->GetTensorInfo());
50 
51  m_CellBiasTensor = std::make_unique<arm_compute::CLTensor>();
52  BuildArmComputeTensor(*m_CellBiasTensor, m_Data.m_CellBias->GetTensorInfo());
53 
54  m_OutputGateBiasTensor = std::make_unique<arm_compute::CLTensor>();
55  BuildArmComputeTensor(*m_OutputGateBiasTensor, m_Data.m_OutputGateBias->GetTensorInfo());
56 
57  // for future reference: check the AndroidNN API for the logic here
58  if (!m_Data.m_Parameters.m_CifgEnabled)
59  {
60  m_InputToInputWeightsTensor = std::make_unique<arm_compute::CLTensor>();
61  BuildArmComputeTensor(*m_InputToInputWeightsTensor, m_Data.m_InputToInputWeights->GetTensorInfo());
62 
63  m_RecurrentToInputWeightsTensor = std::make_unique<arm_compute::CLTensor>();
64  BuildArmComputeTensor(*m_RecurrentToInputWeightsTensor, m_Data.m_RecurrentToInputWeights->GetTensorInfo());
65 
66  m_CellToInputWeightsTensor = std::make_unique<arm_compute::CLTensor>();
67  if (m_Data.m_CellToInputWeights != nullptr)
68  {
69  BuildArmComputeTensor(*m_CellToInputWeightsTensor, m_Data.m_CellToInputWeights->GetTensorInfo());
70  }
71 
72  m_InputGateBiasTensor = std::make_unique<arm_compute::CLTensor>();
73  BuildArmComputeTensor(*m_InputGateBiasTensor, m_Data.m_InputGateBias->GetTensorInfo());
74 
75  lstm_param.set_cifg_params(m_InputToInputWeightsTensor.get(),
76  m_RecurrentToInputWeightsTensor.get(),
77  m_Data.m_CellToInputWeights != nullptr ? m_CellToInputWeightsTensor.get() : nullptr,
78  m_InputGateBiasTensor.get());
79  }
80 
81  if (m_Data.m_Parameters.m_ProjectionEnabled)
82  {
83  m_ProjectionWeightsTensor = std::make_unique<arm_compute::CLTensor>();
84  BuildArmComputeTensor(*m_ProjectionWeightsTensor, m_Data.m_ProjectionWeights->GetTensorInfo());
85 
86  m_ProjectionBiasTensor = std::make_unique<arm_compute::CLTensor>();
87  if (m_Data.m_ProjectionBias != nullptr)
88  {
89  BuildArmComputeTensor(*m_ProjectionBiasTensor, m_Data.m_ProjectionBias->GetTensorInfo());
90  }
91 
92  lstm_param.set_projection_params(m_ProjectionWeightsTensor.get(),
93  m_Data.m_ProjectionBias != nullptr ? m_ProjectionBiasTensor.get() : nullptr);
94  }
95 
96  if (m_Data.m_Parameters.m_PeepholeEnabled)
97  {
98  m_CellToForgetWeightsTensor = std::make_unique<arm_compute::CLTensor>();
99  BuildArmComputeTensor(*m_CellToForgetWeightsTensor, m_Data.m_CellToForgetWeights->GetTensorInfo());
100 
101  m_CellToOutputWeightsTensor = std::make_unique<arm_compute::CLTensor>();
102  BuildArmComputeTensor(*m_CellToOutputWeightsTensor, m_Data.m_CellToOutputWeights->GetTensorInfo());
103 
104  lstm_param.set_peephole_params(m_CellToForgetWeightsTensor.get(), m_CellToOutputWeightsTensor.get());
105  }
106 
107  if (m_Data.m_Parameters.m_LayerNormEnabled)
108  {
109  m_InputLayerNormWeightsTensor = std::make_unique<arm_compute::CLTensor>();
110  m_ForgetLayerNormWeightsTensor = std::make_unique<arm_compute::CLTensor>();
111  m_CellLayerNormWeightsTensor = std::make_unique<arm_compute::CLTensor>();
112  m_OutputLayerNormWeightsTensor = std::make_unique<arm_compute::CLTensor>();
113 
114  if (!m_Data.m_Parameters.m_CifgEnabled)
115  {
116  BuildArmComputeTensor(*m_InputLayerNormWeightsTensor, m_Data.m_InputLayerNormWeights->GetTensorInfo());
117  }
118  BuildArmComputeTensor(*m_ForgetLayerNormWeightsTensor, m_Data.m_ForgetLayerNormWeights->GetTensorInfo());
119  BuildArmComputeTensor(*m_CellLayerNormWeightsTensor, m_Data.m_CellLayerNormWeights->GetTensorInfo());
120  BuildArmComputeTensor(*m_OutputLayerNormWeightsTensor, m_Data.m_OutputLayerNormWeights->GetTensorInfo());
121 
122  lstm_param.set_layer_normalization_params(m_Data.m_Parameters.m_CifgEnabled ? nullptr :
123  m_InputLayerNormWeightsTensor.get(),
124  m_ForgetLayerNormWeightsTensor.get(),
125  m_CellLayerNormWeightsTensor.get(),
126  m_OutputLayerNormWeightsTensor.get());
127  }
128 
129  const arm_compute::ICLTensor& input = static_cast<IClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
130  const arm_compute::ICLTensor& output_state_in = static_cast<IClTensorHandle*>(m_Data.m_Inputs[1])->GetTensor();
131  arm_compute::ICLTensor& cell_state_in = static_cast<IClTensorHandle*>(m_Data.m_Inputs[2])->GetTensor();
132 
133  arm_compute::ICLTensor& output_state_out = static_cast<IClTensorHandle*>(m_Data.m_Outputs[1])->GetTensor();
134  arm_compute::ICLTensor& cell_state_out = static_cast<IClTensorHandle*>(m_Data.m_Outputs[2])->GetTensor();
135  arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(m_Data.m_Outputs[3])->GetTensor();
136 
137  // Get the batch_size and the num_units from the cellStateIn dimensions
138  const TensorInfo& inputTensorInfo = info.m_InputTensorInfos[2];
139  const unsigned int batch_size = armnn::numeric_cast<unsigned int>(inputTensorInfo.GetShape()[0]);
140  const unsigned int num_units = armnn::numeric_cast<unsigned int>(inputTensorInfo.GetShape()[1]);
141 
142  m_ScratchBuffer = std::make_unique<arm_compute::CLTensor>();
143  if (m_Data.m_Parameters.m_CifgEnabled)
144  {
145  // 2D tensor with dimensions [num_units * 3, batch_size] with CIFG
146  armnn::TensorInfo scratchBuffer1({ batch_size, num_units * 3 }, DataType::Float32);
147  BuildArmComputeTensor(*m_ScratchBuffer, scratchBuffer1);
148  }
149  else
150  {
151  // scratch_buffer [num_units * 4, batch_size] without CIFG
152  armnn::TensorInfo scratchBuffer2({ batch_size, num_units * 4 }, DataType::Float32);
153  BuildArmComputeTensor(*m_ScratchBuffer, scratchBuffer2);
154  }
155 
156  float cell_threshold = m_Data.m_Parameters.m_ClippingThresCell;
157  float projection_threshold = m_Data.m_Parameters.m_ClippingThresProj;
158 
159  // for preparing the object for the class ActivationLayerInfo, we need to consider 5 situations
160  arm_compute::ActivationLayerInfo activationLayerInfo;
161  if (m_Data.m_Parameters.m_ActivationFunc == 0)
162  {
163  // no activation, do nothing
164  }
165  else if (m_Data.m_Parameters.m_ActivationFunc == 1)
166  {
167  activationLayerInfo = arm_compute::ActivationLayerInfo(
168  arm_compute::ActivationLayerInfo::ActivationFunction::RELU);
169  }
170  else if (m_Data.m_Parameters.m_ActivationFunc == 3)
171  {
172  activationLayerInfo = arm_compute::ActivationLayerInfo(
173  arm_compute::ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, 6.0);
174  }
175  else if (m_Data.m_Parameters.m_ActivationFunc == 4)
176  {
177  activationLayerInfo = arm_compute::ActivationLayerInfo(
178  arm_compute::ActivationLayerInfo::ActivationFunction::TANH, 1.0, 1.0);
179  }
180  else if (m_Data.m_Parameters.m_ActivationFunc == 6)
181  {
182  activationLayerInfo = arm_compute::ActivationLayerInfo(
183  arm_compute::ActivationLayerInfo::ActivationFunction::LOGISTIC);
184  }
185  else
186  {
187  throw armnn::Exception("Wrong Type of Activation Function!");
188  }
189 
190  m_LstmLayer.configure(clCompileContext, &input, m_InputToForgetWeightsTensor.get(),
191  m_InputToCellWeightsTensor.get(), m_InputToOutputWeightsTensor.get(),
192  m_RecurrentToForgetWeightsTensor.get(), m_RecurrentToCellWeightsTensor.get(),
193  m_RecurrentToOutputWeightsTensor.get(), m_ForgetGateBiasTensor.get(),
194  m_CellBiasTensor.get(), m_OutputGateBiasTensor.get(), &output_state_in,
195  &cell_state_in, m_ScratchBuffer.get(), &output_state_out,
196  &cell_state_out, &output, lstm_param, activationLayerInfo,
197  cell_threshold, projection_threshold);
198 
199  armcomputetensorutils::InitialiseArmComputeTensorEmpty(*m_ScratchBuffer);
200 
201  InitializeArmComputeClTensorData(*m_InputToForgetWeightsTensor, m_Data.m_InputToForgetWeights);
202  InitializeArmComputeClTensorData(*m_InputToCellWeightsTensor, m_Data.m_InputToCellWeights);
203  InitializeArmComputeClTensorData(*m_InputToOutputWeightsTensor, m_Data.m_InputToOutputWeights);
204  InitializeArmComputeClTensorData(*m_RecurrentToForgetWeightsTensor, m_Data.m_RecurrentToForgetWeights);
205  InitializeArmComputeClTensorData(*m_RecurrentToCellWeightsTensor, m_Data.m_RecurrentToCellWeights);
206  InitializeArmComputeClTensorData(*m_RecurrentToOutputWeightsTensor, m_Data.m_RecurrentToOutputWeights);
207  InitializeArmComputeClTensorData(*m_ForgetGateBiasTensor, m_Data.m_ForgetGateBias);
208  InitializeArmComputeClTensorData(*m_CellBiasTensor, m_Data.m_CellBias);
209  InitializeArmComputeClTensorData(*m_OutputGateBiasTensor, m_Data.m_OutputGateBias);
210 
211  if (!m_Data.m_Parameters.m_CifgEnabled)
212  {
213  InitializeArmComputeClTensorData(*m_InputToInputWeightsTensor, m_Data.m_InputToInputWeights);
214  InitializeArmComputeClTensorData(*m_RecurrentToInputWeightsTensor, m_Data.m_RecurrentToInputWeights);
215  if (m_Data.m_CellToInputWeights != nullptr)
216  {
217  InitializeArmComputeClTensorData(*m_CellToInputWeightsTensor, m_Data.m_CellToInputWeights);
218  }
219  InitializeArmComputeClTensorData(*m_InputGateBiasTensor, m_Data.m_InputGateBias);
220  }
221 
222  if (m_Data.m_Parameters.m_ProjectionEnabled)
223  {
224  InitializeArmComputeClTensorData(*m_ProjectionWeightsTensor, m_Data.m_ProjectionWeights);
225  if (m_Data.m_ProjectionBias != nullptr)
226  {
227  InitializeArmComputeClTensorData(*m_ProjectionBiasTensor, m_Data.m_ProjectionBias);
228  }
229  }
230 
231  if (m_Data.m_Parameters.m_PeepholeEnabled)
232  {
233  InitializeArmComputeClTensorData(*m_CellToForgetWeightsTensor, m_Data.m_CellToForgetWeights);
234  InitializeArmComputeClTensorData(*m_CellToOutputWeightsTensor, m_Data.m_CellToOutputWeights);
235  }
236 
237  if (m_Data.m_Parameters.m_LayerNormEnabled)
238  {
239  if (!m_Data.m_Parameters.m_CifgEnabled)
240  {
241  InitializeArmComputeClTensorData(*m_InputLayerNormWeightsTensor, m_Data.m_InputLayerNormWeights);
242  }
243 
244  InitializeArmComputeClTensorData(*m_ForgetLayerNormWeightsTensor, m_Data.m_ForgetLayerNormWeights);
245  InitializeArmComputeClTensorData(*m_CellLayerNormWeightsTensor, m_Data.m_CellLayerNormWeights);
246  InitializeArmComputeClTensorData(*m_OutputLayerNormWeightsTensor, m_Data.m_OutputLayerNormWeights);
247  }
248 
249  // Force Compute Library to perform the necessary copying and reshaping, after which
250  // delete all the input tensors that will no longer be needed
251  m_LstmLayer.prepare();
252  FreeUnusedTensors();
253 }
254 
256 {
257  ARMNN_SCOPED_PROFILING_EVENT_CL("ClLstmFloatWorkload_Execute");
258  RunClFunction(m_LstmLayer, CHECK_LOCATION());
259 }
260 
262  const TensorInfo& cellStateIn, const TensorInfo& scratchBuffer,
263  const TensorInfo& outputStateOut, const TensorInfo& cellStateOut,
264  const TensorInfo& output, const LstmDescriptor& descriptor,
265  const LstmInputParamsInfo& paramsInfo)
266 {
267  arm_compute::LSTMParams<arm_compute::ITensorInfo> lstm_params_info;
268 
269  // The inputs and the outputs
270  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
271  const arm_compute::TensorInfo aclOutputStateInInfo = BuildArmComputeTensorInfo(outputStateIn);
272  const arm_compute::TensorInfo aclCellStateInInfo = BuildArmComputeTensorInfo(cellStateIn);
273  const arm_compute::TensorInfo aclScratchBufferInfo = BuildArmComputeTensorInfo(scratchBuffer);
274  const arm_compute::TensorInfo aclOutputStateOutInfo = BuildArmComputeTensorInfo(outputStateOut);
275  const arm_compute::TensorInfo aclCellStateOutInfo = BuildArmComputeTensorInfo(cellStateOut);
276  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
277 
278  // Basic parameters
279  const arm_compute::TensorInfo aclInputToForgetWeightsInfo
280  = BuildArmComputeTensorInfo(paramsInfo.GetInputToForgetWeights());
281  const arm_compute::TensorInfo aclInputToCellWeightsInfo
282  = BuildArmComputeTensorInfo(paramsInfo.GetInputToCellWeights());
283  const arm_compute::TensorInfo aclInputToOutputWeightsInfo
284  = BuildArmComputeTensorInfo(paramsInfo.GetInputToOutputWeights());
285  const arm_compute::TensorInfo aclRecurrentToForgetWeightsInfo
286  = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToForgetWeights());
287  const arm_compute::TensorInfo aclRecurrentToCellWeightsInfo
288  = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToCellWeights());
289  const arm_compute::TensorInfo aclRecurrentToOutputWeightsInfo
290  = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToOutputWeights());
291  const arm_compute::TensorInfo aclForgetGateBiasInfo = BuildArmComputeTensorInfo(paramsInfo.GetForgetGateBias());
292  const arm_compute::TensorInfo aclCellBiasInfo = BuildArmComputeTensorInfo(paramsInfo.GetCellBias());
293  const arm_compute::TensorInfo aclOutputGateBiasInfo = BuildArmComputeTensorInfo(paramsInfo.GetOutputGateBias());
294 
295  arm_compute::TensorInfo aclInputToInputWeightsInfo;
296  arm_compute::TensorInfo aclRecurrentToInputWeightsInfo;
297  arm_compute::TensorInfo aclCellToInputWeightsInfo;
298  arm_compute::TensorInfo aclInputGateBiasInfo;
299  arm_compute::TensorInfo aclProjectionWeightsInfo;
300  arm_compute::TensorInfo aclProjectionBiasInfo;
301  arm_compute::TensorInfo aclCellToForgetWeightsInfo;
302  arm_compute::TensorInfo aclCellToOutputWeightsInfo;
303  arm_compute::TensorInfo aclInputLayerNormWeightsInfo;
304  arm_compute::TensorInfo aclForgetLayerNormWeightsInfo;
305  arm_compute::TensorInfo aclCellLayerNormWeightsInfo;
306  arm_compute::TensorInfo aclOutputLayerNormWeightsInfo;
307 
308  if (!descriptor.m_CifgEnabled)
309  {
310  aclInputToInputWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetInputToInputWeights());
311  aclRecurrentToInputWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetRecurrentToInputWeights());
312 
313  if (paramsInfo.m_CellToInputWeights != nullptr)
314  {
315  aclCellToInputWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetCellToInputWeights());
316  }
317  aclInputGateBiasInfo = BuildArmComputeTensorInfo(paramsInfo.GetInputGateBias());
318  lstm_params_info.set_cifg_params(&aclInputToInputWeightsInfo, &aclRecurrentToInputWeightsInfo,
319  paramsInfo.m_CellToInputWeights != nullptr ?
320  &aclCellToInputWeightsInfo: nullptr,
321  &aclInputGateBiasInfo);
322  }
323 
324  if (descriptor.m_ProjectionEnabled)
325  {
326  aclProjectionWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetProjectionWeights());
327 
328  if (paramsInfo.m_ProjectionBias != nullptr)
329  {
330  aclProjectionBiasInfo = BuildArmComputeTensorInfo(paramsInfo.GetInputGateBias());
331  }
332  lstm_params_info.set_projection_params(&aclProjectionWeightsInfo,
333  paramsInfo.m_ProjectionBias != nullptr ?
334  &aclProjectionBiasInfo: nullptr);
335  }
336 
337  if (descriptor.m_PeepholeEnabled)
338  {
339  aclCellToForgetWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetCellToForgetWeights());
340  aclCellToOutputWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetCellToOutputWeights());
341  lstm_params_info.set_peephole_params(&aclCellToForgetWeightsInfo, &aclCellToOutputWeightsInfo);
342  }
343 
344  float cell_threshold = descriptor.m_ClippingThresCell;
345  float projection_threshold = descriptor.m_ClippingThresProj;
346 
347  // for preparing the object for the class ActivationLayerInfo, we need to consider 5 situations
348  arm_compute::ActivationLayerInfo activationLayerInfo;
349  if (descriptor.m_ActivationFunc == 0)
350  {
351  // no activation, do nothing
352  }
353  else if (descriptor.m_ActivationFunc == 1)
354  {
355  activationLayerInfo = arm_compute::ActivationLayerInfo(
356  arm_compute::ActivationLayerInfo::ActivationFunction::RELU);
357  }
358  else if (descriptor.m_ActivationFunc == 3)
359  {
360  activationLayerInfo = arm_compute::ActivationLayerInfo(
361  arm_compute::ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, 6.0);
362  }
363  else if (descriptor.m_ActivationFunc == 4)
364  {
365  activationLayerInfo = arm_compute::ActivationLayerInfo(
366  arm_compute::ActivationLayerInfo::ActivationFunction::TANH, 1.0, 1.0);
367  }
368  else if (descriptor.m_ActivationFunc == 6)
369  {
370  activationLayerInfo = arm_compute::ActivationLayerInfo(
371  arm_compute::ActivationLayerInfo::ActivationFunction::LOGISTIC);
372  }
373  else
374  {
375  throw armnn::Exception("Wrong Type of Activation Function!");
376  }
377 
378  if (descriptor.m_LayerNormEnabled)
379  {
380  if (!descriptor.m_CifgEnabled)
381  {
382  aclInputLayerNormWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetInputLayerNormWeights());
383  }
384 
385  aclForgetLayerNormWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetForgetLayerNormWeights());
386 
387  aclCellLayerNormWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetCellLayerNormWeights());
388 
389  aclOutputLayerNormWeightsInfo = BuildArmComputeTensorInfo(paramsInfo.GetOutputLayerNormWeights());
390 
391  lstm_params_info.set_layer_normalization_params(descriptor.m_CifgEnabled ?
392  nullptr : &aclInputLayerNormWeightsInfo,
393  &aclForgetLayerNormWeightsInfo,
394  &aclCellLayerNormWeightsInfo,
395  &aclOutputLayerNormWeightsInfo);
396  }
397 
398  return arm_compute::CLLSTMLayer::validate(&aclInputInfo, &aclInputToForgetWeightsInfo,
399  &aclInputToCellWeightsInfo,
400  &aclInputToOutputWeightsInfo,
401  &aclRecurrentToForgetWeightsInfo,
402  &aclRecurrentToCellWeightsInfo,
403  &aclRecurrentToOutputWeightsInfo,
404  &aclForgetGateBiasInfo,
405  &aclCellBiasInfo,
406  &aclOutputGateBiasInfo,
407  &aclOutputStateInInfo, &aclCellStateInInfo,
408  &aclScratchBufferInfo, &aclOutputStateOutInfo,
409  &aclCellStateOutInfo, &aclOutputInfo,
410  lstm_params_info, activationLayerInfo,
411  cell_threshold, projection_threshold);
412 }
413 
414 void ClLstmFloatWorkload::FreeUnusedTensors()
415 {
416  FreeTensorIfUnused(m_InputToInputWeightsTensor);
417  FreeTensorIfUnused(m_InputToForgetWeightsTensor);
418  FreeTensorIfUnused(m_InputToCellWeightsTensor);
419  FreeTensorIfUnused(m_InputToOutputWeightsTensor);
420  FreeTensorIfUnused(m_RecurrentToInputWeightsTensor);
421  FreeTensorIfUnused(m_RecurrentToForgetWeightsTensor);
422  FreeTensorIfUnused(m_RecurrentToCellWeightsTensor);
423  FreeTensorIfUnused(m_RecurrentToOutputWeightsTensor);
424  FreeTensorIfUnused(m_CellToInputWeightsTensor);
425  FreeTensorIfUnused(m_CellToForgetWeightsTensor);
426  FreeTensorIfUnused(m_CellToOutputWeightsTensor);
427  FreeTensorIfUnused(m_InputGateBiasTensor);
428  FreeTensorIfUnused(m_ForgetGateBiasTensor);
429  FreeTensorIfUnused(m_CellBiasTensor);
430  FreeTensorIfUnused(m_OutputGateBiasTensor);
431  FreeTensorIfUnused(m_ProjectionWeightsTensor);
432  FreeTensorIfUnused(m_ProjectionBiasTensor);
433  FreeTensorIfUnused(m_ScratchBuffer);
434  FreeTensorIfUnused(m_InputLayerNormWeightsTensor);
435  FreeTensorIfUnused(m_ForgetLayerNormWeightsTensor);
436  FreeTensorIfUnused(m_CellLayerNormWeightsTensor);
437  FreeTensorIfUnused(m_OutputLayerNormWeightsTensor);
438 }
439 
440 } //namespace armnn
bool m_ProjectionEnabled
Enable/disable the projection layer.
ClLstmFloatWorkload(const LstmQueueDescriptor &descriptor, const WorkloadInfo &info, const arm_compute::CLCompileContext &clCompileContext)
const TensorInfo & GetRecurrentToCellWeights() const
Definition: LstmParams.hpp:145
const TensorShape & GetShape() const
Definition: Tensor.hpp:187
const TensorInfo & GetCellBias() const
Definition: LstmParams.hpp:173
void InitializeArmComputeClTensorData(arm_compute::CLTensor &clTensor, const ConstCpuTensorHandle *handle)
float m_ClippingThresProj
Clipping threshold value for the projection.
const TensorInfo & GetRecurrentToInputWeights() const
Definition: LstmParams.hpp:137
const TensorInfo & GetCellLayerNormWeights() const
Definition: LstmParams.hpp:197
const TensorInfo & GetRecurrentToOutputWeights() const
Definition: LstmParams.hpp:149
#define ARMNN_SCOPED_PROFILING_EVENT_CL(name)
void RunClFunction(arm_compute::IFunction &function, const CheckLocation &location)
const QueueDescriptor m_Data
Definition: Workload.hpp:46
arm_compute::Status ClLstmFloatWorkloadValidate(const TensorInfo &input, const TensorInfo &outputStateIn, const TensorInfo &cellStateIn, const TensorInfo &scratchBuffer, const TensorInfo &outputStateOut, const TensorInfo &cellStateOut, const TensorInfo &output, const LstmDescriptor &descriptor, const LstmInputParamsInfo &paramsInfo)
const TensorInfo & GetCellToInputWeights() const
Definition: LstmParams.hpp:153
Copyright (c) 2021 ARM Limited and Contributors.
const TensorInfo & GetCellToForgetWeights() const
Definition: LstmParams.hpp:157
const TensorInfo & GetForgetLayerNormWeights() const
Definition: LstmParams.hpp:193
const TensorInfo & GetCellToOutputWeights() const
Definition: LstmParams.hpp:161
const TensorInfo & GetInputToCellWeights() const
Definition: LstmParams.hpp:129
std::vector< TensorInfo > m_InputTensorInfos
An LstmDescriptor for the LstmLayer.
const TensorInfo & GetInputToOutputWeights() const
Definition: LstmParams.hpp:133
const TensorInfo * m_ProjectionBias
Definition: LstmParams.hpp:105
bool m_PeepholeEnabled
Enable/disable peephole.
Status
enumeration
Definition: Types.hpp:26
const TensorInfo * m_CellToInputWeights
Definition: LstmParams.hpp:97
const TensorInfo & GetRecurrentToForgetWeights() const
Definition: LstmParams.hpp:141
#define CHECK_LOCATION()
Definition: Exceptions.hpp:197
uint32_t m_ActivationFunc
The activation function to use.
float m_ClippingThresCell
Clipping threshold value for the cell state.
const TensorInfo & GetInputToInputWeights() const
Definition: LstmParams.hpp:121
const TensorInfo & GetOutputLayerNormWeights() const
Definition: LstmParams.hpp:201
bool m_CifgEnabled
Enable/disable cifg (coupled input & forget gate).
const TensorInfo & GetForgetGateBias() const
Definition: LstmParams.hpp:169
std::vector< ITensorHandle * > m_Outputs
Base class for all ArmNN exceptions so that users can filter to just those.
Definition: Exceptions.hpp:46
bool m_LayerNormEnabled
Enable/disable layer normalization.
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35
const TensorInfo & GetInputGateBias() const
Definition: LstmParams.hpp:165
const TensorInfo & GetProjectionWeights() const
Definition: LstmParams.hpp:181
const TensorInfo & GetInputToForgetWeights() const
Definition: LstmParams.hpp:125
Contains information about inputs and outputs to a layer.
const TensorInfo & GetInputLayerNormWeights() const
Definition: LstmParams.hpp:189
std::vector< ITensorHandle * > m_Inputs
const TensorInfo & GetOutputGateBias() const
Definition: LstmParams.hpp:177