ArmNN  NotReleased
QuantizedLstmLayer Class Reference

This layer represents a QuantizedLstm operation. More...

#include <QuantizedLstmLayer.hpp>

Inheritance diagram for QuantizedLstmLayer:
Layer IConnectableLayer

Public Member Functions

virtual std::unique_ptr< IWorkloadCreateWorkload (const IWorkloadFactory &factory) const override
 
QuantizedLstmLayerClone (Graph &graph) const override
 
void ValidateTensorShapesFromInputs () override
 
std::vector< TensorShapeInferOutputShapes (const std::vector< TensorShape > &inputShapes) const override
 
void Accept (ILayerVisitor &visitor) const override
 
- Public Member Functions inherited from Layer
 Layer (unsigned int numInputSlots, unsigned int numOutputSlots, LayerType type, const char *name)
 
 Layer (unsigned int numInputSlots, unsigned int numOutputSlots, LayerType type, DataLayout layout, const char *name)
 
const std::string & GetNameStr () const
 
const OutputHandlerGetOutputHandler (unsigned int i=0) const
 
OutputHandlerGetOutputHandler (unsigned int i=0)
 
const std::vector< InputSlot > & GetInputSlots () const
 
const std::vector< OutputSlot > & GetOutputSlots () const
 
std::vector< InputSlot >::iterator BeginInputSlots ()
 
std::vector< InputSlot >::iterator EndInputSlots ()
 
std::vector< OutputSlot >::iterator BeginOutputSlots ()
 
std::vector< OutputSlot >::iterator EndOutputSlots ()
 
bool IsOutputUnconnected ()
 
void ResetPriority () const
 
LayerPriority GetPriority () const
 
LayerType GetType () const
 
DataType GetDataType () const
 
const BackendIdGetBackendId () const
 
void SetBackendId (const BackendId &id)
 
virtual void CreateTensorHandles (const TensorHandleFactoryRegistry &registry, const IWorkloadFactory &factory, const bool IsMemoryManaged=true)
 
void VerifyLayerConnections (unsigned int expectedConnections, const CheckLocation &location) const
 
virtual void SerializeLayerParameters (ParameterStringifyFunction &fn) const
 
virtual void ReleaseConstantData ()
 
template<typename Op >
void OperateOnConstantTensors (Op op)
 
const char * GetName () const override
 
unsigned int GetNumInputSlots () const override
 
unsigned int GetNumOutputSlots () const override
 
const InputSlotGetInputSlot (unsigned int index) const override
 
InputSlotGetInputSlot (unsigned int index) override
 
const OutputSlotGetOutputSlot (unsigned int index=0) const override
 
OutputSlotGetOutputSlot (unsigned int index=0) override
 
void SetGuid (LayerGuid guid)
 
LayerGuid GetGuid () const final
 
void AddRelatedLayerName (const std::string layerName)
 
const std::list< std::string > & GetRelatedLayerNames ()
 
virtual void Reparent (Graph &dest, std::list< Layer *>::const_iterator iterator)=0
 

Public Attributes

QuantizedLstmParameters m_QuantizedLstmParameters
 

Protected Member Functions

 QuantizedLstmLayer (const char *name)
 
 ~QuantizedLstmLayer ()=default
 Default destructor. More...
 
Layer::ConstantTensors GetConstantTensorsByRef () override
 
- Protected Member Functions inherited from Layer
virtual ~Layer ()=default
 
template<typename QueueDescriptor >
void CollectQueueDescriptorInputs (QueueDescriptor &descriptor, WorkloadInfo &info) const
 
template<typename QueueDescriptor >
void CollectQueueDescriptorOutputs (QueueDescriptor &descriptor, WorkloadInfo &info) const
 
template<typename QueueDescriptor >
WorkloadInfo PrepInfoAndDesc (QueueDescriptor &descriptor) const
 Helper function to reduce duplication in *LayerCreateWorkload. More...
 
template<typename LayerType , typename ... Params>
LayerTypeCloneBase (Graph &graph, Params &&... params) const
 
- Protected Member Functions inherited from IConnectableLayer
 ~IConnectableLayer ()
 Objects are not deletable via the handle. More...
 

Additional Inherited Members

- Protected Types inherited from Layer
using ConstantTensors = std::vector< std::reference_wrapper< std::unique_ptr< ScopedCpuTensorHandle > >>
 
- Protected Attributes inherited from Layer
std::vector< OutputHandlerm_OutputHandlers
 

Detailed Description

This layer represents a QuantizedLstm operation.

Definition at line 45 of file QuantizedLstmLayer.hpp.

Constructor & Destructor Documentation

◆ QuantizedLstmLayer()

QuantizedLstmLayer ( const char *  name)
protected

Constructor to create a QuantizedLstmLayer.

Parameters
[in]nameOptional name for the layer.

Definition at line 17 of file QuantizedLstmLayer.cpp.

References armnn::QuantizedLstm.

18  : Layer(3, 2, LayerType::QuantizedLstm, name)
19 {
20 }
Layer(unsigned int numInputSlots, unsigned int numOutputSlots, LayerType type, const char *name)
Definition: Layer.cpp:212

◆ ~QuantizedLstmLayer()

~QuantizedLstmLayer ( )
protecteddefault

Default destructor.

Member Function Documentation

◆ Accept()

void Accept ( ILayerVisitor visitor) const
overridevirtual

Implements IConnectableLayer.

Definition at line 168 of file QuantizedLstmLayer.cpp.

References Layer::GetName(), QuantizedLstmParameters::m_CellBias, QuantizedLstmInputParams::m_CellBias, QuantizedLstmParameters::m_ForgetGateBias, QuantizedLstmInputParams::m_ForgetGateBias, QuantizedLstmParameters::m_InputGateBias, QuantizedLstmInputParams::m_InputGateBias, QuantizedLstmParameters::m_InputToCellWeights, QuantizedLstmInputParams::m_InputToCellWeights, QuantizedLstmParameters::m_InputToForgetWeights, QuantizedLstmInputParams::m_InputToForgetWeights, QuantizedLstmParameters::m_InputToInputWeights, QuantizedLstmInputParams::m_InputToInputWeights, QuantizedLstmParameters::m_InputToOutputWeights, QuantizedLstmInputParams::m_InputToOutputWeights, QuantizedLstmParameters::m_OutputGateBias, QuantizedLstmInputParams::m_OutputGateBias, QuantizedLstmLayer::m_QuantizedLstmParameters, QuantizedLstmParameters::m_RecurrentToCellWeights, QuantizedLstmInputParams::m_RecurrentToCellWeights, QuantizedLstmParameters::m_RecurrentToForgetWeights, QuantizedLstmInputParams::m_RecurrentToForgetWeights, QuantizedLstmParameters::m_RecurrentToInputWeights, QuantizedLstmInputParams::m_RecurrentToInputWeights, QuantizedLstmParameters::m_RecurrentToOutputWeights, QuantizedLstmInputParams::m_RecurrentToOutputWeights, and ILayerVisitor::VisitQuantizedLstmLayer().

