LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
deeplima::eigen_impl::Op_BiLSTM_Dense_ArgMax< M, V, T, AuxScalar, IFracBits, WFracBits > Class Template Reference

Fusion of several torch modules implemented for inference in Eigen. More...

#include <deeplima/eigen_wrp/bilstm_and_dense.h>

Inheritance diagram for deeplima::eigen_impl::Op_BiLSTM_Dense_ArgMax< M, V, T, AuxScalar, IFracBits, WFracBits >:
deeplima::eigen_impl::Op_Base

Classes

struct  workbench_t
struct  params_bilstm_dense_argmax_t

Public Types

typedef params_bilstm_dense_argmax_t params_t

Public Member Functions

virtual std::shared_ptr< Op_Base::workbench_t > create_workbench (uint32_t input_size, const std::shared_ptr< param_base_t > params, bool precomputed_input=false) const override
virtual bool supports_precomputing () const
virtual void precompute_inputs (const std::shared_ptr< param_base_t > params, const M &inputs, M &outputs, int64_t first_column)
virtual size_t execute (std::shared_ptr< Op_Base::workbench_t > pwb, const M &input_matrix, const std::shared_ptr< param_base_t > pparams, std::vector< std::vector< uint8_t > > &final_output, size_t input_begin, size_t input_end, size_t output_begin, size_t output_end)
Public Member Functions inherited from deeplima::eigen_impl::Op_Base
virtual ~Op_Base ()

Protected Types

typedef AuxScalar fixed_point_t
using MatrixWeight
using MatrixInput

Protected Member Functions

void forward_pass (const size_t hidden_size, Eigen::Ref< const M > input, const MatrixWeight &weight_hh, V &s, V &c, M &output)
void backward_pass (const size_t hidden_size, Eigen::Ref< const M > input, const MatrixWeight &weight_hh, V &s, V &c, M &output)
void update_c (const size_t hidden_size, const V &s, V &c)
void step_fw (const size_t hidden_size, const size_t t, const V &s, V &c, M &output)
void step_bw (const size_t hidden_size, const size_t t, const V &s, V &c, M &output)

Static Protected Member Functions

static constexpr fixed_point_t pow2 (int bits)

Static Protected Attributes

static constexpr fixed_point_t WEIGHT_FRACTION_MULT = pow2(WFracBits)
static constexpr fixed_point_t DATA_FRACTION_MULT = pow2(IFracBits)
static constexpr fixed_point_t WEIGHT_DATA_FRACTION_MULT = pow2(WFracBits + IFracBits)

Detailed Description

template<typename M, typename V, typename T, typename AuxScalar = float, uint8_t IFracBits = 4, uint8_t WFracBits = 4>
class deeplima::eigen_impl::Op_BiLSTM_Dense_ArgMax< M, V, T, AuxScalar, IFracBits, WFracBits >

Fusion of several torch modules implemented for inference in Eigen.

Precomputed inputs. The x of each gate is fasttext embeddings. They can be computed during model loading. This is done in precompute_inputs. This takes a very long time. This can be done in the first layer only

forward_pass is different for fixed point and non-fixed point

The implementation with factorization is less efficient while it should be more.

In linear layer on top of RNN outputs.

  • Could bequicker in fixed point than in floating point but not sure. Must be tested
  • For pos tagging, could avoid to compute everything because it is very sparse but the code must stay generic and cannot use information specific to morphologic model.

In fixed, only last step is in fixed because some necessary functions (tanh…) are not implemented in fixed but quicker nevertheless

Definition at line 55 of file bilstm_and_dense.h.

Member Typedef Documentation

◆ fixed_point_t

template<typename M, typename V, typename T, typename AuxScalar = float, uint8_t IFracBits = 4, uint8_t WFracBits = 4>
typedef AuxScalar deeplima::eigen_impl::Op_BiLSTM_Dense_ArgMax< M, V, T, AuxScalar, IFracBits, WFracBits >::fixed_point_t
protected

Definition at line 61 of file bilstm_and_dense.h.

◆ MatrixInput

