ArmNN
 21.11
QLstmLayer.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #include "QLstmLayer.hpp"
6 
7 #include "LayerCloneBase.hpp"
8 
9 #include <armnn/LstmParams.hpp>
10 #include <armnn/TypesUtils.hpp>
13 
14 namespace armnn
15 {
16 
17 QLstmLayer::QLstmLayer(const QLstmDescriptor& param, const char* name)
18  : LayerWithParameters(3, 3, LayerType::QLstm, param, name)
19 {
20 }
21 
22 std::unique_ptr<IWorkload> QLstmLayer::CreateWorkload(const IWorkloadFactory& factory) const
23 {
24  QLstmQueueDescriptor descriptor;
25 
26  // Basic parameters
34  descriptor.m_CellBias = m_BasicParameters.m_CellBias.get();
36 
37  // CIFG parameters
39  {
43  }
44 
45  // Projection parameters
47  {
50  }
51 
52  // Peephole parameters
54  {
56  {
58  }
59 
62  }
63 
64  // Layer normalisation parameters
66  {
68  {
70  }
74  }
75 
76  SetAdditionalInfo(descriptor);
77 
78  return factory.CreateQLstm(descriptor, PrepInfoAndDesc(descriptor));
79 }
80 
82 {
83  auto layer = CloneBase<QLstmLayer>(graph, m_Param, GetName());
84 
87  layer->m_BasicParameters.m_InputToCellWeights = m_BasicParameters.m_InputToCellWeights ?
89  layer->m_BasicParameters.m_InputToOutputWeights = m_BasicParameters.m_InputToOutputWeights ?
91  layer->m_BasicParameters.m_RecurrentToForgetWeights = m_BasicParameters.m_RecurrentToForgetWeights ?
93  layer->m_BasicParameters.m_RecurrentToCellWeights = m_BasicParameters.m_RecurrentToCellWeights ?
95  layer->m_BasicParameters.m_RecurrentToOutputWeights = m_BasicParameters.m_RecurrentToOutputWeights ?
97  layer->m_BasicParameters.m_ForgetGateBias = m_BasicParameters.m_ForgetGateBias ?
99  layer->m_BasicParameters.m_CellBias = m_BasicParameters.m_CellBias ?
100  m_BasicParameters.m_CellBias : nullptr;
101  layer->m_BasicParameters.m_OutputGateBias = m_BasicParameters.m_OutputGateBias ?
103 
104  if (!m_Param.m_CifgEnabled)
105  {
106  layer->m_CifgParameters.m_InputToInputWeights = m_CifgParameters.m_InputToInputWeights ?
108  layer->m_CifgParameters.m_RecurrentToInputWeights = m_CifgParameters.m_RecurrentToInputWeights ?
110  layer->m_CifgParameters.m_InputGateBias = m_CifgParameters.m_InputGateBias ?
112  }
113 
114  if (m_Param.m_ProjectionEnabled)
115  {
116  layer->m_ProjectionParameters.m_ProjectionWeights = m_ProjectionParameters.m_ProjectionWeights ?
118  layer->m_ProjectionParameters.m_ProjectionBias = m_ProjectionParameters.m_ProjectionBias ?
120  }
121 
122  if (m_Param.m_PeepholeEnabled)
123  {
124  if (!m_Param.m_CifgEnabled) {
125  layer->m_PeepholeParameters.m_CellToInputWeights = m_PeepholeParameters.m_CellToInputWeights ?
127  }
128 
129  layer->m_PeepholeParameters.m_CellToForgetWeights = m_PeepholeParameters.m_CellToForgetWeights ?
131  layer->m_PeepholeParameters.m_CellToOutputWeights = m_PeepholeParameters.m_CellToOutputWeights ?
133  }
134 
135  if (m_Param.m_LayerNormEnabled)
136  {
137  if (!m_Param.m_CifgEnabled) {
138  layer->m_LayerNormParameters.m_InputLayerNormWeights = m_LayerNormParameters.m_InputLayerNormWeights ?
140  }
141 
142  layer->m_LayerNormParameters.m_ForgetLayerNormWeights = m_LayerNormParameters.m_ForgetLayerNormWeights ?
144  layer->m_LayerNormParameters.m_CellLayerNormWeights = m_LayerNormParameters.m_CellLayerNormWeights ?
146  layer->m_LayerNormParameters.m_OutputLayerNormWeights = m_LayerNormParameters.m_OutputLayerNormWeights ?
148  }
149 
150  return std::move(layer);
151 }
152 
153 std::vector<TensorShape> QLstmLayer::InferOutputShapes(const std::vector<TensorShape>& inputShapes) const
154 {
155  ARMNN_ASSERT(inputShapes.size() == 3);
156 
157  // Get input values for validation
158  unsigned int batchSize = inputShapes[0][0];
159  unsigned int outputSize = inputShapes[1][1];
160  unsigned int numUnits = inputShapes[2][1];
161 
162  std::vector<TensorShape> outShapes;
163  outShapes.push_back(TensorShape({ batchSize, outputSize })); // outputStateOut
164  outShapes.push_back(TensorShape({ batchSize, numUnits })); // cellStateOut
165  outShapes.push_back(TensorShape({ batchSize, outputSize })); // output
166 
167  return outShapes;
168 }
169 
171 {
173 
174  const TensorShape& outputShape = GetOutputSlot(0).GetTensorInfo().GetShape();
175 
177 
178  auto inferredShapes = InferOutputShapes(
179  {
181  GetInputSlot(1).GetConnection()->GetTensorInfo().GetShape(), // previousOutputIn
182  GetInputSlot(2).GetConnection()->GetTensorInfo().GetShape() // previousCellStateIn
183  });
184 
185  ARMNN_ASSERT(inferredShapes.size() == 3);
186 
187  // Check if the weights are nullptr for basic params
189  "QLstmLayer: m_BasicParameters.m_InputToForgetWeights should not be null.");
191  "QLstmLayer: m_BasicParameters.m_InputToCellWeights should not be null.");
193  "QLstmLayer: m_BasicParameters.m_InputToOutputWeights should not be null.");
195  "QLstmLayer: m_BasicParameters.m_RecurrentToForgetWeights should not be null.");
197  "QLstmLayer: m_BasicParameters.m_RecurrentToCellWeights should not be null.");
199  "QLstmLayer: m_BasicParameters.m_RecurrentToOutputWeights should not be null.");
201  "QLstmLayer: m_BasicParameters.m_ForgetGateBias should not be null.");
203  "QLstmLayer: m_BasicParameters.m_CellBias should not be null.");
205  "QLstmLayer: m_BasicParameters.m_OutputGateBias should not be null.");
206 
207  if (!m_Param.m_CifgEnabled)
208  {
210  "QLstmLayer: m_CifgParameters.m_InputToInputWeights should not be null.");
212  "QLstmLayer: m_CifgParameters.m_RecurrentToInputWeights should not be null.");
214  "QLstmLayer: m_CifgParameters.m_InputGateBias should not be null.");
215 
216  ValidateAndCopyShape(outputShape, inferredShapes[0], m_ShapeInferenceMethod, "QLstmLayer");
217  }
218  else
219  {
221  "QLstmLayer: m_CifgParameters.m_InputToInputWeights should not have a value when CIFG is enabled.");
223  "QLstmLayer: m_CifgParameters.m_RecurrentToInputWeights should "
224  "not have a value when CIFG is enabled.");
226  "QLstmLayer: m_CifgParameters.m_InputGateBias should not have a value when CIFG is enabled.");
227 
228  ValidateAndCopyShape(outputShape, inferredShapes[0], m_ShapeInferenceMethod, "QLstmLayer");
229  }
230 
232  {
234  "QLstmLayer: m_ProjectionParameters.m_ProjectionWeights should not be null.");
235  }
236 
238  {
239  if (!m_Param.m_CifgEnabled) {
241  "QLstmLayer: m_PeepholeParameters.m_CellToInputWeights should not be null "
242  "when Peephole is enabled and CIFG is disabled.");
243  }
244 
246  "QLstmLayer: m_PeepholeParameters.m_CellToForgetWeights should not be null.");
248  "QLstmLayer: m_PeepholeParameters.m_CellToOutputWeights should not be null.");
249  }
250 
252  GetOutputSlot(1).GetTensorInfo().GetShape(), inferredShapes[1], m_ShapeInferenceMethod, "QLstmLayer", 1);
254  GetOutputSlot(2).GetTensorInfo().GetShape(), inferredShapes[2], m_ShapeInferenceMethod, "QLstmLayer", 2);
255 
257  {
259  {
261  "QLstmLayer: m_LayerNormParameters.m_InputLayerNormWeights should not be null.");
262  }
264  "QLstmLayer: m_LayerNormParameters.m_ForgetLayerNormWeights should not be null.");
266  "QLstmLayer: m_LayerNormParameters.m_CellLayerNormWeights should not be null.");
268  "QLstmLayer: m_LayerNormParameters.m_UutputLayerNormWeights should not be null.");
269  }
270 }
271 
273 {
283 
284  // Cifg parameters
288 
289  // Projection parameters
292 
293  // Peephole parameters
297 
298  // Layer normalisation parameters
303 }
304 
306 void QLstmLayer::Accept(ILayerVisitor& visitor) const
307 {
308  LstmInputParams inputParams;
318 
319  // Cifg parameters
323 
324  // Projection parameters
327 
328  // Peephole parameters
332 
333  // Layer normalisation parameters
338 
339  ConstTensor inputToInputWeightsTensor;
341  {
342  ConstTensor inputToInputWeightsTensorCopy(managedInputToInputWeights.GetTensorInfo(),
343  managedInputToInputWeights.Map());
344  inputToInputWeightsTensor = inputToInputWeightsTensorCopy;
345  inputParams.m_InputToInputWeights = &inputToInputWeightsTensor;
346  }
347 
348  ConstTensor inputToForgetWeightsTensor;
350  {
351  ConstTensor inputToForgetWeightsTensorCopy(managedInputToForgetWeights.GetTensorInfo(),
352  managedInputToForgetWeights.Map());
353  inputToForgetWeightsTensor = inputToForgetWeightsTensorCopy;
354  inputParams.m_InputToForgetWeights = &inputToForgetWeightsTensor;
355  }
356 
357  ConstTensor inputToCellWeightsTensor;
359  {
360  ConstTensor inputToCellWeightsTensorCopy(managedInputToCellWeights.GetTensorInfo(),
361  managedInputToCellWeights.Map());
362  inputToCellWeightsTensor = inputToCellWeightsTensorCopy;
363  inputParams.m_InputToCellWeights = &inputToCellWeightsTensor;
364  }
365 
366  ConstTensor inputToOutputWeightsTensor;
368  {
369  ConstTensor inputToOutputWeightsTensorCopy(managedInputToOutputWeights.GetTensorInfo(),
370  managedInputToOutputWeights.Map());
371  inputToOutputWeightsTensor = inputToOutputWeightsTensorCopy;
372  inputParams.m_InputToOutputWeights = &inputToOutputWeightsTensor;
373  }
374 
375  ConstTensor recurrentToInputWeightsTensor;
377  {
378  ConstTensor recurrentToInputWeightsTensorCopy(
379  managedRecurrentToInputWeights.GetTensorInfo(),
380  managedRecurrentToInputWeights.Map());
381  recurrentToInputWeightsTensor = recurrentToInputWeightsTensorCopy;
382  inputParams.m_RecurrentToInputWeights = &recurrentToInputWeightsTensor;
383  }
384 
385  ConstTensor recurrentToForgetWeightsTensor;
387  {
388  ConstTensor recurrentToForgetWeightsTensorCopy(
389  managedRecurrentToForgetWeights.GetTensorInfo(),
390  managedRecurrentToForgetWeights.Map());
391  recurrentToForgetWeightsTensor = recurrentToForgetWeightsTensorCopy;
392  inputParams.m_RecurrentToForgetWeights = &recurrentToForgetWeightsTensor;
393  }
394 
395  ConstTensor recurrentToCellWeightsTensor;
397  {
398  ConstTensor recurrentToCellWeightsTensorCopy(
399  managedRecurrentToCellWeights.GetTensorInfo(),
400  managedRecurrentToCellWeights.Map());
401  recurrentToCellWeightsTensor = recurrentToCellWeightsTensorCopy;
402  inputParams.m_RecurrentToCellWeights = &recurrentToCellWeightsTensor;
403  }
404 
405  ConstTensor recurrentToOutputWeightsTensor;
407  {
408  ConstTensor recurrentToOutputWeightsTensorCopy(
409  managedRecurrentToOutputWeights.GetTensorInfo(),
410  managedRecurrentToOutputWeights.Map());
411  recurrentToOutputWeightsTensor = recurrentToOutputWeightsTensorCopy;
412  inputParams.m_RecurrentToOutputWeights = &recurrentToOutputWeightsTensor;
413  }
414 
415  ConstTensor cellToInputWeightsTensor;
417  {
418  ConstTensor cellToInputWeightsTensorCopy(managedCellToInputWeights.GetTensorInfo(),
419  managedCellToInputWeights.Map());
420  cellToInputWeightsTensor = cellToInputWeightsTensorCopy;
421  inputParams.m_CellToInputWeights = &cellToInputWeightsTensor;
422  }
423 
424  ConstTensor cellToForgetWeightsTensor;
426  {
427  ConstTensor cellToForgetWeightsTensorCopy(managedCellToForgetWeights.GetTensorInfo(),
428  managedCellToForgetWeights.Map());
429  cellToForgetWeightsTensor = cellToForgetWeightsTensorCopy;
430  inputParams.m_CellToForgetWeights = &cellToForgetWeightsTensor;
431  }
432 
433  ConstTensor cellToOutputWeightsTensor;
435  {
436  ConstTensor cellToOutputWeightsTensorCopy(managedCellToOutputWeights.GetTensorInfo(),
437  managedCellToOutputWeights.Map());
438  cellToOutputWeightsTensor = cellToOutputWeightsTensorCopy;
439  inputParams.m_CellToOutputWeights = &cellToOutputWeightsTensor;
440  }
441 
442  ConstTensor inputGateBiasTensor;
443  if (m_CifgParameters.m_InputGateBias != nullptr)
444  {
445  ConstTensor inputGateBiasTensorCopy(managedInputGateBias.GetTensorInfo(),
446  managedInputGateBias.Map());
447  inputGateBiasTensor = inputGateBiasTensorCopy;
448  inputParams.m_InputGateBias = &inputGateBiasTensor;
449  }
450 
451  ConstTensor forgetGateBiasTensor;
452  if (m_BasicParameters.m_ForgetGateBias != nullptr)
453  {
454  ConstTensor forgetGateBiasTensorCopy(managedForgetGateBias.GetTensorInfo(),
455  managedForgetGateBias.Map());
456  forgetGateBiasTensor = forgetGateBiasTensorCopy;
457  inputParams.m_ForgetGateBias = &forgetGateBiasTensor;
458  }
459 
460  ConstTensor cellBiasTensor;
461  if (m_BasicParameters.m_CellBias != nullptr)
462  {
463  ConstTensor cellBiasTensorCopy(managedCellBias.GetTensorInfo(),
464  managedCellBias.Map());
465  cellBiasTensor = cellBiasTensorCopy;
466  inputParams.m_CellBias = &cellBiasTensor;
467  }
468 
469  ConstTensor outputGateBias;
470  if (m_BasicParameters.m_OutputGateBias != nullptr)
471  {
472  ConstTensor outputGateBiasCopy(managedOutputGateBias.GetTensorInfo(),
473  managedOutputGateBias.Map());
474  outputGateBias = outputGateBiasCopy;
475  inputParams.m_OutputGateBias = &outputGateBias;
476  }
477 
478  ConstTensor projectionWeightsTensor;
480  {
481  ConstTensor projectionWeightsTensorCopy(managedProjectionWeights.GetTensorInfo(),
482  managedProjectionWeights.Map());
483  projectionWeightsTensor = projectionWeightsTensorCopy;
484  inputParams.m_ProjectionWeights = &projectionWeightsTensor;
485  }
486 
487  ConstTensor projectionBiasTensor;
489  {
490  ConstTensor projectionBiasTensorCopy(managedProjectionBias.GetTensorInfo(),
491  managedProjectionBias.Map());
492  projectionBiasTensor = projectionBiasTensorCopy;
493  inputParams.m_ProjectionBias = &projectionBiasTensor;
494  }
495 
496  ConstTensor inputLayerNormTensor;
498  {
499  ConstTensor inputLayerNormTensorCopy(managedInputLayerNormWeights.GetTensorInfo(),
500  managedInputLayerNormWeights.Map());
501  inputLayerNormTensor = inputLayerNormTensorCopy;
502  inputParams.m_InputLayerNormWeights = &inputLayerNormTensor;
503  }
504 
505  ConstTensor forgetLayerNormTensor;
507  {
508  ConstTensor forgetLayerNormTensorCopy(managedForgetLayerNormWeights.GetTensorInfo(),
509  managedForgetLayerNormWeights.Map());
510  forgetLayerNormTensor = forgetLayerNormTensorCopy;
511  inputParams.m_ForgetLayerNormWeights = &forgetLayerNormTensor;
512  }
513 
514  ConstTensor cellLayerNormTensor;
516  {
517  ConstTensor cellLayerNormTensorCopy(managedCellLayerNormWeights.GetTensorInfo(),
518  managedCellLayerNormWeights.Map());
519  cellLayerNormTensor = cellLayerNormTensorCopy;
520  inputParams.m_CellLayerNormWeights = &cellLayerNormTensor;
521  }
522 
523  ConstTensor outputLayerNormTensor;
525  {
526  ConstTensor outputLayerNormTensorCopy(managedOutputLayerNormWeights.GetTensorInfo(),
527  managedOutputLayerNormWeights.Map());
528  outputLayerNormTensor = outputLayerNormTensorCopy;
529  inputParams.m_OutputLayerNormWeights = &outputLayerNormTensor;
530  }
531 
532 
533  visitor.VisitQLstmLayer(this, GetParameters(), inputParams, GetName());
534 }
536 
537 
539 {
540  std::vector<ConstTensor> constTensors;
550 
551  // Cifg parameters
555 
556  // Projection parameters
559 
560  // Peephole parameters
564 
565  // Layer normalisation parameters
570 
571  // First add mandatory/basic parameters
573  {
574  constTensors.emplace_back(ConstTensor(managedInputToForgetWeights.GetTensorInfo(),
575  managedInputToForgetWeights.Map()));
576  }
578  {
579  constTensors.emplace_back(ConstTensor(managedInputToCellWeights.GetTensorInfo(),
580  managedInputToCellWeights.Map()));
581  }
583  {
584  constTensors.emplace_back(ConstTensor(managedInputToOutputWeights.GetTensorInfo(),
585  managedInputToOutputWeights.Map()));
586  }
588  {
589  constTensors.emplace_back(ConstTensor(
590  managedRecurrentToForgetWeights.GetTensorInfo(),
591  managedRecurrentToForgetWeights.Map()));
592  }
594  {
595  constTensors.emplace_back(ConstTensor(
596  managedRecurrentToCellWeights.GetTensorInfo(),
597  managedRecurrentToCellWeights.Map()));
598  }
600  {
601  constTensors.emplace_back(ConstTensor(
602  managedRecurrentToOutputWeights.GetTensorInfo(),
603  managedRecurrentToOutputWeights.Map()));
604  }
605  if (m_BasicParameters.m_ForgetGateBias != nullptr)
606  {
607  constTensors.emplace_back(ConstTensor(managedForgetGateBias.GetTensorInfo(),
608  managedForgetGateBias.Map()));
609  }
610  if (m_BasicParameters.m_CellBias != nullptr)
611  {
612  constTensors.emplace_back(ConstTensor(managedCellBias.GetTensorInfo(),
613  managedCellBias.Map()));
614  }
615  if (m_BasicParameters.m_OutputGateBias != nullptr)
616  {
617  constTensors.emplace_back(ConstTensor(managedOutputGateBias.GetTensorInfo(),
618  managedOutputGateBias.Map()));
619  }
620 
621  // Add cifig parameters
623  {
624  constTensors.emplace_back(ConstTensor(managedInputToInputWeights.GetTensorInfo(),
625  managedInputToInputWeights.Map()));
626  }
628  {
629  constTensors.emplace_back(ConstTensor(
630  managedRecurrentToInputWeights.GetTensorInfo(),
631  managedRecurrentToInputWeights.Map()));
632  }
633  if (m_CifgParameters.m_InputGateBias != nullptr)
634  {
635  constTensors.emplace_back(ConstTensor(managedInputGateBias.GetTensorInfo(),
636  managedInputGateBias.Map()));
637  }
638 
639  // Add peephole parameters
641  {
642  constTensors.emplace_back(ConstTensor(managedCellToInputWeights.GetTensorInfo(),
643  managedCellToInputWeights.Map()));
644  }
646  {
647  constTensors.emplace_back(ConstTensor(managedCellToForgetWeights.GetTensorInfo(),
648  managedCellToForgetWeights.Map()));
649  }
651  {
652  constTensors.emplace_back(ConstTensor(managedCellToOutputWeights.GetTensorInfo(),
653  managedCellToOutputWeights.Map()));
654  }
655 
656  // Add projection parameters
658  {
659  constTensors.emplace_back(ConstTensor(managedProjectionWeights.GetTensorInfo(),
660  managedProjectionWeights.Map()));
661  }
663  {
664  constTensors.emplace_back(ConstTensor(managedProjectionBias.GetTensorInfo(),
665  managedProjectionBias.Map()));
666  }
667 
668  // Add norm parameters
670  {
671  constTensors.emplace_back(ConstTensor(managedInputLayerNormWeights.GetTensorInfo(),
672  managedInputLayerNormWeights.Map()));
673  }
675  {
676  constTensors.emplace_back(ConstTensor(managedForgetLayerNormWeights.GetTensorInfo(),
677  managedForgetLayerNormWeights.Map()));
678  }
680  {
681  constTensors.emplace_back(ConstTensor(managedCellLayerNormWeights.GetTensorInfo(),
682  managedCellLayerNormWeights.Map()));
683  }
685  {
686  constTensors.emplace_back(ConstTensor(managedOutputLayerNormWeights.GetTensorInfo(),
687  managedOutputLayerNormWeights.Map()));
688  }
689  strategy.ExecuteStrategy(this, GetParameters(), constTensors, GetName());
690 }
691 
692 } // namespace armnn
const ConstTensorHandle * m_CellLayerNormWeights
const ConstTensorHandle * m_ProjectionWeights
const ConstTensor * m_ProjectionWeights
Definition: LstmParams.hpp:55
const ConstTensorHandle * m_ForgetGateBias
const ConstTensor * m_CellBias
Definition: LstmParams.hpp:53
const ConstTensorHandle * m_InputToOutputWeights
QLstmDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).
const TensorShape & GetShape() const
Definition: Tensor.hpp:191
QLstmOptProjectionParameters m_ProjectionParameters
Definition: QLstmLayer.hpp:85
const ConstTensor * m_CellToOutputWeights
Definition: LstmParams.hpp:50
std::shared_ptr< ConstTensorHandle > m_OutputGateBias
A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32). ...
Definition: QLstmLayer.hpp:35
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
Definition: Deprecated.hpp:33
bool m_PeepholeEnabled
Enable/disable peephole.
virtual void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0)=0
const ConstTensor * m_CellToInputWeights
Definition: LstmParams.hpp:48
const ConstTensorHandle * m_InputToInputWeights
std::shared_ptr< ConstTensorHandle > m_RecurrentToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units] (QSymmS8)...
Definition: QLstmLayer.hpp:61
const ConstTensorHandle * m_CellToOutputWeights
std::shared_ptr< ConstTensorHandle > m_ForgetLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:71
const ConstTensor * m_InputGateBias
Definition: LstmParams.hpp:51
const ConstTensorHandle * m_CellToInputWeights
virtual std::unique_ptr< IWorkload > CreateQLstm(const QLstmQueueDescriptor &descriptor, const WorkloadInfo &info) const
std::shared_ptr< ConstTensorHandle > m_InputToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:21
std::shared_ptr< ConstTensorHandle > m_InputLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:69
const ConstTensor * m_RecurrentToCellWeights
Definition: LstmParams.hpp:46
const ConstTensor * m_ForgetLayerNormWeights
Definition: LstmParams.hpp:58
void VerifyShapeInferenceType(const TensorShape &outputShape, ShapeInferenceMethod shapeInferenceMethod)
Definition: Layer.cpp:433
const ConstTensor * m_CellToForgetWeights
Definition: LstmParams.hpp:49
const TensorInfo & GetTensorInfo() const
Copyright (c) 2021 ARM Limited and Contributors.
const IOutputSlot * GetConnection() const override
Definition: Layer.hpp:199
std::shared_ptr< ConstTensorHandle > m_CellToOutputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:53
void ValidateAndCopyShape(const TensorShape &outputShape, const TensorShape &inferredShape, const ShapeInferenceMethod shapeInferenceMethod, const std::string &layerName, const unsigned int outputSlotIndex=0)
Definition: Layer.cpp:393
std::shared_ptr< ConstTensorHandle > m_InputToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:19
const ConstTensor * m_OutputGateBias
Definition: LstmParams.hpp:54
QLstmOptLayerNormParameters m_LayerNormParameters
Definition: QLstmLayer.hpp:87
QLstmLayer * Clone(Graph &graph) const override
Creates a dynamically-allocated copy of this layer.
Definition: QLstmLayer.cpp:81
const ConstTensorHandle * m_ForgetLayerNormWeights
std::shared_ptr< ConstTensorHandle > m_CellBias
A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32). ...
Definition: QLstmLayer.hpp:33
std::shared_ptr< ConstTensorHandle > m_ProjectionWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units] (QSymmS8)...
Definition: QLstmLayer.hpp:41
void VerifyLayerConnections(unsigned int expectedConnections, const CheckLocation &location) const
Definition: Layer.cpp:349
std::shared_ptr< ConstTensorHandle > m_InputToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:17
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
Definition: Layer.hpp:316
std::shared_ptr< ConstTensorHandle > m_InputGateBias
A unique pointer to represent 1D weights tensor with dimensions [num_units] (int32).
Definition: QLstmLayer.hpp:63
const ConstTensor * m_InputLayerNormWeights
Definition: LstmParams.hpp:57
bool m_LayerNormEnabled
Enable/disable layer normalization.
std::vector< std::reference_wrapper< std::shared_ptr< ConstTensorHandle > >> ConstantTensors
Definition: Layer.hpp:393
const ConstTensor * m_RecurrentToOutputWeights
Definition: LstmParams.hpp:47
#define ARMNN_NO_DEPRECATE_WARN_END
Definition: Deprecated.hpp:34
std::shared_ptr< ConstTensorHandle > m_CellLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:73
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
std::shared_ptr< ConstTensorHandle > m_ForgetGateBias
A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32). ...
Definition: QLstmLayer.hpp:31
virtual std::unique_ptr< IWorkload > CreateWorkload(const IWorkloadFactory &factory) const override
Makes a workload for the QLstm type.
Definition: QLstmLayer.cpp:22
std::shared_ptr< ConstTensorHandle > m_CellToInputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:49
const ConstTensor * m_ProjectionBias
Definition: LstmParams.hpp:56
std::shared_ptr< ConstTensorHandle > m_CellToForgetWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:51
const ConstTensorHandle * m_InputToForgetWeights
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:327
const ConstTensorHandle * m_CellBias
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
A QLstmDescriptor for the QLstmLayer.
const ConstTensorHandle * m_InputLayerNormWeights
void ValidateTensorShapesFromInputs() override
Check if the input tensor shape(s) will lead to a valid configuration of QLstmLayer.
Definition: QLstmLayer.cpp:170
QLstmLayer(const QLstmDescriptor &param, const char *name)
Constructor to create a QLstmLayer.
Definition: QLstmLayer.cpp:17
Layer::ConstantTensors GetConstantTensorsByRef() override
Retrieve the handles to the constant values stored by the layer.
Definition: QLstmLayer.cpp:272
#define CHECK_LOCATION()
Definition: Exceptions.hpp:209
std::shared_ptr< ConstTensorHandle > m_OutputLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:75
std::shared_ptr< ConstTensorHandle > m_RecurrentToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:26
QLstmBasicParameters m_BasicParameters
Definition: QLstmLayer.hpp:83
std::shared_ptr< ConstTensorHandle > m_RecurrentToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:28
const ConstTensorHandle * m_InputToCellWeights
void SetAdditionalInfo(QueueDescriptor &descriptor) const
Definition: Layer.cpp:245
const ConstTensor * m_CellLayerNormWeights
Definition: LstmParams.hpp:59
const ConstTensor * m_ForgetGateBias
Definition: LstmParams.hpp:52
const ConstTensor * m_InputToCellWeights
Definition: LstmParams.hpp:42
std::shared_ptr< ConstTensorHandle > m_InputToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units] (QSymmS8)...
Definition: QLstmLayer.hpp:59
const ConstTensor * m_InputToOutputWeights
Definition: LstmParams.hpp:43
This layer represents a QLstm operation.
Definition: QLstmLayer.hpp:79
const ConstTensorHandle * m_CellToForgetWeights
ARMNN_NO_DEPRECATE_WARN_BEGIN void Accept(ILayerVisitor &visitor) const override
Definition: QLstmLayer.cpp:306
const ConstTensor * m_RecurrentToForgetWeights
Definition: LstmParams.hpp:45
const ConstTensorHandle * m_ProjectionBias
const ConstTensorHandle * m_RecurrentToCellWeights
bool m_ProjectionEnabled
Enable/disable the projection layer.
const ConstTensorHandle * m_InputGateBias
const ConstTensor * m_RecurrentToInputWeights
Definition: LstmParams.hpp:44
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *LayerCreateWorkload.
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
Definition: Layer.hpp:318
virtual const TensorInfo & GetTensorInfo() const =0
QLstmOptCifgParameters m_CifgParameters
Definition: QLstmLayer.hpp:84
QLstmOptPeepholeParameters m_PeepholeParameters
Definition: QLstmLayer.hpp:86
const char * GetName() const override
Returns the name of the layer.
Definition: Layer.hpp:311
const ConstTensorHandle * m_OutputGateBias
std::shared_ptr< ConstTensorHandle > m_ProjectionBias
A unique pointer to represent 1D weights tensor with dimensions [output_size] (int32).
Definition: QLstmLayer.hpp:43
const ConstTensor * m_OutputLayerNormWeights
Definition: LstmParams.hpp:60
const void * Map(bool blocking=true)
RAII Managed resource Unmaps MemoryArea once out of scope.
std::vector< TensorShape > InferOutputShapes(const std::vector< TensorShape > &inputShapes) const override
By default returns inputShapes if the number of inputs are equal to number of outputs, otherwise infers the output shapes from given input shapes and layer properties.
Definition: QLstmLayer.cpp:153
std::shared_ptr< ConstTensorHandle > m_RecurrentToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:24
const TensorInfo & GetTensorInfo(const ITensorHandle *tensorHandle)
float32 helpers
const ConstTensorHandle * m_OutputLayerNormWeights
const TensorInfo & GetTensorInfo() const override
Definition: Layer.cpp:63
const ConstTensorHandle * m_RecurrentToOutputWeights
const ConstTensorHandle * m_RecurrentToInputWeights
bool m_CifgEnabled
Enable/disable CIFG (coupled input & forget gate).
ShapeInferenceMethod m_ShapeInferenceMethod
Definition: Layer.hpp:408
ARMNN_NO_DEPRECATE_WARN_END void ExecuteStrategy(IStrategy &strategy) const override
Apply a visitor to this layer.
Definition: QLstmLayer.cpp:538
const ConstTensorHandle * m_RecurrentToForgetWeights
const ConstTensor * m_InputToForgetWeights
Definition: LstmParams.hpp:41
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below...
Definition: Types.hpp:443
const ConstTensor * m_InputToInputWeights
Definition: LstmParams.hpp:40