24.02.1
|
Basic function to run NELSTMLayer. More...
#include <NELSTMLayer.h>
Public Member Functions | |
NELSTMLayer (std::shared_ptr< IMemoryManager > memory_manager=nullptr) | |
Default constructor. More... | |
NELSTMLayer (const NELSTMLayer &)=delete | |
Prevent instances of this class from being copied (As this class contains pointers) More... | |
NELSTMLayer & | operator= (const NELSTMLayer &)=delete |
Prevent instances of this class from being copied (As this class contains pointers) More... | |
NELSTMLayer (NELSTMLayer &&)=delete | |
Prevent instances of this class from being moved (As this class contains non movable objects) More... | |
NELSTMLayer & | operator= (NELSTMLayer &&)=delete |
Prevent instances of this class from being moved (As this class contains non movable objects) More... | |
~NELSTMLayer () | |
Default destructor. More... | |
void | configure (const ITensor *input, const ITensor *input_to_forget_weights, const ITensor *input_to_cell_weights, const ITensor *input_to_output_weights, const ITensor *recurrent_to_forget_weights, const ITensor *recurrent_to_cell_weights, const ITensor *recurrent_to_output_weights, const ITensor *forget_gate_bias, const ITensor *cell_bias, const ITensor *output_gate_bias, const ITensor *output_state_in, const ITensor *cell_state_in, ITensor *scratch_buffer, ITensor *output_state_out, ITensor *cell_state_out, ITensor *output, const LSTMParams< ITensor > &lstm_params, const ActivationLayerInfo &activation_info, float cell_threshold=0.f, float projection_threshold=0.f) |
Initialize function's tensors. More... | |
void | run () override |
Run the kernels contained in the function. More... | |
void | prepare () override |
Prepare the function for executing. More... | |
Public Member Functions inherited from IFunction | |
virtual | ~IFunction ()=default |
Destructor. More... | |
Static Public Member Functions | |
static Status | validate (const ITensorInfo *input, const ITensorInfo *input_to_forget_weights, const ITensorInfo *input_to_cell_weights, const ITensorInfo *input_to_output_weights, const ITensorInfo *recurrent_to_forget_weights, const ITensorInfo *recurrent_to_cell_weights, const ITensorInfo *recurrent_to_output_weights, const ITensorInfo *forget_gate_bias, const ITensorInfo *cell_bias, const ITensorInfo *output_gate_bias, const ITensorInfo *output_state_in, const ITensorInfo *cell_state_in, const ITensorInfo *scratch_buffer, const ITensorInfo *output_state_out, const ITensorInfo *cell_state_out, const ITensorInfo *output, const LSTMParams< ITensorInfo > &lstm_params, const ActivationLayerInfo &activation_info, float cell_threshold=0.f, float projection_threshold=0.f) |
Static function to check if given info will lead to a valid configuration of NELSTMLayer. More... | |
Basic function to run NELSTMLayer.
Definition at line 46 of file NELSTMLayer.h.
NELSTMLayer | ( | std::shared_ptr< IMemoryManager > | memory_manager = nullptr | ) |
|
delete |
Prevent instances of this class from being copied (As this class contains pointers)
|
delete |
Prevent instances of this class from being moved (As this class contains non movable objects)
|
default |
Default destructor.
void configure | ( | const ITensor * | input, |
const ITensor * | input_to_forget_weights, | ||
const ITensor * | input_to_cell_weights, | ||
const ITensor * | input_to_output_weights, | ||
const ITensor * | recurrent_to_forget_weights, | ||
const ITensor * | recurrent_to_cell_weights, | ||
const ITensor * | recurrent_to_output_weights, | ||
const ITensor * | forget_gate_bias, | ||
const ITensor * | cell_bias, | ||
const ITensor * | output_gate_bias, | ||
const ITensor * | output_state_in, | ||
const ITensor * | cell_state_in, | ||
ITensor * | scratch_buffer, | ||
ITensor * | output_state_out, | ||
ITensor * | cell_state_out, | ||
ITensor * | output, | ||
const LSTMParams< ITensor > & | lstm_params, | ||
const ActivationLayerInfo & | activation_info, | ||
float | cell_threshold = 0.f , |
||
float | projection_threshold = 0.f |
||
) |
Initialize function's tensors.
Valid data layouts:
Valid data type configurations:
src0 - src13 | dst0 - dst3 |
---|---|
F16 | F16 |
F32 | F32 |
[in] | input | Source tensor. Input is a 2D tensor with dimensions [input_size, batch_size]. Data types supported: F16/F32. |
[in] | input_to_forget_weights | 2D weights tensor with dimensions [input_size, num_units]. Data type supported: Same as input . |
[in] | input_to_cell_weights | 2D weights tensor with dimensions [input_size, num_units]. Data type supported: Same as input . |
[in] | input_to_output_weights | 2D weights tensor with dimensions [input_size, num_units]. Data type supported: Same as input . |
[in] | recurrent_to_forget_weights | 2D weights tensor with dimensions [output_size, num_units]. Data type supported: Same as input . |
[in] | recurrent_to_cell_weights | 2D weights tensor with dimensions [output_size, num_units]. Data type supported: Same as input . |
[in] | recurrent_to_output_weights | 2D weights tensor with dimensions [output_size, num_units]. Data type supported: Same as input . |
[in] | forget_gate_bias | 1D weights tensor with dimensions [num_units]. Data type supported: Same as input . |
[in] | cell_bias | 1D weights tensor with dimensions [num_units]. Data type supported: Same as input . |
[in] | output_gate_bias | 1D weights tensor with dimensions [num_units]. Data type supported: Same as input . |
[in] | output_state_in | 2D weights tensor with dimensions [output_size, batch_size]. Data type supported: Same as input . |
[in] | cell_state_in | 2D tensor with dimensions [num_units, batch_size]. Data type supported: Same as input . |
[out] | scratch_buffer | 2D tensor with dimensions [num_units * 4, batch_size] with CIFG or [num_units * 3, batch_size] without CIGF. Data type supported: Same as input . |
[out] | output_state_out | 2D weights tensor with dimensions [output_size, batch_size]. Data type supported: Same as input . |
[out] | cell_state_out | 2D tensor with dimensions [num_units, batch_size]. Data type supported: Same as input . |
[out] | output | Destination tensor. Output is a 2D tensor with dimensions [output_size, batch_size]. Data types supported: Same as input . |
[in] | lstm_params | Weights tensors used in peephole optimization: input_to_input_weights (Optional) 2D weights tensor with dimensions [input_size, num_units]. Data type supported: Same as input . recurrent_to_input_weights (Optional) 2D weights tensor with dimensions [output_size, num_units]. Data type supported: Same as input . cell_to_input_weights (Optional) 1D weights tensor with dimensions [num_units]. Can be nullptr. Data type supported: Same as input . cell_to_forget_weights (Optional) 1D weights tensor with dimensions [num_units]. Data type supported: Same as input . cell_to_output_weights (Optional) 1D weights tensor with dimensions [num_units]. Data type supported: Same as input . input_gate_bias (Optional) 1D weights tensor with dimensions [num_units]. Data type supported: Same as input projection_weights (Optional) 2D weights tensor with dimensions [output_size, num_units]. Data type supported: Same as input . projection_bias (Optional) 1D weights tensor with dimensions [output_size]. Data type supported: Same as input . input_layer_norm_weights (Optional) 1D weights tensor with dimensions [num_units]. Data type supported: Same as input . forget_layer_norm_weights (Optional) 1D weights tensor with dimensions [num_units]. Data type supported: Same as input . cell_layer_norm_weights (Optional) 1D weights tensor with dimensions [num_units]. Data type supported: Same as input . output_layer_norm_weights (Optional) 1D weights tensor with dimensions [num_units]. Data type supported: Same as input . |
[in] | activation_info | Contains activation information described in ActivationLayerInfo. |
[in] | cell_threshold | The clipping threshold for the cell state, such that values are bound within [-cell_clip, cell_clip]. If set to 0.0 then clipping is disabled. |
[in] | projection_threshold | The clipping threshold for the output from the projection layer, such that values are bound within [-proj_clip, proj_clip]. If set to 0.0 then clipping is disabled. |
lstm_res = PixelwiseMul(output, Activation(cell_state))
-- Clip(lstm_res * projection_weights + projection_bias, projection_threshold) , if there is a projection /
output_state = – \ – lstm_res , otherwise
Definition at line 129 of file NELSTMLayer.cpp.
References TensorAllocator::allocate(), Tensor::allocator(), ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, ARM_COMPUTE_LOG_PARAMS, arm_compute::utils::info_helpers::build_lstm_params_tensor_info(), LSTMParams< T >::cell_layer_norm_weights(), LSTMParams< T >::cell_to_forget_weights(), LSTMParams< T >::cell_to_input_weights(), LSTMParams< T >::cell_to_output_weights(), arm_compute::misc::shape_calculator::compute_transposed_shape(), NETranspose::configure(), NECopy::configure(), NEMeanStdDevNormalizationLayer::configure(), NEConcatenateLayer::configure(), NEArithmeticAddition::configure(), NEGEMM::configure(), NEArithmeticSubtraction::configure(), NEActivationLayer::configure(), NEPixelWiseMultiplication::configure(), NEFullyConnectedLayer::configure(), Window::DimX, arm_compute::test::validation::forget_gate_bias, LSTMParams< T >::forget_layer_norm_weights(), LSTMParams< T >::has_cifg_opt(), LSTMParams< T >::has_peephole_opt(), LSTMParams< T >::has_projection(), ITensor::info(), Tensor::info(), TensorAllocator::init(), arm_compute::test::validation::input, LSTMParams< T >::input_gate_bias(), LSTMParams< T >::input_layer_norm_weights(), arm_compute::test::validation::input_to_cell_weights, arm_compute::test::validation::input_to_forget_weights, LSTMParams< T >::input_to_input_weights(), arm_compute::test::validation::input_to_output_weights, MemoryGroup::manage(), arm_compute::test::validation::output_gate_bias, LSTMParams< T >::output_layer_norm_weights(), LSTMParams< T >::projection_bias(), LSTMParams< T >::projection_weights(), arm_compute::test::validation::recurrent_to_cell_weights, arm_compute::test::validation::recurrent_to_forget_weights, LSTMParams< T >::recurrent_to_input_weights(), arm_compute::test::validation::recurrent_to_output_weights, arm_compute::SATURATE, ITensorInfo::tensor_shape(), arm_compute::TO_ZERO, LSTMParams< T >::use_layer_norm(), and NELSTMLayer::validate().
|
delete |
Prevent instances of this class from being copied (As this class contains pointers)
|
delete |
Prevent instances of this class from being moved (As this class contains non movable objects)
|
overridevirtual |
Prepare the function for executing.
Any one off pre-processing step required by the function is handled here
Reimplemented from IFunction.
Definition at line 877 of file NELSTMLayer.cpp.
References NEConcatenateLayer::run().
Referenced by NELSTMLayer::run().
|
overridevirtual |
Run the kernels contained in the function.
For CPU kernels:
For OpenCL kernels:
Implements IFunction.
Definition at line 769 of file NELSTMLayer.cpp.
References Tensor::buffer(), ITensorInfo::data_type(), ITensorInfo::element_size(), arm_compute::F16, Tensor::info(), NELSTMLayer::prepare(), INESimpleFunctionNoBorder::run(), NECopy::run(), NETranspose::run(), NEConcatenateLayer::run(), NEActivationLayer::run(), NEArithmeticAddition::run(), NEArithmeticSubtraction::run(), NEGEMM::run(), NEPixelWiseMultiplication::run(), NEFullyConnectedLayer::run(), and ITensorInfo::total_size().
|
static |
Static function to check if given info will lead to a valid configuration of NELSTMLayer.
[in] | input | Source tensor. Input is a 2D tensor with dimensions [input_size, batch_size]. Data types supported: F16/F32. |
[in] | input_to_forget_weights | 2D weights tensor with dimensions [input_size, num_units]. Data type supported: Same as input . |
[in] | input_to_cell_weights | 2D weights tensor with dimensions [input_size, num_units]. Data type supported: Same as input . |
[in] | input_to_output_weights | 2D weights tensor with dimensions [input_size, num_units]. Data type supported: Same as input . |
[in] | recurrent_to_forget_weights | 2D weights tensor with dimensions [output_size, num_units]. Data type supported: Same as input . |
[in] | recurrent_to_cell_weights | 2D weights tensor with dimensions [output_size, num_units]. Data type supported: Same as input . |
[in] | recurrent_to_output_weights | 2D weights tensor with dimensions [output_size, num_units]. Data type supported: Same as input . |
[in] | forget_gate_bias | 1D weights tensor with dimensions [num_units]. Data type supported: Same as input . |
[in] | cell_bias | 1D weights tensor with dimensions [num_units]. Data type supported: Same as input . |
[in] | output_gate_bias | 1D weights tensor with dimensions [num_units]. Data type supported: Same as input . |
[in] | output_state_in | 2D weights tensor with dimensions [output_size, batch_size]. Data type supported: Same as input . |
[in] | cell_state_in | 2D tensor with dimensions [num_units, batch_size]. Data type supported: Same as input . |
[in] | scratch_buffer | 2D tensor with dimensions [num_units * 4, batch_size] with CIFG or [num_units * 3, batch_size] without CIGF. Data type supported: Same as input . |
[in] | output_state_out | 2D weights tensor with dimensions [output_size, batch_size]. Data type supported: Same as input . |
[in] | cell_state_out | 2D tensor with dimensions [num_units, batch_size]. Data type supported: Same as input . |
[in] | output | Destination tensor. Output is a 2D tensor with dimensions [output_size, batch_size]. Data types supported: Same as input . |
[in] | lstm_params | Weights tensors used in peephole optimization: input_to_input_weights (Optional) 2D weights tensor with dimensions [input_size, num_units]. Data type supported: Same as input . recurrent_to_input_weights (Optional) 2D weights tensor with dimensions [output_size, num_units]. Data type supported: Same as input . cell_to_input_weights (Optional) 1D weights tensor with dimensions [num_units]. Can be nullptr. Data type supported: Same as input . cell_to_forget_weights (Optional) 1D weights tensor with dimensions [num_units]. Data type supported: Same as input . cell_to_output_weights (Optional) 1D weights tensor with dimensions [num_units]. Data type supported: Same as input . input_gate_bias (Optional) 1D weights tensor with dimensions [num_units]. Data type supported: Same as input projection_weights (Optional) 2D weights tensor with dimensions [output_size, num_units]. Data type supported: Same as input . projection_bias (Optional) 1D weights tensor with dimensions [output_size]. Data type supported: Same as input . input_layer_norm_weights (Optional) 1D weights tensor info with dimensions [num_units]. Data type supported: Same as input . forget_layer_norm_weights (Optional) 1D weights tensor info with dimensions [num_units]. Data type supported: Same as input . cell_layer_norm_weights (Optional) 1D weights tensor info with dimensions [num_units]. Data type supported: Same as input . output_layer_norm_weights (Optional) 1D weights tensor info with dimensions [num_units]. Data type supported: Same as input . |
[in] | activation_info | Contains activation information described in ActivationLayerInfo. |
[in] | cell_threshold | The clipping threshold for the cell state, such that values are bound within [-cell_clip, cell_clip]. If set to 0.0 then clipping is disabled. |
[in] | projection_threshold | The clipping threshold for the output from the projection layer, such that values are bound within [-proj_clip, proj_clip]. If set to 0.0 then clipping is disabled. |
Definition at line 488 of file NELSTMLayer.cpp.
References ARM_COMPUTE_RETURN_ERROR_ON, ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN, ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES, ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR, ARM_COMPUTE_RETURN_ON_ERROR, arm_compute::misc::shape_calculator::calculate_concatenate_shape(), LSTMParams< T >::cell_layer_norm_weights(), LSTMParams< T >::cell_to_forget_weights(), LSTMParams< T >::cell_to_input_weights(), LSTMParams< T >::cell_to_output_weights(), arm_compute::misc::shape_calculator::compute_transposed_shape(), ITensorInfo::dimension(), Window::DimX, arm_compute::F16, arm_compute::F32, arm_compute::test::validation::forget_gate_bias, LSTMParams< T >::forget_layer_norm_weights(), LSTMParams< T >::has_cifg_opt(), LSTMParams< T >::has_peephole_opt(), LSTMParams< T >::has_projection(), arm_compute::test::validation::input, LSTMParams< T >::input_gate_bias(), LSTMParams< T >::input_layer_norm_weights(), arm_compute::test::validation::input_to_cell_weights, arm_compute::test::validation::input_to_forget_weights, LSTMParams< T >::input_to_input_weights(), arm_compute::test::validation::input_to_output_weights, ITensorInfo::num_dimensions(), arm_compute::test::validation::output_gate_bias, LSTMParams< T >::output_layer_norm_weights(), LSTMParams< T >::projection_bias(), LSTMParams< T >::projection_weights(), arm_compute::test::validation::recurrent_to_cell_weights, arm_compute::test::validation::recurrent_to_forget_weights, LSTMParams< T >::recurrent_to_input_weights(), arm_compute::test::validation::recurrent_to_output_weights, arm_compute::SATURATE, arm_compute::TO_ZERO, LSTMParams< T >::use_layer_norm(), NECopy::validate(), NEMeanStdDevNormalizationLayer::validate(), NEConcatenateLayer::validate(), NEArithmeticAddition::validate(), NEGEMM::validate(), NEActivationLayer::validate(), NEArithmeticSubtraction::validate(), NEPixelWiseMultiplication::validate(), and NEFullyConnectedLayer::validate().
Referenced by NELSTMLayer::configure().