template<typename M, typename V, typename T, typename AuxScalar = float, uint8_t IFracBits = 4, uint8_t WFracBits = 4>
using deeplima::eigen_impl::Op_BiLSTM_Dense_ArgMax< M, V, T, AuxScalar, IFracBits, WFracBits >::MatrixInput
protected
Initial value:
typename std::conditional<std::is_integral_v<AuxScalar> && std::is_signed_v<AuxScalar>,
Eigen::Matrix<fixed_point_t, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor>,
M>::type

Definition at line 65 of file bilstm_and_dense.h.

◆ MatrixWeight

template<typename M, typename V, typename T, typename AuxScalar = float, uint8_t IFracBits = 4, uint8_t WFracBits = 4>
using deeplima::eigen_impl::Op_BiLSTM_Dense_ArgMax< M, V, T, AuxScalar, IFracBits, WFracBits >::MatrixWeight
protected
Initial value:
typename std::conditional<std::is_integral_v<AuxScalar> && std::is_signed_v<AuxScalar>,
Eigen::Matrix<fixed_point_t, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>,
M>::type

Definition at line 62 of file bilstm_and_dense.h.

◆ params_t

template<typename M, typename V, typename T, typename AuxScalar = float, uint8_t IFracBits = 4, uint8_t WFracBits = 4>
typedef params_bilstm_dense_argmax_t deeplima::eigen_impl::Op_BiLSTM_Dense_ArgMax< M, V, T, AuxScalar, IFracBits, WFracBits >::params_t

Definition at line 195 of file bilstm_and_dense.h.

Member Function Documentation

◆ backward_pass()

template<typename M, typename V, typename T, typename AuxScalar = float, uint8_t IFracBits = 4, uint8_t WFracBits = 4>
void deeplima::eigen_impl::Op_BiLSTM_Dense_ArgMax< M, V, T, AuxScalar, IFracBits, WFracBits >::backward_pass ( const size_t hidden_size,
Eigen::Ref< const M > input,
const MatrixWeight & weight_hh,
V & s,
V & c,
M & output )
inlineprotected

Definition at line 554 of file bilstm_and_dense.h.

◆ create_workbench()

template<typename M, typename V, typename T, typename AuxScalar = float, uint8_t IFracBits = 4, uint8_t WFracBits = 4>
virtual std::shared_ptr< Op_Base::workbench_t > deeplima::eigen_impl::Op_BiLSTM_Dense_ArgMax< M, V, T, AuxScalar, IFracBits, WFracBits >::create_workbench ( uint32_t input_size,
const std::shared_ptr< param_base_t > params,
bool precomputed_input = false ) const
inlineoverridevirtual

Implements deeplima::eigen_impl::Op_Base.

Definition at line 197 of file bilstm_and_dense.h.

◆ execute()

template<typename M, typename V, typename T, typename AuxScalar = float, uint8_t IFracBits = 4, uint8_t WFracBits = 4>
virtual size_t deeplima::eigen_impl::Op_BiLSTM_Dense_ArgMax< M, V, T, AuxScalar, IFracBits, WFracBits >::execute ( std::shared_ptr< Op_Base::workbench_t > pwb,
const M & input_matrix,
const std::shared_ptr< param_base_t > pparams,
std::vector< std::vector< uint8_t > > & final_output,
size_t input_begin,
size_t input_end,
size_t output_begin,
size_t output_end )
inlinevirtual

Definition at line 249 of file bilstm_and_dense.h.

◆ forward_pass()

template<typename M, typename V, typename T, typename AuxScalar = float, uint8_t IFracBits = 4, uint8_t WFracBits = 4>
void deeplima::eigen_impl::Op_BiLSTM_Dense_ArgMax< M, V, T, AuxScalar, IFracBits, WFracBits >::forward_pass ( const size_t hidden_size,
Eigen::Ref< const M > input,
const MatrixWeight & weight_hh,
V & s,
V & c,
M & output )
inlineprotected

Definition at line 457 of file bilstm_and_dense.h.

◆ pow2()

template<typename M, typename V, typename T, typename AuxScalar = float, uint8_t IFracBits = 4, uint8_t WFracBits = 4>
constexpr fixed_point_t deeplima::eigen_impl::Op_BiLSTM_Dense_ArgMax< M, V, T, AuxScalar, IFracBits, WFracBits >::pow2 ( int bits)
inlinestaticconstexprprotected

