102 if (!m_Param.m_CifgEnabled)
112 if (m_Param.m_ProjectionEnabled)
120 if (m_Param.m_PeepholeEnabled)
122 if (!m_Param.m_CifgEnabled) {
133 if (m_Param.m_LayerNormEnabled)
135 if (!m_Param.m_CifgEnabled) {
148 return std::move(layer);
156 unsigned int batchSize = inputShapes[0][0];
157 unsigned int outputSize = inputShapes[1][1];
158 unsigned int numUnits = inputShapes[2][1];
160 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 }));
183 "QLstmLayer: m_BasicParameters.m_InputToForgetWeights should not be null.");
185 "QLstmLayer: m_BasicParameters.m_InputToCellWeights should not be null.");
187 "QLstmLayer: m_BasicParameters.m_InputToOutputWeights should not be null.");
189 "QLstmLayer: m_BasicParameters.m_RecurrentToForgetWeights should not be null.");
191 "QLstmLayer: m_BasicParameters.m_RecurrentToCellWeights should not be null.");
193 "QLstmLayer: m_BasicParameters.m_RecurrentToOutputWeights should not be null.");
195 "QLstmLayer: m_BasicParameters.m_ForgetGateBias should not be null.");
197 "QLstmLayer: m_BasicParameters.m_CellBias should not be null.");
199 "QLstmLayer: m_BasicParameters.m_OutputGateBias should not be null.");
204 "QLstmLayer: m_CifgParameters.m_InputToInputWeights should not be null.");
206 "QLstmLayer: m_CifgParameters.m_RecurrentToInputWeights should not be null.");
208 "QLstmLayer: m_CifgParameters.m_InputGateBias should not be null.");
210 ConditionalThrowIfNotEqual<LayerValidationException>(
211 "QLstmLayer: TensorShape set on OutputSlot[0] does not match the inferred shape.",
218 "QLstmLayer: m_CifgParameters.m_InputToInputWeights should not have a value when CIFG is enabled.");
220 "QLstmLayer: m_CifgParameters.m_RecurrentToInputWeights should " 221 "not have a value when CIFG is enabled.");
223 "QLstmLayer: m_CifgParameters.m_InputGateBias should not have a value when CIFG is enabled.");
225 ConditionalThrowIfNotEqual<LayerValidationException>(
226 "QLstmLayer: TensorShape set on OutputSlot[0] does not match the inferred shape.",
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.");
251 ConditionalThrowIfNotEqual<LayerValidationException>(
252 "QLstmLayer: TensorShape set on OutputSlot[1] does not match the inferred shape.",
255 ConditionalThrowIfNotEqual<LayerValidationException>(
256 "QLstmLayer: TensorShape set on OutputSlot[2] does not match the inferred shape.",
265 "QLstmLayer: m_LayerNormParameters.m_InputLayerNormWeights should not be null.");
268 "QLstmLayer: m_LayerNormParameters.m_ForgetLayerNormWeights should not be null.");
270 "QLstmLayer: m_LayerNormParameters.m_CellLayerNormWeights should not be null.");
272 "QLstmLayer: m_LayerNormParameters.m_UutputLayerNormWeights should not be null.");
318 inputToInputWeightsTensor = inputToInputWeightsTensorCopy;
327 inputToForgetWeightsTensor = inputToForgetWeightsTensorCopy;
336 inputToCellWeightsTensor = inputToCellWeightsTensorCopy;
345 inputToOutputWeightsTensor = inputToOutputWeightsTensorCopy;
355 recurrentToInputWeightsTensor = recurrentToInputWeightsTensorCopy;
365 recurrentToForgetWeightsTensor = recurrentToForgetWeightsTensorCopy;
375 recurrentToCellWeightsTensor = recurrentToCellWeightsTensorCopy;
385 recurrentToOutputWeightsTensor = recurrentToOutputWeightsTensorCopy;
394 cellToInputWeightsTensor = cellToInputWeightsTensorCopy;
403 cellToForgetWeightsTensor = cellToForgetWeightsTensorCopy;
412 cellToOutputWeightsTensor = cellToOutputWeightsTensorCopy;
421 inputGateBiasTensor = inputGateBiasTensorCopy;
430 forgetGateBiasTensor = forgetGateBiasTensorCopy;
439 cellBiasTensor = cellBiasTensorCopy;
448 outputGateBias = outputGateBiasCopy;
457 projectionWeightsTensor = projectionWeightsTensorCopy;
466 projectionBiasTensor = projectionBiasTensorCopy;
475 inputLayerNormTensor = inputLayerNormTensorCopy;
484 forgetLayerNormTensor = forgetLayerNormTensorCopy;
493 cellLayerNormTensor = cellLayerNormTensorCopy;
502 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). ...
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).
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
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 override
const ConstCpuTensorHandle * m_InputToOutputWeights
bool m_CifgEnabled
Enable/disable CIFG (coupled input & forget gate).
const ConstCpuTensorHandle * m_InputToInputWeights
const ConstCpuTensorHandle * m_InputToCellWeights