24.08
|
Go to the documentation of this file.
82 auto layer = CloneBase<UnidirectionalSequenceLstmLayer>(graph,
m_Param,
GetName());
147 return std::move(layer);
151 const std::vector<TensorShape>& inputShapes)
const
154 "inputShapes' size is \"" + std::to_string(inputShapes.size()) +
155 "\" - should be \"3\".");
158 unsigned int outputSize = inputShapes[1][1];
160 std::vector<TensorShape> outShapes;
163 outShapes.push_back(
TensorShape({inputShapes[0][0], inputShapes[0][1], outputSize}));
167 outShapes.push_back(
TensorShape({inputShapes[0][0], inputShapes[0][1], outputSize}));
186 if (inferredShapes.size() != 1)
189 + std::to_string(inferredShapes.size()) +
190 " elements - should only have 1.");
197 "m_BasicParameters.m_InputToForgetWeights should not be null.");
203 "m_BasicParameters.m_InputToCellWeights should not be null.");
209 "m_BasicParameters.m_InputToOutputWeights should not be null.");
215 "m_BasicParameters.m_RecurrentToForgetWeights should not be null.");
221 "m_BasicParameters.m_RecurrentToCellWeights should not be null.");
227 "m_BasicParameters.m_RecurrentToOutputWeights should not be null.");
233 "m_BasicParameters.m_ForgetGateBias should not be null.");
239 "m_BasicParameters.m_CellBias should not be null.");
245 "m_BasicParameters.m_OutputGateBias should not be null.");
253 "m_CifgParameters.m_InputToInputWeights should not be null.");
259 "m_CifgParameters.m_RecurrentToInputWeights should not be null.");
265 "m_CifgParameters.m_InputGateBias should not be null.");
273 "m_CifgParameters.m_InputToInputWeights should not have a value "
274 "when CIFG is enabled.");
280 "m_CifgParameters.m_RecurrentToInputWeights should not have a value "
281 "when CIFG is enabled.");
287 "m_CifgParameters.m_InputGateBias should not have a value "
288 "when CIFG is enabled.");
297 "m_ProjectionParameters.m_ProjectionWeights should not be null.");
308 "m_PeepholeParameters.m_CellToInputWeights should not be null "
309 "when Peephole is enabled and CIFG is disabled.");
316 "m_PeepholeParameters.m_CellToForgetWeights should not be null.");
322 "m_PeepholeParameters.m_CellToOutputWeights should not be null.");
333 "m_LayerNormParameters.m_inputLayerNormWeights "
334 "should not be null.");
341 "m_LayerNormParameters.m_forgetLayerNormWeights "
342 "should not be null.");
348 "m_LayerNormParameters.m_cellLayerNormWeights "
349 "should not be null.");
355 "m_LayerNormParameters.m_outputLayerNormWeights "
356 "should not be null.");
399 std::vector<ConstTensor> constTensors;
437 managedInputToForgetWeights.
Map()));
442 managedInputToCellWeights.
Map()));
447 managedInputToOutputWeights.
Map()));
453 managedRecurrentToForgetWeights.
Map()));
459 managedRecurrentToCellWeights.
Map()));
465 managedRecurrentToOutputWeights.
Map()));
470 managedForgetGateBias.
Map()));
475 managedCellBias.
Map()));
480 managedOutputGateBias.
Map()));
489 managedInputToInputWeights.
Map()));
495 managedRecurrentToInputWeights.
Map()));
500 managedInputGateBias.
Map()));
512 managedCellToInputWeights.
Map()));
518 managedCellToForgetWeights.
Map()));
523 managedCellToOutputWeights.
Map()));
533 managedProjectionWeights.
Map()));
538 managedProjectionBias.
Map()));
550 managedInputLayerNormWeights.
Map()));
556 managedForgetLayerNormWeights.
Map()));
561 managedCellLayerNormWeights.
Map()));
566 managedOutputLayerNormWeights.
Map()));
UnidirectionalSequenceLstmLayer * Clone(Graph &graph) const override
Creates a dynamically-allocated copy of this layer.
const ConstTensorHandle * m_CellBias
const ConstTensorHandle * m_RecurrentToCellWeights
std::shared_ptr< ConstTensorHandle > m_ProjectionWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units].
std::shared_ptr< ConstTensorHandle > m_OutputLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
bool m_TimeMajor
Enable/disable time major.
const TensorInfo & GetTensorInfo() const override
std::shared_ptr< ConstTensorHandle > m_InputToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
std::shared_ptr< ConstTensorHandle > m_InputLayerNormWeights
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 UnidirectionalSequence LSTM type.
std::shared_ptr< ConstTensorHandle > m_InputGateBias
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_CellToInputWeights
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)
LstmBasicParameters m_BasicParameters
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
Layer::ImmutableConstantTensors GetConstantTensorsByRef() const override
Retrieve the handles to the constant values stored by the layer.
const ConstTensorHandle * m_InputLayerNormWeights
const ConstTensorHandle * m_InputToOutputWeights
const ConstTensorHandle * m_OutputLayerNormWeights
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
const LstmDescriptor & GetParameters() const override
std::shared_ptr< ConstTensorHandle > m_ProjectionBias
A unique pointer to represent 1D weights tensor with dimensions [output_size].
std::shared_ptr< ConstTensorHandle > m_InputToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
const ConstTensorHandle * m_OutputGateBias
const ConstTensorHandle * m_ForgetLayerNormWeights
const char * GetName() const override
Returns the name of the layer.
const ConstTensorHandle * m_InputToForgetWeights
const ConstTensorHandle * m_RecurrentToOutputWeights
std::vector< std::reference_wrapper< const std::shared_ptr< ConstTensorHandle > >> ImmutableConstantTensors
std::shared_ptr< ConstTensorHandle > m_ForgetGateBias
A unique pointer to represent 1D weights tensor with dimensions [num_units].
const ConstTensorHandle * m_ProjectionWeights
std::shared_ptr< ConstTensorHandle > m_CellLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
bool m_PeepholeEnabled
Enable/disable peephole.
LstmDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).
std::shared_ptr< ConstTensorHandle > m_RecurrentToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *Layer::CreateWorkload.
void VerifyShapeInferenceType(const TensorShape &outputShape, ShapeInferenceMethod shapeInferenceMethod)
const ConstTensorHandle * m_ForgetGateBias
const ConstTensorHandle * m_InputGateBias
const void * Map(bool blocking=true)
RAII Managed resource Unmaps MemoryArea once out of scope.
void SetAdditionalInfo(QueueDescriptor &descriptor) const
const ConstTensorHandle * m_CellToInputWeights
UnidirectionalSequenceLstmLayer(const LstmDescriptor ¶m, const char *name)
Constructor to create a UnidirectionalSequenceLstmLayer.
const ConstTensorHandle * m_CellToOutputWeights
LstmOptPeepholeParameters m_PeepholeParameters
std::shared_ptr< ConstTensorHandle > m_OutputGateBias
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_CellBias
A unique pointer to represent 1D weights tensor with dimensions [num_units].
This layer represents a LSTM operation.
const ConstTensorHandle * m_RecurrentToForgetWeights
const ConstTensorHandle * m_CellToForgetWeights
const ConstTensorHandle * m_RecurrentToInputWeights
const ConstTensorHandle * m_InputToInputWeights
std::shared_ptr< ConstTensorHandle > m_InputToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
void ExecuteStrategy(IStrategy &strategy) const override
Apply a visitor to this layer.
std::shared_ptr< ConstTensorHandle > m_InputToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
An LstmDescriptor for the LstmLayer.
bool m_CifgEnabled
Enable/disable cifg (coupled input & forget gate).
std::shared_ptr< ConstTensorHandle > m_RecurrentToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units].
std::shared_ptr< ConstTensorHandle > m_RecurrentToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units].
const TensorShape & GetShape() const
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,...
std::shared_ptr< ConstTensorHandle > m_RecurrentToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units].
bool m_LayerNormEnabled
Enable/disable layer normalization.
const ConstTensorHandle * m_ProjectionBias
@ UnidirectionalSequenceLstm
std::shared_ptr< ConstTensorHandle > m_CellToOutputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
Copyright (c) 2021 ARM Limited and Contributors.
LstmOptLayerNormParameters m_LayerNormParameters
std::shared_ptr< ConstTensorHandle > m_ForgetLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
LstmOptCifgParameters m_CifgParameters
bool m_ProjectionEnabled
Enable/disable the projection layer.
const ConstTensorHandle * m_InputToCellWeights
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
void VerifyLayerConnections(unsigned int expectedConnections, const CheckLocation &location) const
ShapeInferenceMethod m_ShapeInferenceMethod
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below.
const ConstTensorHandle * m_CellLayerNormWeights
void ValidateTensorShapesFromInputs() override
Check if the input tensor shape(s) will lead to a valid configuration of UnidirectionalSequenceLstmLa...
virtual std::unique_ptr< IWorkload > CreateWorkload(LayerType type, const QueueDescriptor &descriptor, const WorkloadInfo &info) const =0
Backends should implement their own CreateWorkload function with a switch statement.
virtual void ExecuteStrategy(const IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0)=0
std::shared_ptr< ConstTensorHandle > m_CellToForgetWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
const TensorInfo & GetTensorInfo() const
LstmOptProjectionParameters m_ProjectionParameters
#define ARMNN_THROW_INVALIDARG_MSG_IF_FALSE(_cond, _str)