21.02
|
Basic function to run NEQLSTMLayer. More...
#include <NEQLSTMLayer.h>
Public Member Functions | |
NEQLSTMLayer (std::shared_ptr< IMemoryManager > memory_manager=nullptr) | |
Default constructor. More... | |
NEQLSTMLayer (const NEQLSTMLayer &)=delete | |
Prevent instances of this class from being copied (As this class contains pointers) More... | |
NEQLSTMLayer (NEQLSTMLayer &&)=delete | |
Prevent instances of this class from being moved (As this class contains pointers) More... | |
NEQLSTMLayer & | operator= (const NEQLSTMLayer &)=delete |
Prevent instances of this class from being copied (As this class contains pointers) More... | |
NEQLSTMLayer & | operator= (NEQLSTMLayer &&)=delete |
Prevent instances of this class from being moved (As this class contains pointers) More... | |
~NEQLSTMLayer () | |
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 *cell_state_in, ITensor *output_state_in, ITensor *cell_state_out, ITensor *output_state_out, ITensor *output, const LSTMParams< ITensor > &lstm_params) |
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 *cell_state_in, const ITensorInfo *output_state_in, const ITensorInfo *cell_state_out, const ITensorInfo *output_state_out, const ITensorInfo *output, const LSTMParams< ITensorInfo > &lstm_params) |
Static function to check if given info will lead to a valid configuration of NEQLSTMLayer. More... | |
Basic function to run NEQLSTMLayer.
This function calls the following Neon functions/kernels:
Definition at line 62 of file NEQLSTMLayer.h.
NEQLSTMLayer | ( | std::shared_ptr< IMemoryManager > | memory_manager = nullptr | ) |
Default constructor.
Definition at line 115 of file NEQLSTMLayer.cpp.
References TensorAllocator::allocate(), Tensor::allocator(), arm_compute::quantization::calculate_quantized_multiplier(), NEGEMMLowpMatrixMultiplyCore::configure(), NEGEMMLowpOutputStage::configure(), GEMMLowpOutputStageInfo::gemmlowp_multiplier, GEMMLowpOutputStageInfo::gemmlowp_shift, TensorAllocator::init(), and MemoryGroup::manage().
|
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 pointers)
|
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 * | cell_state_in, | ||
ITensor * | output_state_in, | ||
ITensor * | cell_state_out, | ||
ITensor * | output_state_out, | ||
ITensor * | output, | ||
const LSTMParams< ITensor > & | lstm_params | ||
) |
Initialize function's tensors.
[in] | input | Source tensor. Input is a 2D tensor with dimensions [input_size, batch_size]. Data types supported: QASYMM8_SIGNED. |
[in] | input_to_forget_weights | 2D weights tensor with dimensions [input_size, num_units]. Data type supported: QSYMM8. |
[in] | input_to_cell_weights | 2D weights tensor with dimensions [input_size, num_units]. Data type supported: QSYMM8. |
[in] | input_to_output_weights | 2D weights tensor with dimensions [input_size, num_units]. Data type supported: QSYMM8. |
[in] | recurrent_to_forget_weights | 2D weights tensor with dimensions [output_size, num_units]. Data type supported: QSYMM8. |
[in] | recurrent_to_cell_weights | 2D weights tensor with dimensions [output_size, num_units]. Data type supported: QSYMM8. |
[in] | recurrent_to_output_weights | 2D weights tensor with dimensions [output_size, num_units]. Data type supported: QSYMM8. |
[in] | forget_gate_bias | 1D weights tensor with dimensions [num_units]. Data type supported: S32. |
[in] | cell_bias | 1D weights tensor with dimensions [num_units]. Data type supported: S32. |
[in] | output_gate_bias | 1D weights tensor with dimensions [num_units]. Data type supported: S32. |
[in] | cell_state_in | 2D tensor with dimensions [num_units, batch_size]. Data type supported: QSYMM16. |
[in] | output_state_in | 2D tensor with dimensions [output_size, batch_size]. Data type supported: Same as input . |
[out] | cell_state_out | Destination tensor. Output is a 2D tensor with dimensions [num_units, batch_size]. Data type supported: QSYMM16. |
[out] | output_state_out | Destination tensor. Output is a 2D tensor with dimensions [output_size, batch_size].Data types 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, CIFG and layer normalization optimizations: input_intermediate_scale Scale of the intermediate result of matmul, i.e. input to layer normalization, at input gate. forget_intermediate_scale Scale of the intermediate result of matmul, i.e. input to layer normalization, at forget gate. cell_intermediate_scale Scale of the intermediate result of matmul, i.e. input to layer normalization, at cell gate. output_intermediate_scale Scale of the intermediate result of matmul, i.e. input to layer normalization, at output gate. hidden_state_zero The zero point of the hidden state. hidden_state_scale The scale of the hidden state. input_to_input_weights (Optional) 2D weights tensor with dimensions [input_size, num_units]. Data type supported: QSYMM8. recurrent_to_input_weights (Optional) 2D weights tensor with dimensions [output_size, num_units]. Data type supported: QSYMM8. cell_to_input_weights (Optional) 1D weights tensor with dimensions [num_units]. Can be nullptr. Data type supported: QSYMM16. cell_to_forget_weights (Optional) 1D weights tensor with dimensions [num_units]. Data type supported: QSYMM16. cell_to_output_weights (Optional) 1D weights tensor with dimensions [num_units]. Data type supported: QSYMM16. input_gate_bias (Optional) 1D weights tensor with dimensions [num_units]. Data type supported: S32. projection_weights (Optional) 2D weights tensor with dimensions [output_size, num_units]. Data type supported: QSYMM8. projection_bias (Optional) 1D weights tensor with dimensions [output_size]. S32. input_layer_norm_weights (Optional) 1D weights tensor with dimensions [num_units]. Data type supported: QSYMM16. forget_layer_norm_weights (Optional) 1D weights tensor with dimensions [num_units]. Data type supported: QSYMM16. cell_layer_norm_weights (Optional) 1D weights tensor with dimensions [num_units]. Data type supported: QSYMM16. output_layer_norm_weights (Optional) 1D weights tensor with dimensions [num_units]. Data type supported: QSYMM16. cell_threshold (Optional) 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. projection_threshold (Optional) 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 152 of file NEQLSTMLayer.cpp.
References TensorAllocator::allocate(), Tensor::allocator(), ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::utils::info_helpers::build_lstm_params_tensor_info(), arm_compute::quantization::calculate_quantized_multiplier(), LSTMParams< T >::cell_clip(), LSTMParams< T >::cell_intermediate_scale(), LSTMParams< T >::cell_layer_norm_weights(), LSTMParams< T >::cell_to_forget_weights(), LSTMParams< T >::cell_to_input_weights(), LSTMParams< T >::cell_to_output_weights(), NETranspose::configure(), NECopy::configure(), NEArithmeticSubtraction::configure(), NEActivationLayer::configure(), NEArithmeticAddition::configure(), NEPixelWiseMultiplication::configure(), NEGEMMLowpOutputStage::configure(), ITensorInfo::data_type(), ITensorInfo::dimension(), LSTMParams< T >::forget_intermediate_scale(), LSTMParams< T >::forget_layer_norm_weights(), GEMMLowpOutputStageInfo::gemmlowp_max_bound, GEMMLowpOutputStageInfo::gemmlowp_min_bound, GEMMLowpOutputStageInfo::gemmlowp_multiplier, GEMMLowpOutputStageInfo::gemmlowp_offset, GEMMLowpOutputStageInfo::gemmlowp_shift, LSTMParams< T >::has_cifg_opt(), LSTMParams< T >::has_peephole_opt(), LSTMParams< T >::has_projection(), LSTMParams< T >::hidden_state_scale(), LSTMParams< T >::hidden_state_zero(), ITensor::info(), Tensor::info(), TensorAllocator::init(), LSTMParams< T >::input_gate_bias(), LSTMParams< T >::input_intermediate_scale(), 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, ActivationLayerInfo::LOGISTIC, arm_compute::support::cpp11::lowest(), ActivationLayerInfo::LU_BOUNDED_RELU, MemoryGroup::manage(), UniformQuantizationInfo::offset, GEMMLowpOutputStageInfo::output_data_type, LSTMParams< T >::output_intermediate_scale(), LSTMParams< T >::output_layer_norm_weights(), arm_compute::test::validation::output_size, LSTMParams< T >::projection_bias(), LSTMParams< T >::projection_clip(), LSTMParams< T >::projection_weights(), arm_compute::QASYMM8_SIGNED, arm_compute::QSYMM16, ITensorInfo::quantization_info(), arm_compute::QUANTIZE_DOWN_FIXEDPOINT, arm_compute::quantize_qsymm16(), 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::S32, arm_compute::SATURATE, UniformQuantizationInfo::scale, ITensorInfo::set_tensor_shape(), TensorInfo::set_tensor_shape(), ActivationLayerInfo::TANH, ITensorInfo::tensor_shape(), TensorInfo::tensor_shape(), arm_compute::TO_ZERO, GEMMLowpOutputStageInfo::type, QuantizationInfo::uniform(), LSTMParams< T >::use_layer_norm(), and NEQLSTMLayer::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 pointers)
|
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 1085 of file NEQLSTMLayer.cpp.
References TensorAllocator::allocate(), Tensor::allocator(), Tensor::buffer(), Window::DimY, ITensorInfo::element_size(), Scheduler::get(), Tensor::info(), ITensor::mark_as_unused(), INESimpleFunctionNoBorder::run(), NEArithmeticAddition::run(), IScheduler::schedule(), and ITensorInfo::total_size().
Referenced by NEQLSTMLayer::run().
|
overridevirtual |
Run the kernels contained in the function.
For Neon kernels:
For OpenCL kernels:
Implements IFunction.
Definition at line 943 of file NEQLSTMLayer.cpp.
References Window::DimY, Scheduler::get(), NEQLSTMLayer::prepare(), INESimpleFunctionNoBorder::run(), NECopy::run(), NEArithmeticSubtraction::run(), NEActivationLayer::run(), NEArithmeticAddition::run(), NEGEMMLowpMatrixMultiplyCore::run(), NEPixelWiseMultiplication::run(), and IScheduler::schedule().
|
static |
Static function to check if given info will lead to a valid configuration of NEQLSTMLayer.
[in] | input | Source tensor info. Input is a 2D tensor info with dimensions [input_size, batch_size]. Data types supported: QASYMM8_SIGNED. |
[in] | input_to_forget_weights | 2D weights tensor info with dimensions [input_size, num_units]. Data type supported: QSYMM8. |
[in] | input_to_cell_weights | 2D weights tensor info with dimensions [input_size, num_units]. Data type supported: QSYMM8. |
[in] | input_to_output_weights | 2D weights tensor info with dimensions [input_size, num_units]. Data type supported: QSYMM8. |
[in] | recurrent_to_forget_weights | 2D weights tensor info with dimensions [output_size, num_units]. Data type supported: QSYMM8. |
[in] | recurrent_to_cell_weights | 2D weights tensor info with dimensions [output_size, num_units]. Data type supported: QSYMM8. |
[in] | recurrent_to_output_weights | 2D weights tensor info with dimensions [output_size, num_units]. Data type supported: QSYMM8. |
[in] | forget_gate_bias | 1D weights tensor info with dimensions [num_units]. Data type supported: S32. |
[in] | cell_bias | 1D weights tensor info with dimensions [num_units]. Data type supported: S32. |
[in] | output_gate_bias | 1D weights tensor info with dimensions [num_units]. Data type supported: S32. |
[in] | cell_state_in | 2D tensor info with dimensions [num_units, batch_size]. Data type supported: QSYMM16. |
[in] | output_state_in | 2D tensor info with dimensions [output_size, batch_size]. Data type supported: Same as input . |
[in] | cell_state_out | Destination tensor info. Output is a 2D tensor info with dimensions [num_units, batch_size]. Data type supported: QSYMM16. |
[in] | output_state_out | Destination tensor info. Output is a 2D tensor info with dimensions [output_size, batch_size].Data types supported: Same as input . |
[in] | output | Destination tensor info. Output is a 2D tensor info with dimensions [output_size, batch_size].Data types supported: Same as input . |
[in] | lstm_params | Weights tensors info used in peephole, CIFG and layer normalization optimizations: input_intermediate_scale Scale of the intermediate result of matmul, i.e. input to layer normalization, at input gate. forget_intermediate_scale Scale of the intermediate result of matmul, i.e. input to layer normalization, at forget gate. cell_intermediate_scale Scale of the intermediate result of matmul, i.e. input to layer normalization, at cell gate. output_intermediate_scale Scale of the intermediate result of matmul, i.e. input to layer normalization, at output gate. hidden_state_zero The zero point of the hidden state. hidden_state_scale The scale of the hidden state. input_to_input_weights (Optional) 2D weights tensor with dimensions [input_size, num_units]. Data type supported: QSYMM8. recurrent_to_input_weights (Optional) 2D weights tensor with dimensions [output_size, num_units]. Data type supported: QSYMM8. cell_to_input_weights (Optional) 1D weights tensor with dimensions [num_units]. Can be nullptr. Data type supported: QSYMM16. cell_to_forget_weights (Optional) 1D weights tensor with dimensions [num_units]. Data type supported: QSYMM16. cell_to_output_weights (Optional) 1D weights tensor with dimensions [num_units]. Data type supported: QSYMM16. input_gate_bias (Optional) 1D weights tensor with dimensions [num_units]. Data type supported: S32. projection_weights (Optional) 2D weights tensor with dimensions [output_size, num_units]. Data type supported: QSYMM8. projection_bias (Optional) 1D weights tensor with dimensions [output_size]. S32. input_layer_norm_weights (Optional) 1D weights tensor with dimensions [num_units]. Data type supported: QSYMM16. forget_layer_norm_weights (Optional) 1D weights tensor with dimensions [num_units]. Data type supported: QSYMM16. cell_layer_norm_weights (Optional) 1D weights tensor with dimensions [num_units]. Data type supported: QSYMM16. output_layer_norm_weights (Optional) 1D weights tensor with dimensions [num_units]. Data type supported: QSYMM16. cell_threshold (Optional) 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. projection_threshold (Optional) 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 579 of file NEQLSTMLayer.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_MISMATCHING_SHAPES, ARM_COMPUTE_RETURN_ERROR_ON_MSG, ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR, ARM_COMPUTE_RETURN_ON_ERROR, arm_compute::quantization::calculate_quantized_multiplier(), LSTMParams< T >::cell_clip(), LSTMParams< T >::cell_intermediate_scale(), LSTMParams< T >::cell_layer_norm_weights(), LSTMParams< T >::cell_to_forget_weights(), LSTMParams< T >::cell_to_input_weights(), LSTMParams< T >::cell_to_output_weights(), ITensorInfo::data_type(), TensorInfo::data_type(), ITensorInfo::dimension(), arm_compute::test::validation::forget_gate_bias, LSTMParams< T >::forget_intermediate_scale(), LSTMParams< T >::forget_layer_norm_weights(), GEMMLowpOutputStageInfo::gemmlowp_max_bound, GEMMLowpOutputStageInfo::gemmlowp_min_bound, GEMMLowpOutputStageInfo::gemmlowp_multiplier, GEMMLowpOutputStageInfo::gemmlowp_offset, GEMMLowpOutputStageInfo::gemmlowp_shift, LSTMParams< T >::has_cifg_opt(), LSTMParams< T >::has_peephole_opt(), LSTMParams< T >::has_projection(), LSTMParams< T >::hidden_state_scale(), LSTMParams< T >::hidden_state_zero(), LSTMParams< T >::input_gate_bias(), LSTMParams< T >::input_intermediate_scale(), LSTMParams< T >::input_layer_norm_weights(), arm_compute::test::validation::input_size, LSTMParams< T >::input_to_input_weights(), ActivationLayerInfo::LOGISTIC, arm_compute::support::cpp11::lowest(), ActivationLayerInfo::LU_BOUNDED_RELU, ITensorInfo::num_dimensions(), UniformQuantizationInfo::offset, GEMMLowpOutputStageInfo::output_data_type, arm_compute::test::validation::output_gate_bias, LSTMParams< T >::output_intermediate_scale(), LSTMParams< T >::output_layer_norm_weights(), arm_compute::test::validation::output_size, LSTMParams< T >::projection_bias(), LSTMParams< T >::projection_clip(), LSTMParams< T >::projection_weights(), arm_compute::QASYMM8_SIGNED, arm_compute::QSYMM16, arm_compute::QSYMM8, ITensorInfo::quantization_info(), arm_compute::QUANTIZE_DOWN_FIXEDPOINT, arm_compute::quantize_qasymm8_signed(), arm_compute::quantize_qsymm16(), LSTMParams< T >::recurrent_to_input_weights(), arm_compute::S32, arm_compute::SATURATE, UniformQuantizationInfo::scale, TensorInfo::set_tensor_shape(), ActivationLayerInfo::TANH, arm_compute::TO_ZERO, ITensorInfo::total_size(), GEMMLowpOutputStageInfo::type, QuantizationInfo::uniform(), LSTMParams< T >::use_layer_norm(), NETranspose::validate(), NECopy::validate(), NEArithmeticSubtraction::validate(), NEActivationLayer::validate(), NEArithmeticAddition::validate(), NEGEMMLowpMatrixAReductionKernel::validate(), NEPixelWiseMultiplication::validate(), arm_compute::validate(), and NEGEMMLowpOutputStage::validate().
Referenced by NEQLSTMLayer::configure().