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)
137 if (!m_Param.m_CifgEnabled) {
150 return std::move(layer);
158 unsigned int batchSize = inputShapes[0][0];
159 unsigned int outputSize = inputShapes[1][1];
160 unsigned int numUnits = inputShapes[2][1];
162 std::vector<TensorShape> outShapes;
163 outShapes.push_back(
TensorShape({ batchSize, outputSize }));
164 outShapes.push_back(
TensorShape({ batchSize, numUnits }));
165 outShapes.push_back(
TensorShape({ batchSize, outputSize }));
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.");
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.");
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.");
234 "QLstmLayer: m_ProjectionParameters.m_ProjectionWeights should not be null.");
241 "QLstmLayer: m_PeepholeParameters.m_CellToInputWeights should not be null " 242 "when Peephole is enabled and CIFG is disabled.");
246 "QLstmLayer: m_PeepholeParameters.m_CellToForgetWeights should not be null.");
248 "QLstmLayer: m_PeepholeParameters.m_CellToOutputWeights should not be null.");
261 "QLstmLayer: m_LayerNormParameters.m_InputLayerNormWeights should not be null.");
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.");
314 inputToInputWeightsTensor = inputToInputWeightsTensorCopy;
323 inputToForgetWeightsTensor = inputToForgetWeightsTensorCopy;
332 inputToCellWeightsTensor = inputToCellWeightsTensorCopy;
341 inputToOutputWeightsTensor = inputToOutputWeightsTensorCopy;
351 recurrentToInputWeightsTensor = recurrentToInputWeightsTensorCopy;
361 recurrentToForgetWeightsTensor = recurrentToForgetWeightsTensorCopy;
371 recurrentToCellWeightsTensor = recurrentToCellWeightsTensorCopy;
381 recurrentToOutputWeightsTensor = recurrentToOutputWeightsTensorCopy;
390 cellToInputWeightsTensor = cellToInputWeightsTensorCopy;
399 cellToForgetWeightsTensor = cellToForgetWeightsTensorCopy;
408 cellToOutputWeightsTensor = cellToOutputWeightsTensorCopy;
417 inputGateBiasTensor = inputGateBiasTensorCopy;
426 forgetGateBiasTensor = forgetGateBiasTensorCopy;
435 cellBiasTensor = cellBiasTensorCopy;
444 outputGateBias = outputGateBiasCopy;
453 projectionWeightsTensor = projectionWeightsTensorCopy;
462 projectionBiasTensor = projectionBiasTensorCopy;
471 inputLayerNormTensor = inputLayerNormTensorCopy;
480 forgetLayerNormTensor = forgetLayerNormTensorCopy;
489 cellLayerNormTensor = cellLayerNormTensorCopy;
498 outputLayerNormTensor = outputLayerNormTensorCopy;
const ConstCpuTensorHandle * m_CellToForgetWeights
virtual void VisitQLstmLayer(const IConnectableLayer *layer, const QLstmDescriptor &descriptor, const LstmInputParams ¶ms, const char *name=nullptr)=0
Function a QLstm layer should call back to when its Accept(ILayerVisitor&) function is invoked...
QLstmDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).
const QLstmDescriptor & GetParameters() const
const TensorShape & GetShape() const
const ConstCpuTensorHandle * m_ProjectionWeights
QLstmOptProjectionParameters m_ProjectionParameters
std::unique_ptr< ScopedCpuTensorHandle > m_OutputGateBias
A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32). ...
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units] (QSymmS8)...
std::unique_ptr< ScopedCpuTensorHandle > m_CellLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
bool m_PeepholeEnabled
Enable/disable peephole.
std::unique_ptr< ScopedCpuTensorHandle > m_InputLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
const ConstCpuTensorHandle * m_ProjectionBias
const ConstCpuTensorHandle * m_ForgetLayerNormWeights
std::unique_ptr< ScopedCpuTensorHandle > m_InputToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units] (QSymmS8)...
const ConstCpuTensorHandle * m_CellLayerNormWeights
std::unique_ptr< ScopedCpuTensorHandle > m_CellToOutputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
std::unique_ptr< ScopedCpuTensorHandle > m_ProjectionBias
A unique pointer to represent 1D weights tensor with dimensions [output_size] (int32).
std::unique_ptr< ScopedCpuTensorHandle > m_ProjectionWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units] (QSymmS8)...
const ConstCpuTensorHandle * m_RecurrentToCellWeights
virtual std::unique_ptr< IWorkload > CreateQLstm(const QLstmQueueDescriptor &descriptor, const WorkloadInfo &info) const
const ConstCpuTensorHandle * m_RecurrentToInputWeights
std::unique_ptr< ScopedCpuTensorHandle > m_InputToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8)...
std::unique_ptr< ScopedCpuTensorHandle > m_CellBias
A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32). ...
void VerifyShapeInferenceType(const TensorShape &outputShape, ShapeInferenceMethod shapeInferenceMethod)
const ConstCpuTensorHandle * m_OutputGateBias
const ConstCpuTensorHandle * m_CellBias
Copyright (c) 2020 ARM Limited.
std::unique_ptr< ScopedCpuTensorHandle > m_InputToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8)...
std::unique_ptr< ScopedCpuTensorHandle > m_OutputLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
void ValidateAndCopyShape(const TensorShape &outputShape, const TensorShape &inferredShape, const ShapeInferenceMethod shapeInferenceMethod, const std::string &layerName, const unsigned int outputSlotIndex=0)
QLstmOptLayerNormParameters m_LayerNormParameters
QLstmLayer * Clone(Graph &graph) const override
Creates a dynamically-allocated copy of this layer.
const ConstCpuTensorHandle * m_CellToOutputWeights
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8)...
const ConstCpuTensorHandle * m_OutputLayerNormWeights
void VerifyLayerConnections(unsigned int expectedConnections, const CheckLocation &location) const
std::unique_ptr< ScopedCpuTensorHandle > m_CellToInputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
bool m_LayerNormEnabled
Enable/disable layer normalization.
#define ARMNN_ASSERT_MSG(COND, MSG)
virtual std::unique_ptr< IWorkload > CreateWorkload(const IWorkloadFactory &factory) const override
Makes a workload for the QLstm type.
const ConstCpuTensorHandle * m_InputToForgetWeights
std::unique_ptr< ScopedCpuTensorHandle > m_CellToForgetWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
std::unique_ptr< ScopedCpuTensorHandle > m_InputGateBias
A unique pointer to represent 1D weights tensor with dimensions [num_units] (int32).
#define ARMNN_ASSERT(COND)
A QLstmDescriptor for the QLstmLayer.
std::unique_ptr< ScopedCpuTensorHandle > m_ForgetLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
void ValidateTensorShapesFromInputs() override
Check if the input tensor shape(s) will lead to a valid configuration of QLstmLayer.
QLstmLayer(const QLstmDescriptor ¶m, const char *name)
Constructor to create a QLstmLayer.
Layer::ConstantTensors GetConstantTensorsByRef() override
Retrieve the handles to the constant values stored by the layer.
std::unique_ptr< ScopedCpuTensorHandle > m_InputToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8)...
QLstmBasicParameters m_BasicParameters
const ConstCpuTensorHandle * m_CellToInputWeights
void SetAdditionalInfo(QueueDescriptor &descriptor) const
This layer represents a QLstm operation.
std::unique_ptr< ScopedCpuTensorHandle > m_ForgetGateBias
A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32). ...
const ConstCpuTensorHandle * m_RecurrentToOutputWeights
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8)...
bool m_ProjectionEnabled
Enable/disable the projection layer.
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *LayerCreateWorkload.
const ConstCpuTensorHandle * m_InputGateBias
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8)...
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
void Accept(ILayerVisitor &visitor) const override
Apply a visitor to this layer.
virtual const TensorInfo & GetTensorInfo() const =0
QLstmOptCifgParameters m_CifgParameters
QLstmOptPeepholeParameters m_PeepholeParameters
const char * GetName() const override
Returns the name of the layer.
const ConstCpuTensorHandle * m_InputLayerNormWeights
const ConstCpuTensorHandle * m_RecurrentToForgetWeights
std::vector< std::reference_wrapper< std::unique_ptr< ScopedCpuTensorHandle > >> ConstantTensors
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.
const ConstCpuTensorHandle * m_ForgetGateBias
const TensorInfo & GetTensorInfo(const ITensorHandle *tensorHandle)
float32 helpers
const TensorInfo & GetTensorInfo() const override
const ConstCpuTensorHandle * m_InputToOutputWeights
bool m_CifgEnabled
Enable/disable CIFG (coupled input & forget gate).
const ConstCpuTensorHandle * m_InputToInputWeights
ShapeInferenceMethod m_ShapeInferenceMethod
const ConstCpuTensorHandle * m_InputToCellWeights