24.08
|
Go to the documentation of this file.
147 return std::move(layer);
152 if (inputShapes.size() != 3)
154 throw armnn::Exception(
"inputShapes' size is \"" + std::to_string(inputShapes.size()) +
155 "\" - should be \"3\".");
159 unsigned int batchSize = inputShapes[0][0];
160 unsigned int outputSize = inputShapes[1][1];
161 unsigned int numUnits = inputShapes[2][1];
163 std::vector<TensorShape> outShapes;
165 outShapes.push_back(
TensorShape({batchSize, outputSize}));
166 outShapes.push_back(
TensorShape({batchSize, numUnits}));
167 outShapes.push_back(
TensorShape({batchSize, outputSize}));
186 if (inferredShapes.size() != 4)
189 + std::to_string(inferredShapes.size()) +
190 " element(s) - should only have 4.");
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.");
275 "m_CifgParameters.m_InputToInputWeights should not have a value "
276 "when CIFG is enabled.");
282 "m_CifgParameters.m_RecurrentToInputWeights should not have a value "
283 "when CIFG is enabled.");
289 "m_CifgParameters.m_InputGateBias should not have a value "
290 "when CIFG is enabled.");
301 "m_ProjectionParameters.m_ProjectionWeights should not be null.");
312 "m_PeepholeParameters.m_CellToInputWeights should not be null "
313 "when Peephole is enabled and CIFG is disabled.");
320 "m_PeepholeParameters.m_CellToForgetWeights should not be null.");
326 "m_PeepholeParameters.m_CellToOutputWeights should not be null.");
344 "m_LayerNormParameters.m_inputLayerNormWeights should not be null.");
351 "m_LayerNormParameters.m_forgetLayerNormWeights should not be null.");
357 "m_LayerNormParameters.m_cellLayerNormWeights should not be null.");
363 "m_LayerNormParameters.m_outputLayerNormWeights should not be null.");
404 std::vector<ConstTensor> constTensors;
442 managedInputToForgetWeights.
Map()));
447 managedInputToCellWeights.
Map()));
452 managedInputToOutputWeights.
Map()));
458 managedRecurrentToForgetWeights.
Map()));
464 managedRecurrentToCellWeights.
Map()));
470 managedRecurrentToOutputWeights.
Map()));
475 managedForgetGateBias.
Map()));
480 managedCellBias.
Map()));
485 managedOutputGateBias.
Map()));
494 managedInputToInputWeights.
Map()));
500 managedRecurrentToInputWeights.
Map()));
505 managedInputGateBias.
Map()));
517 managedCellToInputWeights.
Map()));
523 managedCellToForgetWeights.
Map()));
528 managedCellToOutputWeights.
Map()));
538 managedProjectionWeights.
Map()));
543 managedProjectionBias.
Map()));
555 managedInputLayerNormWeights.
Map()));
561 managedForgetLayerNormWeights.
Map()));
566 managedCellLayerNormWeights.
Map()));
571 managedOutputLayerNormWeights.
Map()));
const ConstTensorHandle * m_ForgetLayerNormWeights
const ConstTensorHandle * m_CellBias
LstmOptProjectionParameters m_ProjectionParameters
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].
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].
LstmLayer * Clone(Graph &graph) const override
Creates a dynamically-allocated copy of this layer.
std::shared_ptr< ConstTensorHandle > m_InputLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
const ConstTensorHandle * m_InputToInputWeights
const ConstTensorHandle * m_ForgetGateBias
LstmOptLayerNormParameters m_LayerNormParameters
void ExecuteStrategy(IStrategy &strategy) const override
Apply a visitor to this layer.
const ConstTensorHandle * m_InputToForgetWeights
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)
Layer::ImmutableConstantTensors GetConstantTensorsByRef() const override
Retrieve the handles to the constant values stored by the layer.
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
const ConstTensorHandle * m_InputToCellWeights
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].
LstmOptCifgParameters m_CifgParameters
const ConstTensorHandle * m_CellToOutputWeights
const char * GetName() const override
Returns the name of the layer.
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].
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.).
This layer represents a LSTM operation.
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 TensorInfo & GetTensorInfo(const ITensorHandle *tensorHandle)
float32 helpers
const void * Map(bool blocking=true)
RAII Managed resource Unmaps MemoryArea once out of scope.
void SetAdditionalInfo(QueueDescriptor &descriptor) const
const ConstTensorHandle * m_InputGateBias
Base class for all ArmNN exceptions so that users can filter to just those.
const ConstTensorHandle * m_RecurrentToCellWeights
const ConstTensorHandle * m_CellLayerNormWeights
LstmLayer(const LstmDescriptor ¶m, const char *name)
Constructor to create a LstmLayer.
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].
std::shared_ptr< ConstTensorHandle > m_InputToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
LstmBasicParameters m_BasicParameters
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).
const ConstTensorHandle * m_RecurrentToOutputWeights
std::shared_ptr< ConstTensorHandle > m_RecurrentToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units].
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_RecurrentToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units].
const TensorShape & GetShape() const
std::shared_ptr< ConstTensorHandle > m_RecurrentToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units].
const ConstTensorHandle * m_InputLayerNormWeights
bool m_LayerNormEnabled
Enable/disable layer normalization.
const ConstTensorHandle * m_RecurrentToForgetWeights
const ConstTensorHandle * m_CellToInputWeights
const ConstTensorHandle * m_ProjectionWeights
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.
std::shared_ptr< ConstTensorHandle > m_ForgetLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
const ConstTensorHandle * m_RecurrentToInputWeights
bool m_ProjectionEnabled
Enable/disable the projection layer.
const ConstTensorHandle * m_ProjectionBias
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
void VerifyLayerConnections(unsigned int expectedConnections, const CheckLocation &location) const
const ConstTensorHandle * m_OutputGateBias
LstmOptPeepholeParameters m_PeepholeParameters
const ConstTensorHandle * m_CellToForgetWeights
const ConstTensorHandle * m_InputToOutputWeights
const ConstTensorHandle * m_OutputLayerNormWeights
ShapeInferenceMethod m_ShapeInferenceMethod
void ValidateTensorShapesFromInputs() override
Check if the input tensor shape(s) will lead to a valid configuration of LstmLayer.
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below.
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
virtual std::unique_ptr< IWorkload > CreateWorkload(const IWorkloadFactory &factory) const override
Makes a workload for the LSTM type.