Definition at line 72 of file bilstm_and_dense.h.

◆ precompute_inputs()

template<typename M, typename V, typename T, typename AuxScalar = float, uint8_t IFracBits = 4, uint8_t WFracBits = 4>
virtual void deeplima::eigen_impl::Op_BiLSTM_Dense_ArgMax< M, V, T, AuxScalar, IFracBits, WFracBits >::precompute_inputs ( const std::shared_ptr< param_base_t > params,
const M & inputs,
M & outputs,
int64_t first_column )
inlinevirtual

Definition at line 223 of file bilstm_and_dense.h.

◆ step_bw()

template<typename M, typename V, typename T, typename AuxScalar = float, uint8_t IFracBits = 4, uint8_t WFracBits = 4>
void deeplima::eigen_impl::Op_BiLSTM_Dense_ArgMax< M, V, T, AuxScalar, IFracBits, WFracBits >::step_bw ( const size_t hidden_size,
const size_t t,
const V & s,
V & c,
M & output )
inlineprotected

Definition at line 621 of file bilstm_and_dense.h.

◆ step_fw()

template<typename M, typename V, typename T, typename AuxScalar = float, uint8_t IFracBits = 4, uint8_t WFracBits = 4>
void deeplima::eigen_impl::Op_BiLSTM_Dense_ArgMax< M, V, T, AuxScalar, IFracBits, WFracBits >::step_fw ( const size_t hidden_size,
const size_t t,
const V & s,
V & c,
M & output )
inlineprotected

Definition at line 607 of file bilstm_and_dense.h.

◆ supports_precomputing()

template<typename M, typename V, typename T, typename AuxScalar = float, uint8_t IFracBits = 4, uint8_t WFracBits = 4>
virtual bool deeplima::eigen_impl::Op_BiLSTM_Dense_ArgMax< M, V, T, AuxScalar, IFracBits, WFracBits >::supports_precomputing ( ) const
inlinevirtual

Definition at line 218 of file bilstm_and_dense.h.

◆ update_c()

template<typename M, typename V, typename T, typename AuxScalar = float, uint8_t IFracBits = 4, uint8_t WFracBits = 4>
void deeplima::eigen_impl::Op_BiLSTM_Dense_ArgMax< M, V, T, AuxScalar, IFracBits, WFracBits >::update_c ( const size_t hidden_size,
const V & s,
V & c )
inlineprotected

Definition at line 594 of file bilstm_and_dense.h.

Member Data Documentation

◆ DATA_FRACTION_MULT

template<typename M, typename V, typename T, typename AuxScalar = float, uint8_t IFracBits = 4, uint8_t WFracBits = 4>
fixed_point_t deeplima::eigen_impl::Op_BiLSTM_Dense_ArgMax< M, V, T, AuxScalar, IFracBits, WFracBits >::DATA_FRACTION_MULT = pow2(IFracBits)
staticconstexprprotected

Definition at line 80 of file bilstm_and_dense.h.

◆ WEIGHT_DATA_FRACTION_MULT

template<typename M, typename V, typename T, typename AuxScalar = float, uint8_t IFracBits = 4, uint8_t WFracBits = 4>
fixed_point_t deeplima::eigen_impl::Op_BiLSTM_Dense_ArgMax< M, V, T, AuxScalar, IFracBits, WFracBits >::WEIGHT_DATA_FRACTION_MULT = pow2(WFracBits + IFracBits)
staticconstexprprotected

Definition at line 81 of file bilstm_and_dense.h.

◆ WEIGHT_FRACTION_MULT

template<typename M, typename V, typename T, typename AuxScalar = float, uint8_t IFracBits = 4, uint8_t WFracBits = 4>
fixed_point_t deeplima::eigen_impl::Op_BiLSTM_Dense_ArgMax< M, V, T, AuxScalar, IFracBits, WFracBits >::WEIGHT_FRACTION_MULT = pow2(WFracBits)
staticconstexprprotected

Definition at line 79 of file bilstm_and_dense.h.


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