ArmNN
 25.11
Loading...
Searching...
No Matches
QLstmLayer.hpp
Go to the documentation of this file.
1//
2// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5#pragma once
6
8
9namespace armnn
10{
11
13
15{
16 /// A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8).
17 std::shared_ptr<ConstTensorHandle> m_InputToForgetWeights;
18 /// A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8).
19 std::shared_ptr<ConstTensorHandle> m_InputToCellWeights;
20 /// A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8).
21 std::shared_ptr<ConstTensorHandle> m_InputToOutputWeights;
22
23 /// A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8).
24 std::shared_ptr<ConstTensorHandle> m_RecurrentToForgetWeights;
25 /// A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8).
26 std::shared_ptr<ConstTensorHandle> m_RecurrentToCellWeights;
27 /// A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8).
28 std::shared_ptr<ConstTensorHandle> m_RecurrentToOutputWeights;
29
30 /// A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32).
31 std::shared_ptr<ConstTensorHandle> m_ForgetGateBias;
32 /// A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32).
33 std::shared_ptr<ConstTensorHandle> m_CellBias;
34 /// A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32).
35 std::shared_ptr<ConstTensorHandle> m_OutputGateBias;
36};
37
39{
40 /// A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units] (QSymmS8).
41 std::shared_ptr<ConstTensorHandle> m_ProjectionWeights;
42 /// A unique pointer to represent 1D weights tensor with dimensions [output_size] (int32).
43 std::shared_ptr<ConstTensorHandle> m_ProjectionBias;
44};
45
47{
48 /// A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
49 std::shared_ptr<ConstTensorHandle> m_CellToInputWeights;
50 /// A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
51 std::shared_ptr<ConstTensorHandle> m_CellToForgetWeights;
52 /// A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
53 std::shared_ptr<ConstTensorHandle> m_CellToOutputWeights;
54};
55
57{
58 /// A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units] (QSymmS8).
59 std::shared_ptr<ConstTensorHandle> m_InputToInputWeights;
60 /// A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units] (QSymmS8).
61 std::shared_ptr<ConstTensorHandle> m_RecurrentToInputWeights;
62 /// A unique pointer to represent 1D weights tensor with dimensions [num_units] (int32).
63 std::shared_ptr<ConstTensorHandle> m_InputGateBias;
64};
65
67{
68 /// A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
69 std::shared_ptr<ConstTensorHandle> m_InputLayerNormWeights;
70 /// A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
71 std::shared_ptr<ConstTensorHandle> m_ForgetLayerNormWeights;
72 /// A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
73 std::shared_ptr<ConstTensorHandle> m_CellLayerNormWeights;
74 /// A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
75 std::shared_ptr<ConstTensorHandle> m_OutputLayerNormWeights;
76};
77
78/// This layer represents a QLstm operation.
79class QLstmLayer : public LayerWithParameters<QLstmDescriptor>
80{
81public:
82
88
89 /// Makes a workload for the QLstm type.
90 /// @param [in] graph The graph where this layer can be found.
91 /// @param [in] factory The workload factory which will create the workload.
92 /// @return A pointer to the created workload, or nullptr if not created.
93 virtual std::unique_ptr<IWorkload> CreateWorkload(const IWorkloadFactory& factory) const override;
94
95 /// Creates a dynamically-allocated copy of this layer.
96 /// @param [in] graph The graph into which this layer is being cloned.
97 QLstmLayer* Clone(Graph& graph) const override;
98
99 /// Check if the input tensor shape(s)
100 /// will lead to a valid configuration of @ref QLstmLayer.
101 /// @param [in] shapeInferenceMethod Indicates if output shape shall be overwritten or just validated.
102 void ValidateTensorShapesFromInputs() override;
103
104 /// By default returns inputShapes if the number of inputs are equal to number of outputs,
105 /// otherwise infers the output shapes from given input shapes and layer properties.
106 /// @param [in] inputShapes The input shapes layer has.
107 /// @return A vector to the inferred output shape.
108 std::vector<TensorShape> InferOutputShapes(const std::vector<TensorShape>& inputShapes) const override;
109
110 void ExecuteStrategy(IStrategy& strategy) const override;
111
112protected:
113 /// Constructor to create a QLstmLayer.
114 /// @param [in] name Optional name for the layer.
115 QLstmLayer(const QLstmDescriptor& param, const char* name);
116
117 /// Default destructor
118 ~QLstmLayer() = default;
119
120 /// Retrieve the handles to the constant values stored by the layer.
121 /// @return A vector of the constant tensors stored by this layer.
123};
124
125} // namespace armnn
std::vector< std::reference_wrapper< const std::shared_ptr< ConstTensorHandle > > > ImmutableConstantTensors
Definition INetwork.hpp:141
LayerWithParameters(unsigned int numInputSlots, unsigned int numOutputSlots, LayerType type, const QLstmDescriptor &param, const char *name)
Layer::ImmutableConstantTensors GetConstantTensorsByRef() const override
Retrieve the handles to the constant values stored by the layer.
QLstmLayer(const QLstmDescriptor &param, const char *name)
Constructor to create a QLstmLayer.
QLstmOptProjectionParameters m_ProjectionParameters
void ExecuteStrategy(IStrategy &strategy) const override
Apply a visitor to this layer.
QLstmOptPeepholeParameters m_PeepholeParameters
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,...
void ValidateTensorShapesFromInputs() override
Check if the input tensor shape(s) will lead to a valid configuration of QLstmLayer.
QLstmBasicParameters m_BasicParameters
QLstmOptLayerNormParameters m_LayerNormParameters
QLstmLayer * Clone(Graph &graph) const override
Creates a dynamically-allocated copy of this layer.
virtual std::unique_ptr< IWorkload > CreateWorkload(const IWorkloadFactory &factory) const override
Makes a workload for the QLstm type.
~QLstmLayer()=default
Default destructor.
QLstmOptCifgParameters m_CifgParameters
Copyright (c) 2021 ARM Limited and Contributors.
std::shared_ptr< ConstTensorHandle > m_RecurrentToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8).
std::shared_ptr< ConstTensorHandle > m_CellBias
A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32).
std::shared_ptr< ConstTensorHandle > m_InputToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8).
std::shared_ptr< ConstTensorHandle > m_RecurrentToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8).
std::shared_ptr< ConstTensorHandle > m_OutputGateBias
A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32).
std::shared_ptr< ConstTensorHandle > m_InputToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8).
std::shared_ptr< ConstTensorHandle > m_InputToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8).
std::shared_ptr< ConstTensorHandle > m_RecurrentToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8).
std::shared_ptr< ConstTensorHandle > m_ForgetGateBias
A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32).
A QLstmDescriptor for the QLstmLayer.
std::shared_ptr< ConstTensorHandle > m_InputToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units] (QSymmS8).
std::shared_ptr< ConstTensorHandle > m_InputGateBias
A unique pointer to represent 1D weights tensor with dimensions [num_units] (int32).
std::shared_ptr< ConstTensorHandle > m_RecurrentToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units] (QSymmS8).
std::shared_ptr< ConstTensorHandle > m_CellLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
std::shared_ptr< ConstTensorHandle > m_InputLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
std::shared_ptr< ConstTensorHandle > m_OutputLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
std::shared_ptr< ConstTensorHandle > m_ForgetLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
std::shared_ptr< ConstTensorHandle > m_CellToForgetWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
std::shared_ptr< ConstTensorHandle > m_CellToInputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
std::shared_ptr< ConstTensorHandle > m_CellToOutputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
std::shared_ptr< ConstTensorHandle > m_ProjectionBias
A unique pointer to represent 1D weights tensor with dimensions [output_size] (int32).
std::shared_ptr< ConstTensorHandle > m_ProjectionWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units] (QSymmS8).