169 {
170  QuantizedLstmInputParams inputParams;
171 
172  // InputToX weight tensors
173  ConstTensor inputToInputWeightsTensor;
175  {
176  ConstTensor inputToInputWeightsTensorCopy(m_QuantizedLstmParameters.m_InputToInputWeights->GetTensorInfo(),
178  inputToInputWeightsTensor = inputToInputWeightsTensorCopy;
179  inputParams.m_InputToInputWeights = &inputToInputWeightsTensor;
180  }
181 
182  ConstTensor inputToForgetWeightsTensor;
184  {
185  ConstTensor inputToForgetWeightsTensorCopy(m_QuantizedLstmParameters.m_InputToForgetWeights->GetTensorInfo(),
187  inputToForgetWeightsTensor = inputToForgetWeightsTensorCopy;
188  inputParams.m_InputToForgetWeights = &inputToForgetWeightsTensor;
189  }
190 
191  ConstTensor inputToCellWeightsTensor;
193  {
194  ConstTensor inputToCellWeightsTensorCopy(m_QuantizedLstmParameters.m_InputToCellWeights->GetTensorInfo(),
196  inputToCellWeightsTensor = inputToCellWeightsTensorCopy;
197  inputParams.m_InputToCellWeights = &inputToCellWeightsTensor;
198  }
199 
200  ConstTensor inputToOutputWeightsTensor;
202  {
203  ConstTensor inputToOutputWeightsTensorCopy(m_QuantizedLstmParameters.m_InputToOutputWeights->GetTensorInfo(),
205  inputToOutputWeightsTensor = inputToOutputWeightsTensorCopy;
206  inputParams.m_InputToOutputWeights = &inputToOutputWeightsTensor;
207  }
208 
209  // RecurrentToX weight tensors
210  ConstTensor recurrentToInputWeightsTensor;
212  {
213  ConstTensor recurrentToInputWeightsTensorCopy(
216  recurrentToInputWeightsTensor = recurrentToInputWeightsTensorCopy;
217  inputParams.m_RecurrentToInputWeights = &recurrentToInputWeightsTensor;
218  }
219 
220  ConstTensor recurrentToForgetWeightsTensor;
222  {
223  ConstTensor recurrentToForgetWeightsTensorCopy(
226  recurrentToForgetWeightsTensor = recurrentToForgetWeightsTensorCopy;
227  inputParams.m_RecurrentToForgetWeights = &recurrentToForgetWeightsTensor;
228  }
229 
230  ConstTensor recurrentToCellWeightsTensor;
232  {
233  ConstTensor recurrentToCellWeightsTensorCopy(
236  recurrentToCellWeightsTensor = recurrentToCellWeightsTensorCopy;
237  inputParams.m_RecurrentToCellWeights = &recurrentToCellWeightsTensor;
238  }
239 
240  ConstTensor recurrentToOutputWeightsTensor;
242  {
243  ConstTensor recurrentToOutputWeightsTensorCopy(
246  recurrentToOutputWeightsTensor = recurrentToOutputWeightsTensorCopy;
247  inputParams.m_RecurrentToOutputWeights = &recurrentToOutputWeightsTensor;
248  }
249 
250  // Bias tensors
251  ConstTensor inputGateBiasTensor;
253  {
254  ConstTensor inputGateBiasTensorCopy(m_QuantizedLstmParameters.m_InputGateBias->GetTensorInfo(),
256  inputGateBiasTensor = inputGateBiasTensorCopy;
257  inputParams.m_InputGateBias = &inputGateBiasTensor;
258  }
259 
260  ConstTensor forgetGateBiasTensor;
262  {
263  ConstTensor forgetGateBiasTensorCopy(m_QuantizedLstmParameters.m_ForgetGateBias->GetTensorInfo(),
265  forgetGateBiasTensor = forgetGateBiasTensorCopy;
266  inputParams.m_ForgetGateBias = &forgetGateBiasTensor;
267  }
268 
269  ConstTensor cellBiasTensor;
270  if (m_QuantizedLstmParameters.m_CellBias != nullptr)
271  {
272  ConstTensor cellBiasTensorCopy(m_QuantizedLstmParameters.m_CellBias->GetTensorInfo(),
274  cellBiasTensor = cellBiasTensorCopy;
275  inputParams.m_CellBias = &cellBiasTensor;
276  }
277 
278  ConstTensor outputGateBiasTensor;
280  {
281  ConstTensor outputGateBiasCopy(m_QuantizedLstmParameters.m_OutputGateBias->GetTensorInfo(),
283  outputGateBiasTensor = outputGateBiasCopy;
284  inputParams.m_OutputGateBias = &outputGateBiasTensor;
285  }
286 
287  visitor.VisitQuantizedLstmLayer(this, inputParams, GetName());
288 }
std::unique_ptr< ScopedCpuTensorHandle > m_ForgetGateBias
A unique pointer to represent 1D bias tensor with dimensions [outputSize] (int32).
const char * GetName() const override
Definition: Layer.hpp:305
std::unique_ptr< ScopedCpuTensorHandle > m_InputGateBias
A unique pointer to represent 1D bias tensor with dimensions [outputSize] (int32).
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, outputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, outputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, outputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_InputToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, inputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_OutputGateBias
A unique pointer to represent 1D bias tensor with dimensions [outputSize] (int32).
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, outputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_InputToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, inputSize] (QAsymm8)...
QuantizedLstmParameters m_QuantizedLstmParameters
std::unique_ptr< ScopedCpuTensorHandle > m_InputToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, inputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_InputToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, inputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_CellBias
A unique pointer to represent 1D bias tensor with dimensions [outputSize] (int32).

◆ Clone()

QuantizedLstmLayer * Clone ( Graph graph) const
overridevirtual

Creates a dynamically-allocated copy of this layer.

Parameters
[in]graphThe graph into which this layer is being cloned.

Implements Layer.

Definition at line 45 of file QuantizedLstmLayer.cpp.

References Layer::GetName(), QuantizedLstmParameters::m_CellBias, QuantizedLstmParameters::m_ForgetGateBias, QuantizedLstmParameters::m_InputGateBias, QuantizedLstmParameters::m_InputToCellWeights, QuantizedLstmParameters::m_InputToForgetWeights, QuantizedLstmParameters::m_InputToInputWeights, QuantizedLstmParameters::m_InputToOutputWeights, QuantizedLstmParameters::m_OutputGateBias, QuantizedLstmLayer::m_QuantizedLstmParameters, QuantizedLstmParameters::m_RecurrentToCellWeights, QuantizedLstmParameters::m_RecurrentToForgetWeights, QuantizedLstmParameters::m_RecurrentToInputWeights, and QuantizedLstmParameters::m_RecurrentToOutputWeights.

46 {
47  auto layer = CloneBase<QuantizedLstmLayer>(graph, GetName());
48 
49  layer->m_QuantizedLstmParameters.m_InputToInputWeights = m_QuantizedLstmParameters.m_InputToInputWeights ?
50  std::make_unique<ScopedCpuTensorHandle>(*m_QuantizedLstmParameters.m_InputToInputWeights) : nullptr;
51  layer->m_QuantizedLstmParameters.m_InputToForgetWeights = m_QuantizedLstmParameters.m_InputToForgetWeights ?
52  std::make_unique<ScopedCpuTensorHandle>(*m_QuantizedLstmParameters.m_InputToForgetWeights) : nullptr;
53  layer->m_QuantizedLstmParameters.m_InputToCellWeights = m_QuantizedLstmParameters.m_InputToCellWeights ?
54  std::make_unique<ScopedCpuTensorHandle>(*m_QuantizedLstmParameters.m_InputToCellWeights) : nullptr;
55  layer->m_QuantizedLstmParameters.m_InputToOutputWeights = m_QuantizedLstmParameters.m_InputToOutputWeights ?
56  std::make_unique<ScopedCpuTensorHandle>(*m_QuantizedLstmParameters.m_InputToOutputWeights) : nullptr;
57 
58  layer->m_QuantizedLstmParameters.m_RecurrentToInputWeights = m_QuantizedLstmParameters.m_RecurrentToInputWeights ?
59  std::make_unique<ScopedCpuTensorHandle>(*m_QuantizedLstmParameters.m_RecurrentToInputWeights) : nullptr;
60  layer->m_QuantizedLstmParameters.m_RecurrentToForgetWeights = m_QuantizedLstmParameters.m_RecurrentToForgetWeights
61  ? std::make_unique<ScopedCpuTensorHandle>(*m_QuantizedLstmParameters.m_RecurrentToForgetWeights) : nullptr;
62  layer->m_QuantizedLstmParameters.m_RecurrentToCellWeights = m_QuantizedLstmParameters.m_RecurrentToCellWeights ?
63  std::make_unique<ScopedCpuTensorHandle>(*m_QuantizedLstmParameters.m_RecurrentToCellWeights) : nullptr;
64  layer->m_QuantizedLstmParameters.m_RecurrentToOutputWeights = m_QuantizedLstmParameters.m_RecurrentToOutputWeights
65  ? std::make_unique<ScopedCpuTensorHandle>(*m_QuantizedLstmParameters.m_RecurrentToOutputWeights) : nullptr;
66 
67  layer->m_QuantizedLstmParameters.m_InputGateBias = m_QuantizedLstmParameters.m_InputGateBias ?
68  std::make_unique<ScopedCpuTensorHandle>(*m_QuantizedLstmParameters.m_InputGateBias) : nullptr;
69  layer->m_QuantizedLstmParameters.m_ForgetGateBias = m_QuantizedLstmParameters.m_ForgetGateBias ?
70  std::make_unique<ScopedCpuTensorHandle>(*m_QuantizedLstmParameters.m_ForgetGateBias) : nullptr;
71  layer->m_QuantizedLstmParameters.m_CellBias = m_QuantizedLstmParameters.m_CellBias ?
72  std::make_unique<ScopedCpuTensorHandle>(*m_QuantizedLstmParameters.m_CellBias) : nullptr;
73  layer->m_QuantizedLstmParameters.m_OutputGateBias = m_QuantizedLstmParameters.m_OutputGateBias ?
74  std::make_unique<ScopedCpuTensorHandle>(*m_QuantizedLstmParameters.m_OutputGateBias) : nullptr;
75 
76  return std::move(layer);
77 }
std::unique_ptr< ScopedCpuTensorHandle > m_ForgetGateBias
A unique pointer to represent 1D bias tensor with dimensions [outputSize] (int32).
const char * GetName() const override
Definition: Layer.hpp:305
std::unique_ptr< ScopedCpuTensorHandle > m_InputGateBias
A unique pointer to represent 1D bias tensor with dimensions [outputSize] (int32).
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, outputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, outputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, outputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_InputToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, inputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_OutputGateBias
A unique pointer to represent 1D bias tensor with dimensions [outputSize] (int32).
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, outputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_InputToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, inputSize] (QAsymm8)...
QuantizedLstmParameters m_QuantizedLstmParameters
std::unique_ptr< ScopedCpuTensorHandle > m_InputToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, inputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_InputToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, inputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_CellBias
A unique pointer to represent 1D bias tensor with dimensions [outputSize] (int32).

◆ CreateWorkload()

std::unique_ptr< IWorkload > CreateWorkload ( const IWorkloadFactory factory) const
overridevirtual

Makes a workload for the QuantizedLstm type.

Parameters
[in]graphThe graph where this layer can be found.
[in]factoryThe workload factory which will create the workload.
Returns
A pointer to the created workload, or nullptr if not created.

Implements Layer.

Definition at line 22 of file QuantizedLstmLayer.cpp.

References IWorkloadFactory::CreateQuantizedLstm(), QuantizedLstmParameters::m_CellBias, QuantizedLstmQueueDescriptor::m_CellBias, QuantizedLstmParameters::m_ForgetGateBias, QuantizedLstmQueueDescriptor::m_ForgetGateBias, QuantizedLstmParameters::m_InputGateBias, QuantizedLstmQueueDescriptor::m_InputGateBias, QuantizedLstmParameters::m_InputToCellWeights, QuantizedLstmQueueDescriptor::m_InputToCellWeights, QuantizedLstmParameters::m_InputToForgetWeights, QuantizedLstmQueueDescriptor::m_InputToForgetWeights, QuantizedLstmParameters::m_InputToInputWeights, QuantizedLstmQueueDescriptor::m_InputToInputWeights, QuantizedLstmParameters::m_InputToOutputWeights, QuantizedLstmQueueDescriptor::m_InputToOutputWeights, QuantizedLstmParameters::m_OutputGateBias, QuantizedLstmQueueDescriptor::m_OutputGateBias, QuantizedLstmLayer::m_QuantizedLstmParameters, QuantizedLstmParameters::m_RecurrentToCellWeights, QuantizedLstmQueueDescriptor::m_RecurrentToCellWeights, QuantizedLstmParameters::m_RecurrentToForgetWeights, QuantizedLstmQueueDescriptor::m_RecurrentToForgetWeights, QuantizedLstmParameters::m_RecurrentToInputWeights, QuantizedLstmQueueDescriptor::m_RecurrentToInputWeights, QuantizedLstmParameters::m_RecurrentToOutputWeights, QuantizedLstmQueueDescriptor::m_RecurrentToOutputWeights, and Layer::PrepInfoAndDesc().

23 {
24  QuantizedLstmQueueDescriptor descriptor;
25 
26  // QuantizedLstmLayer parameters - there are no optional params
27  descriptor.m_InputToInputWeights = m_QuantizedLstmParameters.m_InputToInputWeights.get();
28  descriptor.m_InputToForgetWeights = m_QuantizedLstmParameters.m_InputToForgetWeights.get();
29  descriptor.m_InputToCellWeights = m_QuantizedLstmParameters.m_InputToCellWeights.get();
30  descriptor.m_InputToOutputWeights = m_QuantizedLstmParameters.m_InputToOutputWeights.get();
31 
32  descriptor.m_RecurrentToInputWeights = m_QuantizedLstmParameters.m_RecurrentToInputWeights.get();
33  descriptor.m_RecurrentToForgetWeights = m_QuantizedLstmParameters.m_RecurrentToForgetWeights.get();
34  descriptor.m_RecurrentToCellWeights = m_QuantizedLstmParameters.m_RecurrentToCellWeights.get();
35  descriptor.m_RecurrentToOutputWeights = m_QuantizedLstmParameters.m_RecurrentToOutputWeights.get();
36 
37  descriptor.m_InputGateBias = m_QuantizedLstmParameters.m_InputGateBias.get();
38  descriptor.m_ForgetGateBias = m_QuantizedLstmParameters.m_ForgetGateBias.get();
39  descriptor.m_CellBias = m_QuantizedLstmParameters.m_CellBias.get();
40  descriptor.m_OutputGateBias = m_QuantizedLstmParameters.m_OutputGateBias.get();
41 
42  return factory.CreateQuantizedLstm(descriptor, PrepInfoAndDesc(descriptor));
43 }
std::unique_ptr< ScopedCpuTensorHandle > m_ForgetGateBias
A unique pointer to represent 1D bias tensor with dimensions [outputSize] (int32).
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *LayerCreateWorkload.
Definition: Layer.hpp:344
std::unique_ptr< ScopedCpuTensorHandle > m_InputGateBias
A unique pointer to represent 1D bias tensor with dimensions [outputSize] (int32).
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, outputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, outputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, outputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_InputToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, inputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_OutputGateBias
A unique pointer to represent 1D bias tensor with dimensions [outputSize] (int32).
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, outputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_InputToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, inputSize] (QAsymm8)...
QuantizedLstmParameters m_QuantizedLstmParameters
std::unique_ptr< ScopedCpuTensorHandle > m_InputToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, inputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_InputToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, inputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_CellBias
A unique pointer to represent 1D bias tensor with dimensions [outputSize] (int32).

◆ GetConstantTensorsByRef()

Layer::ConstantTensors GetConstantTensorsByRef ( )
overrideprotectedvirtual

Retrieve the handles to the constant values stored by the layer.

Returns
A vector of the constant tensors stored by this layer.

Reimplemented from Layer.

Definition at line 147 of file QuantizedLstmLayer.cpp.

References QuantizedLstmParameters::m_CellBias, QuantizedLstmParameters::m_ForgetGateBias, QuantizedLstmParameters::m_InputGateBias, QuantizedLstmParameters::m_InputToCellWeights, QuantizedLstmParameters::m_InputToForgetWeights, QuantizedLstmParameters::m_InputToInputWeights, QuantizedLstmParameters::m_InputToOutputWeights, QuantizedLstmParameters::m_OutputGateBias, QuantizedLstmLayer::m_QuantizedLstmParameters, QuantizedLstmParameters::m_RecurrentToCellWeights, QuantizedLstmParameters::m_RecurrentToForgetWeights, QuantizedLstmParameters::m_RecurrentToInputWeights, and QuantizedLstmParameters::m_RecurrentToOutputWeights.

148 {
149  return
150  {
155 
160 
165  };
166 }
std::unique_ptr< ScopedCpuTensorHandle > m_ForgetGateBias
A unique pointer to represent 1D bias tensor with dimensions [outputSize] (int32).
std::unique_ptr< ScopedCpuTensorHandle > m_InputGateBias
A unique pointer to represent 1D bias tensor with dimensions [outputSize] (int32).
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, outputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, outputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, outputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_InputToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, inputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_OutputGateBias
A unique pointer to represent 1D bias tensor with dimensions [outputSize] (int32).
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, outputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_InputToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, inputSize] (QAsymm8)...
QuantizedLstmParameters m_QuantizedLstmParameters
std::unique_ptr< ScopedCpuTensorHandle > m_InputToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, inputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_InputToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, inputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_CellBias
A unique pointer to represent 1D bias tensor with dimensions [outputSize] (int32).

◆ InferOutputShapes()

std::vector< TensorShape > InferOutputShapes ( const std::vector< TensorShape > &  inputShapes) const
overridevirtual

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.

Parameters
[in]inputShapesThe input shapes layer has.
Returns
A vector to the inferred output shape.

Reimplemented from Layer.

Definition at line 79 of file QuantizedLstmLayer.cpp.

Referenced by QuantizedLstmInferOutputShapeImpl(), and QuantizedLstmLayer::ValidateTensorShapesFromInputs().

80 {
81  BOOST_ASSERT(inputShapes.size() == 3);
82 
83  // Get input values for validation
84  unsigned int numBatches = inputShapes[0][0];
85  unsigned int outputSize = inputShapes[1][1];
86 
87  std::vector<TensorShape> outShapes;
88  outShapes.push_back(TensorShape({numBatches, outputSize})); // cellStateOut
89  outShapes.push_back(TensorShape({numBatches, outputSize})); // output
90 
91  return outShapes;
92 }

◆ ValidateTensorShapesFromInputs()

void ValidateTensorShapesFromInputs ( )
overridevirtual

Check if the input tensor shape(s) will lead to a valid configuration of QuantizedLstmLayer.

Implements Layer.

Definition at line 94 of file QuantizedLstmLayer.cpp.

References CHECK_LOCATION, InputSlot::GetConnection(), Layer::GetInputSlot(), Layer::GetOutputSlot(), TensorInfo::GetShape(), IOutputSlot::GetTensorInfo(), OutputSlot::GetTensorInfo(), QuantizedLstmLayer::InferOutputShapes(), QuantizedLstmParameters::m_CellBias, QuantizedLstmParameters::m_ForgetGateBias, QuantizedLstmParameters::m_InputGateBias, QuantizedLstmParameters::m_InputToCellWeights, QuantizedLstmParameters::m_InputToForgetWeights, QuantizedLstmParameters::m_InputToInputWeights, QuantizedLstmParameters::m_InputToOutputWeights, QuantizedLstmParameters::m_OutputGateBias, QuantizedLstmLayer::m_QuantizedLstmParameters, QuantizedLstmParameters::m_RecurrentToCellWeights, QuantizedLstmParameters::m_RecurrentToForgetWeights, QuantizedLstmParameters::m_RecurrentToInputWeights, QuantizedLstmParameters::m_RecurrentToOutputWeights, and Layer::VerifyLayerConnections().

95 {
97 
98  auto inferredShapes = InferOutputShapes(
99  {
101  GetInputSlot(1).GetConnection()->GetTensorInfo().GetShape(), // previousCellStateIn
102  GetInputSlot(2).GetConnection()->GetTensorInfo().GetShape() // previousOutputIn
103  });
104 
105  BOOST_ASSERT(inferredShapes.size() == 2);
106 
107  // Check weights and bias for nullptr
108  BOOST_ASSERT_MSG(m_QuantizedLstmParameters.m_InputToInputWeights != nullptr,
109  "QuantizedLstmLayer: m_QuantizedLstmParameters.m_InputToInputWeights should not be null.");
110  BOOST_ASSERT_MSG(m_QuantizedLstmParameters.m_InputToForgetWeights != nullptr,
111  "QuantizedLstmLayer: m_QuantizedLstmParameters.m_InputToForgetWeights should not be null.");
112  BOOST_ASSERT_MSG(m_QuantizedLstmParameters.m_InputToCellWeights != nullptr,
113  "QuantizedLstmLayer: m_QuantizedLstmParameters.m_InputToCellWeights should not be null.");
114  BOOST_ASSERT_MSG(m_QuantizedLstmParameters.m_InputToOutputWeights != nullptr,
115  "QuantizedLstmLayer: m_QuantizedLstmParameters.m_InputToOutputWeights should not be null.");
116 
117  BOOST_ASSERT_MSG(m_QuantizedLstmParameters.m_RecurrentToInputWeights != nullptr,
118  "QuantizedLstmLayer: m_QuantizedLstmParameters.m_RecurrentToInputWeights should not be null.");
119  BOOST_ASSERT_MSG(m_QuantizedLstmParameters.m_RecurrentToForgetWeights != nullptr,
120  "QuantizedLstmLayer: m_QuantizedLstmParameters.m_RecurrentToForgetWeights should not be null.");
121  BOOST_ASSERT_MSG(m_QuantizedLstmParameters.m_RecurrentToCellWeights != nullptr,
122  "QuantizedLstmLayer: m_QuantizedLstmParameters.m_RecurrentToCellWeights should not be null.");
123  BOOST_ASSERT_MSG(m_QuantizedLstmParameters.m_RecurrentToOutputWeights != nullptr,
124  "QuantizedLstmLayer: m_QuantizedLstmParameters.m_RecurrentToOutputWeights should not be null.");
125 
126  BOOST_ASSERT_MSG(m_QuantizedLstmParameters.m_InputGateBias != nullptr,
127  "QuantizedLstmLayer: m_QuantizedLstmParameters.m_InputGateBias should not be null.");
128  BOOST_ASSERT_MSG(m_QuantizedLstmParameters.m_ForgetGateBias != nullptr,
129  "QuantizedLstmLayer: m_QuantizedLstmParameters.m_ForgetGateBias should not be null.");
130  BOOST_ASSERT_MSG(m_QuantizedLstmParameters.m_CellBias != nullptr,
131  "QuantizedLstmLayer: m_QuantizedLstmParameters.m_CellBias should not be null.");
132  BOOST_ASSERT_MSG(m_QuantizedLstmParameters.m_OutputGateBias != nullptr,
133  "QuantizedLstmLayer: m_QuantizedLstmParameters.m_OutputGateBias should not be null.");
134 
135  // Check output TensorShape(s) match inferred shape
136  ConditionalThrowIfNotEqual<LayerValidationException>(
137  "QuantizedLstmLayer: TensorShape set on OutputSlot[0] does not match the inferred shape.",
139  inferredShapes[0]);
140 
141  ConditionalThrowIfNotEqual<LayerValidationException>(
142  "QuantizedLstmLayer: TensorShape set on OutputSlot[1] does not match the inferred shape.",
144  inferredShapes[1]);
145 }
std::unique_ptr< ScopedCpuTensorHandle > m_ForgetGateBias
A unique pointer to represent 1D bias tensor with dimensions [outputSize] (int32).
virtual const TensorInfo & GetTensorInfo() const =0
std::unique_ptr< ScopedCpuTensorHandle > m_InputGateBias
A unique pointer to represent 1D bias tensor with dimensions [outputSize] (int32).
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, outputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, outputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, outputSize] (QAsymm8)...
#define CHECK_LOCATION()
Definition: Exceptions.hpp:169
std::vector< TensorShape > InferOutputShapes(const std::vector< TensorShape > &inputShapes) const override
const IOutputSlot * GetConnection() const override
Definition: Layer.hpp:199
std::unique_ptr< ScopedCpuTensorHandle > m_InputToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, inputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_OutputGateBias
A unique pointer to represent 1D bias tensor with dimensions [outputSize] (int32).
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, outputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_InputToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, inputSize] (QAsymm8)...
void VerifyLayerConnections(unsigned int expectedConnections, const CheckLocation &location) const
Definition: Layer.cpp:337
QuantizedLstmParameters m_QuantizedLstmParameters
std::unique_ptr< ScopedCpuTensorHandle > m_InputToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, inputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_InputToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, inputSize] (QAsymm8)...
const TensorShape & GetShape() const
Definition: Tensor.hpp:88
const TensorInfo & GetTensorInfo() const override
Definition: Layer.cpp:63
std::unique_ptr< ScopedCpuTensorHandle > m_CellBias
A unique pointer to represent 1D bias tensor with dimensions [outputSize] (int32).
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Definition: Layer.hpp:312
const InputSlot & GetInputSlot(unsigned int index) const override
Definition: Layer.hpp:310

Member Data Documentation

◆ m_QuantizedLstmParameters


The documentation for this class was generated from the following files: