Compute Library
 21.02
LSTMParams< T > Class Template Reference

#include <LSTMParams.h>

Public Member Functions

 LSTMParams ()
 Constructor. More...
 
 LSTMParams (const LSTMParams &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
LSTMParamsoperator= (const LSTMParams &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 ~LSTMParams ()=default
 Default destructor. More...
 
LSTMParamsset_cifg_params (const T *input_to_input_weights, const T *recurrent_to_input_weights, T *cell_to_input_weights, const T *input_gate_bias)
 Set CIFG tensor parameters. More...
 
LSTMParamsset_projection_params (const T *projection_weights, const T *projection_bias)
 Set projection tensor parameters. More...
 
LSTMParamsset_peephole_params (T *cell_to_forget_weights, T *cell_to_output_weights)
 Set peephole tensor parameters. More...
 
LSTMParamsset_layer_normalization_params (T *input_layer_norm_weights, T *forget_layer_norm_weights, T *cell_layer_norm_weights, T *output_layer_norm_weights)
 Set layer normalization tensor parameters. More...
 
LSTMParamsset_cell_clip_params (float cell_clip)
 Set cell clip value. More...
 
LSTMParamsset_projection_clip_params (float projection_clip)
 Set projection clip value. More...
 
LSTMParamsset_matmul_scale_params (float input_intermediate_scale, float forget_intermediate_scale, float cell_intermediate_scale, float output_intermediate_scale)
 Set scale of the intermediate results of matmul of each layer parameters. More...
 
LSTMParamsset_hidden_state_params (int32_t hidden_state_zero, float hidden_state_scale)
 Set hidden state zero and scale parameters. More...
 
const T * input_to_input_weights () const
 
const T * recurrent_to_input_weights () const
 
T * cell_to_input_weights () const
 
const T * input_gate_bias () const
 
T * cell_to_forget_weights () const
 
T * cell_to_output_weights () const
 
const T * projection_weights () const
 
const T * projection_bias () const
 
T * input_layer_norm_weights () const
 
T * forget_layer_norm_weights () const
 
T * cell_layer_norm_weights () const
 
T * output_layer_norm_weights () const
 
float cell_clip () const
 
float projection_clip () const
 
float input_intermediate_scale () const
 
float forget_intermediate_scale () const
 
float cell_intermediate_scale () const
 
float output_intermediate_scale () const
 
int32_t hidden_state_zero () const
 
float hidden_state_scale () const
 
bool has_peephole_opt () const
 
bool has_projection () const
 
bool has_cifg_opt () const
 
bool use_layer_norm () const
 

Detailed Description

template<typename T>
class arm_compute::LSTMParams< T >

Definition at line 38 of file LSTMParams.h.

Constructor & Destructor Documentation

◆ LSTMParams() [1/2]

LSTMParams ( )
inline

Constructor.

Definition at line 42 of file LSTMParams.h.

References LSTMParams< T >::operator=(), and LSTMParams< T >::~LSTMParams().

43  : _input_to_input_weights(nullptr),
44  _recurrent_to_input_weights(nullptr),
45  _cell_to_input_weights(nullptr),
46  _input_gate_bias(nullptr),
47  _cell_to_forget_weights(nullptr),
48  _cell_to_output_weights(nullptr),
49  _projection_weights(nullptr),
50  _projection_bias(nullptr),
51  _input_layer_norm_weights(nullptr),
52  _forget_layer_norm_weights(nullptr),
53  _cell_layer_norm_weights(nullptr),
54  _output_layer_norm_weights(nullptr),
55  _cell_clip(0.f),
56  _projection_clip(0.0f),
57  _input_intermediate_scale(0.0f),
58  _forget_intermediate_scale(0.0f),
59  _cell_intermediate_scale(0.0f),
60  _output_intermediate_scale(0.0f),
61  _hidden_state_zero(0),
62  _hidden_state_scale(0.0f),
63  _has_peephole_opt(false),
64  _has_projection(false),
65  _has_cifg_opt(true),
66  _use_layer_norm(false)
67  {
68  }

◆ LSTMParams() [2/2]

LSTMParams ( const LSTMParams< T > &  )
delete

Prevent instances of this class from being copied (As this class contains pointers)

◆ ~LSTMParams()

~LSTMParams ( )
default

Default destructor.

Referenced by LSTMParams< T >::LSTMParams().

Member Function Documentation

◆ cell_clip()

float cell_clip ( ) const
inline

◆ cell_intermediate_scale()

float cell_intermediate_scale ( ) const
inline

◆ cell_layer_norm_weights()

◆ cell_to_forget_weights()

◆ cell_to_input_weights()

◆ cell_to_output_weights()

◆ forget_intermediate_scale()

float forget_intermediate_scale ( ) const
inline

◆ forget_layer_norm_weights()

◆ has_cifg_opt()

◆ has_peephole_opt()

◆ has_projection()

◆ hidden_state_scale()

float hidden_state_scale ( ) const
inline

◆ hidden_state_zero()

int32_t hidden_state_zero ( ) const
inline

◆ input_gate_bias()

◆ input_intermediate_scale()

float input_intermediate_scale ( ) const
inline

◆ input_layer_norm_weights()

◆ input_to_input_weights()

◆ operator=()

LSTMParams& operator= ( const LSTMParams< T > &  )
delete

Prevent instances of this class from being copied (As this class contains pointers)

Referenced by LSTMParams< T >::LSTMParams().

◆ output_intermediate_scale()

float output_intermediate_scale ( ) const
inline

◆ output_layer_norm_weights()

◆ projection_bias()

◆ projection_clip()

float projection_clip ( ) const
inline

Definition at line 262 of file LSTMParams.h.

Referenced by NEQLSTMLayer::configure(), CLQLSTMLayer::configure(), LSTMParams< T >::set_projection_clip_params(), NEQLSTMLayer::validate(), and CLQLSTMLayer::validate().

263  {
264  return _projection_clip;
265  }

◆ projection_weights()

◆ recurrent_to_input_weights()

◆ set_cell_clip_params()

LSTMParams& set_cell_clip_params ( float  cell_clip)
inline

Set cell clip value.

Parameters
[in]cell_clipValue to be used to clip the cell state prior to the cell output activation.
Returns
Reference to this LSTMParams object

Definition at line 147 of file LSTMParams.h.

References LSTMParams< T >::cell_clip().

148  {
149  _cell_clip = cell_clip;
150  return *this;
151  }
float cell_clip() const
Definition: LSTMParams.h:257

◆ set_cifg_params()

LSTMParams& set_cifg_params ( const T *  input_to_input_weights,
const T *  recurrent_to_input_weights,
T *  cell_to_input_weights,
const T *  input_gate_bias 
)
inline

Set CIFG tensor parameters.

Parameters
[in]input_to_input_weights2D weights tensor with dimensions [input_size, num_units]. Data types supported: QSYMM8/F16/F32.
[in]recurrent_to_input_weights2D weights tensor with dimensions [output_size, num_units]. Data type supported: Same as input_to_input_weights.
[in]cell_to_input_weights1D weights tensor with dimensions [num_units]. Can be nullptr. Data type supported: Same as input_to_input_weights.
[in]input_gate_bias1D weights tensor with dimensions [num_units]. Data type supported: Same as input_to_input_weights, S32 when input_to_input_weights is QSYMM8
Returns
Reference to this LSTMParams object

Definition at line 84 of file LSTMParams.h.

References LSTMParams< T >::cell_to_input_weights(), LSTMParams< T >::input_gate_bias(), LSTMParams< T >::input_to_input_weights(), and LSTMParams< T >::recurrent_to_input_weights().

Referenced by arm_compute::utils::info_helpers::build_lstm_params_tensor_info().

85  {
86  _input_to_input_weights = input_to_input_weights;
87  _recurrent_to_input_weights = recurrent_to_input_weights;
88  _cell_to_input_weights = cell_to_input_weights;
89  _input_gate_bias = input_gate_bias;
90  _has_cifg_opt = false;
91  return *this;
92  }
const T * input_to_input_weights() const
Definition: LSTMParams.h:197
T * cell_to_input_weights() const
Definition: LSTMParams.h:207
const T * recurrent_to_input_weights() const
Definition: LSTMParams.h:202
const T * input_gate_bias() const
Definition: LSTMParams.h:212

◆ set_hidden_state_params()

LSTMParams& set_hidden_state_params ( int32_t  hidden_state_zero,
float  hidden_state_scale 
)
inline

Set hidden state zero and scale parameters.

Parameters
[in]hidden_state_zeroThe zero point of the hidden state.
[in]hidden_state_scaleThe scale of the hidden state.
Returns
Reference to this LSTMParams object

Definition at line 190 of file LSTMParams.h.

References LSTMParams< T >::hidden_state_scale(), and LSTMParams< T >::hidden_state_zero().

Referenced by arm_compute::utils::info_helpers::build_lstm_params_tensor_info().

191  {
192  _hidden_state_zero = hidden_state_zero;
193  _hidden_state_scale = hidden_state_scale;
194  return *this;
195  }
int32_t hidden_state_zero() const
Definition: LSTMParams.h:287
float hidden_state_scale() const
Definition: LSTMParams.h:292

◆ set_layer_normalization_params()

LSTMParams& set_layer_normalization_params ( T *  input_layer_norm_weights,
T *  forget_layer_norm_weights,
T *  cell_layer_norm_weights,
T *  output_layer_norm_weights 
)
inline

Set layer normalization tensor parameters.

Parameters
[in]input_layer_norm_weights1D weights tensor with dimensions [num_units]. Data type supported: Data types supported: QSYMM16/F16/F32.
[in]forget_layer_norm_weights1D weights tensor with dimensions [num_units]. Data type supported: Same as input_layer_norm_weights.
[in]cell_layer_norm_weights1D weights tensor with dimensions [num_units]. Data type supported: Same as input_layer_norm_weights.
[in]output_layer_norm_weights1D weights tensor with dimensions [num_units]. Data type supported: Same as input_layer_norm_weights.
Returns
Reference to this LSTMParams object

Definition at line 130 of file LSTMParams.h.

References LSTMParams< T >::cell_layer_norm_weights(), LSTMParams< T >::forget_layer_norm_weights(), LSTMParams< T >::input_layer_norm_weights(), and LSTMParams< T >::output_layer_norm_weights().

Referenced by arm_compute::utils::info_helpers::build_lstm_params_tensor_info().

132  {
133  _input_layer_norm_weights = input_layer_norm_weights;
134  _forget_layer_norm_weights = forget_layer_norm_weights;
135  _cell_layer_norm_weights = cell_layer_norm_weights;
136  _output_layer_norm_weights = output_layer_norm_weights;
137  _use_layer_norm = true;
138  return *this;
139  }
T * forget_layer_norm_weights() const
Definition: LSTMParams.h:242
T * output_layer_norm_weights() const
Definition: LSTMParams.h:252
T * input_layer_norm_weights() const
Definition: LSTMParams.h:237
T * cell_layer_norm_weights() const
Definition: LSTMParams.h:247

◆ set_matmul_scale_params()

LSTMParams& set_matmul_scale_params ( float  input_intermediate_scale,
float  forget_intermediate_scale,
float  cell_intermediate_scale,
float  output_intermediate_scale 
)
inline

Set scale of the intermediate results of matmul of each layer parameters.

Parameters
[in]input_intermediate_scaleScale of the intermediate result of matmul, i.e. input to layer normalization, at input gate.
[in]forget_intermediate_scaleScale of the intermediate result of matmul, i.e. input to layer normalization, at forget gate.
[in]cell_intermediate_scaleScale of the intermediate result of matmul, i.e. input to layer normalization, at cell gate.
[in]output_intermediate_scaleScale of the intermediate result of matmul, i.e. input to layer normalization, at output gate.
Returns
Reference to this LSTMParams object

Definition at line 174 of file LSTMParams.h.

References LSTMParams< T >::cell_intermediate_scale(), LSTMParams< T >::forget_intermediate_scale(), LSTMParams< T >::input_intermediate_scale(), and LSTMParams< T >::output_intermediate_scale().

Referenced by arm_compute::utils::info_helpers::build_lstm_params_tensor_info().

175  {
176  _input_intermediate_scale = input_intermediate_scale;
177  _forget_intermediate_scale = forget_intermediate_scale;
178  _cell_intermediate_scale = cell_intermediate_scale;
179  _output_intermediate_scale = output_intermediate_scale;
180  return *this;
181  }
float output_intermediate_scale() const
Definition: LSTMParams.h:282
float cell_intermediate_scale() const
Definition: LSTMParams.h:277
float forget_intermediate_scale() const
Definition: LSTMParams.h:272
float input_intermediate_scale() const
Definition: LSTMParams.h:267

◆ set_peephole_params()

LSTMParams& set_peephole_params ( T *  cell_to_forget_weights,
T *  cell_to_output_weights 
)
inline

Set peephole tensor parameters.

Parameters
[in]cell_to_forget_weights1D weights tensor with dimensions [num_units]. Data type supported: Data types supported: QSYMM16/F16/F32.
[in]cell_to_output_weights1D weights tensor with dimensions [num_units]. Data type supported: Same as cell_to_forget_weights.
Returns
Reference to this LSTMParams object

Definition at line 114 of file LSTMParams.h.

References LSTMParams< T >::cell_to_forget_weights(), and LSTMParams< T >::cell_to_output_weights().

Referenced by arm_compute::utils::info_helpers::build_lstm_params_tensor_info(), and arm_compute::test::validation::DATA_TEST_CASE().

115  {
116  _cell_to_forget_weights = cell_to_forget_weights;
117  _cell_to_output_weights = cell_to_output_weights;
118  _has_peephole_opt = true;
119  return *this;
120  }
T * cell_to_forget_weights() const
Definition: LSTMParams.h:217
T * cell_to_output_weights() const
Definition: LSTMParams.h:222

◆ set_projection_clip_params()

LSTMParams& set_projection_clip_params ( float  projection_clip)
inline

Set projection clip value.

Parameters
[in]projection_clipValue to be used to clip the projection, in case projection is enabled.
Returns
Reference to this LSTMParams object

Definition at line 159 of file LSTMParams.h.

References LSTMParams< T >::projection_clip().

160  {
161  _projection_clip = projection_clip;
162  return *this;
163  }
float projection_clip() const
Definition: LSTMParams.h:262

◆ set_projection_params()

LSTMParams& set_projection_params ( const T *  projection_weights,
const T *  projection_bias 
)
inline

Set projection tensor parameters.

Parameters
[in]projection_weights2D weights tensor with dimensions [output_size, num_units]. Data type supported: Data types supported: QSYMM8/F16/F32.
[in]projection_bias1D weights tensor with dimensions [output_size]. Data type supported: Same as projection_weights, S32 when input_to_input_weights is QSYMM8.
Returns
Reference to this LSTMParams object

Definition at line 100 of file LSTMParams.h.

References LSTMParams< T >::projection_bias(), and LSTMParams< T >::projection_weights().

Referenced by arm_compute::utils::info_helpers::build_lstm_params_tensor_info().

101  {
102  _projection_weights = projection_weights;
103  _projection_bias = projection_bias;
104  _has_projection = true;
105  return *this;
106  }
const T * projection_weights() const
Definition: LSTMParams.h:227
const T * projection_bias() const
Definition: LSTMParams.h:232

◆ use_layer_norm()


The documentation for this class was generated from the following file: