104 if (!m_Param.m_CifgEnabled)
114 if (m_Param.m_ProjectionEnabled)
122 if (m_Param.m_PeepholeEnabled)
124 if (!m_Param.m_CifgEnabled)
135 if (m_Param.m_LayerNormEnabled)
147 return std::move(layer);
155 unsigned int batchSize = inputShapes[0][0];
156 unsigned int outputSize = inputShapes[1][1];
157 unsigned int numUnits = inputShapes[2][1];
159 std::vector<TensorShape> outShapes;
161 outShapes.push_back(
TensorShape({batchSize, outputSize}));
162 outShapes.push_back(
TensorShape({batchSize, numUnits}));
163 outShapes.push_back(
TensorShape({batchSize, outputSize}));
186 "LstmLayer: m_BasicParameters.m_InputToForgetWeights should not be null.");
188 "LstmLayer: m_BasicParameters.m_InputToCellWeights should not be null.");
190 "LstmLayer: m_BasicParameters.m_InputToOutputWeights should not be null.");
192 "LstmLayer: m_BasicParameters.m_RecurrentToForgetWeights should not be null.");
194 "LstmLayer: m_BasicParameters.m_RecurrentToCellWeights should not be null.");
196 "LstmLayer: m_BasicParameters.m_RecurrentToOutputWeights should not be null.");
198 "LstmLayer: m_BasicParameters.m_ForgetGateBias should not be null.");
200 "LstmLayer: m_BasicParameters.m_CellBias should not be null.");
202 "LstmLayer: m_BasicParameters.m_OutputGateBias should not be null.");
207 "LstmLayer: m_CifgParameters.m_InputToInputWeights should not be null.");
209 "LstmLayer: m_CifgParameters.m_RecurrentToInputWeights should not be null.");
211 "LstmLayer: m_CifgParameters.m_InputGateBias should not be null.");
218 "LstmLayer: m_CifgParameters.m_InputToInputWeights should not have a value when CIFG is enabled.");
220 "LstmLayer: m_CifgParameters.m_RecurrentToInputWeights should not have a value when CIFG is enabled.");
222 "LstmLayer: m_CifgParameters.m_InputGateBias should not have a value when CIFG is enabled.");
230 "LstmLayer: m_ProjectionParameters.m_ProjectionWeights should not be null.");
238 "LstmLayer: m_PeepholeParameters.m_CellToInputWeights should not be null " 239 "when Peephole is enabled and CIFG is disabled.");
242 "LstmLayer: m_PeepholeParameters.m_CellToForgetWeights should not be null.");
244 "LstmLayer: m_PeepholeParameters.m_CellToOutputWeights should not be null.");
259 "LstmLayer: m_LayerNormParameters.m_inputLayerNormWeights should not be null.");
262 "LstmLayer: m_LayerNormParameters.m_forgetLayerNormWeights should not be null.");
264 "LstmLayer: m_LayerNormParameters.m_cellLayerNormWeights should not be null.");
266 "LstmLayer: m_LayerNormParameters.m_outputLayerNormWeights should not be null.");
311 inputToInputWeightsTensor = inputToInputWeightsTensorCopy;
319 inputToForgetWeightsTensor = inputToForgetWeightsTensorCopy;
327 inputToCellWeightsTensor = inputToCellWeightsTensorCopy;
335 inputToOutputWeightsTensor = inputToOutputWeightsTensorCopy;
344 recurrentToInputWeightsTensor = recurrentToInputWeightsTensorCopy;
353 recurrentToForgetWeightsTensor = recurrentToForgetWeightsTensorCopy;
362 recurrentToCellWeightsTensor = recurrentToCellWeightsTensorCopy;
371 recurrentToOutputWeightsTensor = recurrentToOutputWeightsTensorCopy;
379 cellToInputWeightsTensor = cellToInputWeightsTensorCopy;
387 cellToForgetWeightsTensor = cellToForgetWeightsTensorCopy;
395 cellToOutputWeightsTensor = cellToOutputWeightsTensorCopy;
403 inputGateBiasTensor = inputGateBiasTensorCopy;
411 forgetGateBiasTensor = forgetGateBiasTensorCopy;
419 cellBiasTensor = cellBiasTensorCopy;
427 outputGateBias = outputGateBiasCopy;
435 projectionWeightsTensor = projectionWeightsTensorCopy;
443 projectionBiasTensor = projectionBiasTensorCopy;
451 inputLayerNormTensor = inputLayerNormTensorCopy;
459 forgetLayerNormTensor = forgetLayerNormTensorCopy;
467 cellLayerNormTensor = cellLayerNormTensorCopy;
475 outputLayerNormTensor = outputLayerNormTensorCopy;
std::unique_ptr< ScopedCpuTensorHandle > m_ForgetGateBias
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::unique_ptr< ScopedCpuTensorHandle > m_InputToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units].
bool m_ProjectionEnabled
Enable/disable the projection layer.
LstmBasicParameters m_BasicParameters
LstmDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).
const LstmDescriptor & GetParameters() const
const TensorShape & GetShape() const
std::unique_ptr< ScopedCpuTensorHandle > m_InputToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
const ConstCpuTensorHandle * m_RecurrentToForgetWeights
const ConstCpuTensorHandle * m_CellToOutputWeights
const ConstCpuTensorHandle * m_InputToCellWeights
const ConstCpuTensorHandle * m_InputToOutputWeights
std::unique_ptr< ScopedCpuTensorHandle > m_CellLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
virtual void VisitLstmLayer(const IConnectableLayer *layer, const LstmDescriptor &descriptor, const LstmInputParams ¶ms, const char *name=nullptr)=0
Function an Lstm layer should call back to when its Accept(ILayerVisitor&) function is invoked...
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units].
const ConstCpuTensorHandle * m_ProjectionBias
virtual std::unique_ptr< IWorkload > CreateLstm(const LstmQueueDescriptor &descriptor, const WorkloadInfo &info) const
const ConstCpuTensorHandle * m_OutputGateBias
const ConstCpuTensorHandle * m_CellToInputWeights
std::unique_ptr< ScopedCpuTensorHandle > m_OutputGateBias
A unique pointer to represent 1D weights tensor with dimensions [num_units].
virtual std::unique_ptr< IWorkload > CreateWorkload(const IWorkloadFactory &factory) const override
Makes a workload for the LSTM type.
const ConstCpuTensorHandle * m_CellLayerNormWeights
std::unique_ptr< ScopedCpuTensorHandle > m_InputLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
void VerifyShapeInferenceType(const TensorShape &outputShape, ShapeInferenceMethod shapeInferenceMethod)
Copyright (c) 2020 ARM Limited.
This layer represents a LSTM operation.
const ConstCpuTensorHandle * m_CellToForgetWeights
const ConstCpuTensorHandle * m_CellBias
const ConstCpuTensorHandle * m_RecurrentToInputWeights
std::unique_ptr< ScopedCpuTensorHandle > m_CellBias
A unique pointer to represent 1D weights tensor with dimensions [num_units].
void ValidateAndCopyShape(const TensorShape &outputShape, const TensorShape &inferredShape, const ShapeInferenceMethod shapeInferenceMethod, const std::string &layerName, const unsigned int outputSlotIndex=0)
void VerifyLayerConnections(unsigned int expectedConnections, const CheckLocation &location) const
std::unique_ptr< ScopedCpuTensorHandle > m_CellToForgetWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
std::unique_ptr< ScopedCpuTensorHandle > m_OutputLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
const ConstCpuTensorHandle * m_InputLayerNormWeights
void ValidateTensorShapesFromInputs() override
Check if the input tensor shape(s) will lead to a valid configuration of LstmLayer.
const ConstCpuTensorHandle * m_OutputLayerNormWeights
LstmLayer * Clone(Graph &graph) const override
Creates a dynamically-allocated copy of this layer.
An LstmDescriptor for the LstmLayer.
#define ARMNN_ASSERT_MSG(COND, MSG)
const ConstCpuTensorHandle * m_ForgetGateBias
std::unique_ptr< ScopedCpuTensorHandle > m_CellToInputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
const ConstCpuTensorHandle * m_InputToInputWeights
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
bool m_PeepholeEnabled
Enable/disable peephole.
#define ARMNN_ASSERT(COND)
LstmOptLayerNormParameters m_LayerNormParameters
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
Layer::ConstantTensors GetConstantTensorsByRef() override
Retrieve the handles to the constant values stored by the layer.
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units].
LstmOptPeepholeParameters m_PeepholeParameters
void SetAdditionalInfo(QueueDescriptor &descriptor) const
LstmOptProjectionParameters m_ProjectionParameters
std::unique_ptr< ScopedCpuTensorHandle > m_ProjectionBias
A unique pointer to represent 1D weights tensor with dimensions [output_size].
bool m_CifgEnabled
Enable/disable cifg (coupled input & forget gate).
const ConstCpuTensorHandle * m_RecurrentToOutputWeights
void Accept(ILayerVisitor &visitor) const override
Apply a visitor to this layer.
std::unique_ptr< ScopedCpuTensorHandle > m_InputToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
const ConstCpuTensorHandle * m_ForgetLayerNormWeights
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *LayerCreateWorkload.
const ConstCpuTensorHandle * m_InputGateBias
std::unique_ptr< ScopedCpuTensorHandle > m_CellToOutputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
LstmLayer(const LstmDescriptor ¶m, const char *name)
Constructor to create a LstmLayer.
bool m_LayerNormEnabled
Enable/disable layer normalization.
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
std::unique_ptr< ScopedCpuTensorHandle > m_ProjectionWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units].
virtual const TensorInfo & GetTensorInfo() const =0
const ConstCpuTensorHandle * m_RecurrentToCellWeights
std::unique_ptr< ScopedCpuTensorHandle > m_ForgetLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
LstmOptCifgParameters m_CifgParameters
const char * GetName() const override
Returns the name of the layer.
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.
std::vector< std::reference_wrapper< std::unique_ptr< ScopedCpuTensorHandle > >> ConstantTensors
const TensorInfo & GetTensorInfo(const ITensorHandle *tensorHandle)
float32 helpers
const TensorInfo & GetTensorInfo() const override
std::unique_ptr< ScopedCpuTensorHandle > m_InputToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
std::unique_ptr< ScopedCpuTensorHandle > m_InputGateBias
A unique pointer to represent 1D weights tensor with dimensions [num_units].
ShapeInferenceMethod m_ShapeInferenceMethod
const ConstCpuTensorHandle * m_ProjectionWeights
const ConstCpuTensorHandle * m_InputToForgetWeights