47 auto layer = CloneBase<QuantizedLstmLayer>(graph,
GetName());
76 return std::move(layer);
81 BOOST_ASSERT(inputShapes.size() == 3);
84 unsigned int numBatches = inputShapes[0][0];
85 unsigned int outputSize = inputShapes[1][1];
87 std::vector<TensorShape> outShapes;
88 outShapes.push_back(
TensorShape({numBatches, outputSize}));
89 outShapes.push_back(
TensorShape({numBatches, outputSize}));
105 BOOST_ASSERT(inferredShapes.size() == 2);
109 "QuantizedLstmLayer: m_QuantizedLstmParameters.m_InputToInputWeights should not be null.");
111 "QuantizedLstmLayer: m_QuantizedLstmParameters.m_InputToForgetWeights should not be null.");
113 "QuantizedLstmLayer: m_QuantizedLstmParameters.m_InputToCellWeights should not be null.");
115 "QuantizedLstmLayer: m_QuantizedLstmParameters.m_InputToOutputWeights should not be null.");
118 "QuantizedLstmLayer: m_QuantizedLstmParameters.m_RecurrentToInputWeights should not be null.");
120 "QuantizedLstmLayer: m_QuantizedLstmParameters.m_RecurrentToForgetWeights should not be null.");
122 "QuantizedLstmLayer: m_QuantizedLstmParameters.m_RecurrentToCellWeights should not be null.");
124 "QuantizedLstmLayer: m_QuantizedLstmParameters.m_RecurrentToOutputWeights should not be null.");
127 "QuantizedLstmLayer: m_QuantizedLstmParameters.m_InputGateBias should not be null.");
129 "QuantizedLstmLayer: m_QuantizedLstmParameters.m_ForgetGateBias should not be null.");
131 "QuantizedLstmLayer: m_QuantizedLstmParameters.m_CellBias should not be null.");
133 "QuantizedLstmLayer: m_QuantizedLstmParameters.m_OutputGateBias should not be null.");
136 ConditionalThrowIfNotEqual<LayerValidationException>(
137 "QuantizedLstmLayer: TensorShape set on OutputSlot[0] does not match the inferred shape.",
141 ConditionalThrowIfNotEqual<LayerValidationException>(
142 "QuantizedLstmLayer: TensorShape set on OutputSlot[1] does not match the inferred shape.",
178 inputToInputWeightsTensor = inputToInputWeightsTensorCopy;
187 inputToForgetWeightsTensor = inputToForgetWeightsTensorCopy;
196 inputToCellWeightsTensor = inputToCellWeightsTensorCopy;
205 inputToOutputWeightsTensor = inputToOutputWeightsTensorCopy;
216 recurrentToInputWeightsTensor = recurrentToInputWeightsTensorCopy;
226 recurrentToForgetWeightsTensor = recurrentToForgetWeightsTensorCopy;
236 recurrentToCellWeightsTensor = recurrentToCellWeightsTensorCopy;
246 recurrentToOutputWeightsTensor = recurrentToOutputWeightsTensorCopy;
256 inputGateBiasTensor = inputGateBiasTensorCopy;
265 forgetGateBiasTensor = forgetGateBiasTensorCopy;
274 cellBiasTensor = cellBiasTensorCopy;
283 outputGateBiasTensor = outputGateBiasCopy;
const ConstCpuTensorHandle * m_RecurrentToForgetWeights
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, outputSize] (QAsymm8)...
Layer::ConstantTensors GetConstantTensorsByRef() override
Retrieve the handles to the constant values stored by the layer.
const ConstCpuTensorHandle * m_InputGateBias
QuantizedLstmParameters m_QuantizedLstmParameters
const TensorShape & GetShape() const
std::unique_ptr< ScopedCpuTensorHandle > m_InputToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, inputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, outputSize] (QAsymm8)...
QuantizedLstmLayer * Clone(Graph &graph) const override
Creates a dynamically-allocated copy of this layer.
const ConstCpuTensorHandle * m_InputToCellWeights
virtual std::unique_ptr< IWorkload > CreateQuantizedLstm(const QuantizedLstmQueueDescriptor &descriptor, const WorkloadInfo &info) const
std::unique_ptr< ScopedCpuTensorHandle > m_InputToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, inputSize] (QAsymm8)...
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, outputSize] (QAsymm8)...
void ValidateTensorShapesFromInputs() override
Check if the input tensor shape(s) will lead to a valid configuration of QuantizedLstmLayer.
Copyright (c) 2020 ARM Limited.
QuantizedLstmLayer(const char *name)
Constructor to create a QuantizedLstmLayer.
std::unique_ptr< ScopedCpuTensorHandle > m_InputGateBias
A unique pointer to represent 1D bias tensor with dimensions [outputSize] (int32).
std::unique_ptr< ScopedCpuTensorHandle > m_CellBias
A unique pointer to represent 1D bias tensor with dimensions [outputSize] (int32).
void VerifyLayerConnections(unsigned int expectedConnections, const CheckLocation &location) const
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
This layer represents a QuantizedLstm operation.
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *LayerCreateWorkload.
std::unique_ptr< ScopedCpuTensorHandle > m_ForgetGateBias
A unique pointer to represent 1D bias tensor with dimensions [outputSize] (int32).
const ConstCpuTensorHandle * m_ForgetGateBias
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
const ConstCpuTensorHandle * m_RecurrentToInputWeights
void Accept(ILayerVisitor &visitor) const override
Apply a visitor to this layer.
const ConstCpuTensorHandle * m_RecurrentToCellWeights
virtual std::unique_ptr< IWorkload > CreateWorkload(const IWorkloadFactory &factory) const override
Makes a workload for the QuantizedLstm type.
const ConstCpuTensorHandle * m_RecurrentToOutputWeights
virtual void VisitQuantizedLstmLayer(const IConnectableLayer *layer, const QuantizedLstmInputParams ¶ms, const char *name=nullptr)=0
Function a QuantizedLstm layer should call back to when its Accept(ILayerVisitor&) function is invoke...
std::unique_ptr< ScopedCpuTensorHandle > m_OutputGateBias
A unique pointer to represent 1D bias tensor with dimensions [outputSize] (int32).
const ConstCpuTensorHandle * m_CellBias
const ConstCpuTensorHandle * m_OutputGateBias
std::unique_ptr< ScopedCpuTensorHandle > m_InputToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, inputSize] (QAsymm8)...
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
virtual const TensorInfo & GetTensorInfo() const =0
const char * GetName() const override
Returns the name of the layer.
const ConstCpuTensorHandle * m_InputToForgetWeights
std::unique_ptr< ScopedCpuTensorHandle > m_InputToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, inputSize] (QAsymm8)...
const ConstCpuTensorHandle * m_InputToOutputWeights
std::vector< std::reference_wrapper< std::unique_ptr< ScopedCpuTensorHandle > >> ConstantTensors
const ConstCpuTensorHandle * m_InputToInputWeights
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, outputSize] (QAsymm8)...
const TensorInfo & GetTensorInfo() const override
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.