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