LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
deeplima::nets::StaticGraphImpl Class Reference

Implementation for Torch of the Tensorflow execution graph Used in training only. More...

#include </home/runner/work/lima/lima/deeplima/libs/static_graph/static_graph.h>

Inheritance diagram for deeplima::nets::StaticGraphImpl:
deeplima::nets::BiRnnClassifierImpl deeplima::graph_dp::train::BiRnnAndDeepBiaffineAttentionImpl deeplima::nets::BiRnnSeq2SeqImpl deeplima::segmentation::train::BiRnnClassifierForSegmentationImpl deeplima::tagging::train::BiRnnClassifierForNerImpl deeplima::lemmatization::train::Seq2SeqLemmatizerImpl

Classes

struct  module_ref_t
 

Public Member Functions

 StaticGraphImpl (const DictsHolder &dicts, const std::string &script)
 
 StaticGraphImpl (DictsHolder &&dicts, const std::string &script)
 
 StaticGraphImpl ()
 
virtual void load (torch::serialize::InputArchive &archive) override
 
virtual void save (torch::serialize::OutputArchive &archive) const override
 
virtual void set_tags (const std::map< std::string, std::string > &tags)
 
virtual const std::map< std::string, std::string > & get_tags () const
 
virtual bool has_tag (const std::string &key) const
 
virtual void to (torch::Device device, bool non_blocking=false) override
 
std::map< std::string, torch::Tensor > forward (const std::map< std::string, torch::Tensor > &inputs, const std::string &output_name)
 
std::map< std::string, torch::Tensor > forward (const std::map< std::string, torch::Tensor > &inputs, const std::vector< std::string > &output_names)
 
template<class InputIt >
std::map< std::string, torch::Tensor > forward (const std::map< std::string, torch::Tensor > &inputs, InputIt outputs_begin, InputIt outputs_end)
 
virtual void pretty_dump (std::ostream &stream) const
 
const DictsHolder & get_dicts () const
 
const std::string & get_script () const
 
const std::vector< torch::nn::LSTM > & get_layers_lstm () const
 
const std::vector< torch::nn::Linear > & get_layers_linear () const
 
const std::vector< torch::nn::Embedding > & get_layers_embedding () const
 
const std::vector< torch::nn::Dropout > & get_layers_dropout () const
 
const std::vector< deeplima::nets::torch_modules::DeepBiaffineAttentionDecoder > & get_layers_deep_biaffine_attn_decoder () const
 
const std::vector< deeplima::nets::torch_modules::DeepBiaffineAttentionLabelDecoder > & get_layers_deep_biaffine_attn_label_decoder () const
 
torch::nn::Embedding get_module_by_name (const std::string &name) const
 
const std::string get_module_name (size_t idx, const std::string &type) const
 

Protected Member Functions

virtual void parse_script (const std::string &script)
 
virtual step_descr_t parse_script_line (const std::string &line)
 
virtual std::map< std::string, std::string > parse_options (std::istringstream &ss)
 
virtual std::vector< std::string > parse_list (std::string &str, char sep)
 
virtual std::vector< int64_t > parse_iargs (const std::string &str)
 
template<class InputIt >
void prepare_exec_plan (const std::map< std::string, torch::Tensor > &inputs, InputIt outputs_begin, InputIt outputs_end)
 
template<class InputIt >
std::string get_exec_plan_key (const std::map< std::string, torch::Tensor > &inputs, InputIt outputs_begin, InputIt outputs_end)
 
template<class T >
T get_option (const std::map< std::string, std::string > &opts, const std::string &name)
 
bool get_bool_option (const std::map< std::string, std::string > &opts, const std::string &name)
 
virtual void create_arg (const std::vector< std::string > &names, const std::map< std::string, std::string > &opts)
 
virtual void create_submodule_Embedding (const std::string &name, const std::map< std::string, std::string > &opts)
 
virtual void create_submodule_LSTM (const std::string &name, const std::map< std::string, std::string > &opts)
 
virtual void create_submodule_Linear (const std::string &name, const std::map< std::string, std::string > &opts)
 
virtual void create_submodule_Dropout (const std::string &name, const std::map< std::string, std::string > &opts)
 
virtual void create_submodule_DeepBiaffineAttentionDecoder (const std::string &name, const std::map< std::string, std::string > &opts)
 
virtual void create_submodule_DeepBiaffineAttentionLabelDecoder (const std::string &name, const std::map< std::string, std::string > &opts)
 
virtual void init_rnns ()
 

Protected Attributes

std::map< std::string, std::vector< size_t > > m_exec_plans
 
DictsHolder m_dicts
 
std::string m_script
 
std::map< std::string, std::string > m_tags
 
std::vector< torch::nn::Embedding > m_embedding
 
std::vector< torch::nn::LSTM > m_lstm
 
std::vector< torch::nn::Linear > m_linear
 
std::vector< torch::nn::Dropout > m_dropout
 
std::vector< deeplima::nets::torch_modules::DeepBiaffineAttentionDecoder > m_deep_biaffine_attention_decoder
 
std::vector< deeplima::nets::torch_modules::DeepBiaffineAttentionLabelDecoder > m_deep_biaffine_attention_label_decoder
 
std::map< std::string, module_ref_t > m_modules
 
std::set< std::string > m_args
 
std::map< std::string, size_t > m_tensor_name_to_idx
 
std::vector< op_t > m_ops
 
std::map< size_t, size_t > m_outidx_to_opidx
 

Detailed Description

Implementation for Torch of the Tensorflow execution graph Used in training only.

Only loaded in inference In pytorch, the graph is implied from the computing and then saved. This is not implemented in libtorch.

Definition at line 31 of file static_graph.h.

Constructor & Destructor Documentation

◆ StaticGraphImpl() [1/3]

deeplima::nets::StaticGraphImpl::StaticGraphImpl ( const DictsHolder &  dicts,
const std::string &  script 
)

Definition at line 20 of file static_graph.cpp.

◆ StaticGraphImpl() [2/3]

deeplima::nets::StaticGraphImpl::StaticGraphImpl ( DictsHolder &&  dicts,
const std::string &  script 
)

Definition at line 28 of file static_graph.cpp.

◆ StaticGraphImpl() [3/3]

deeplima::nets::StaticGraphImpl::StaticGraphImpl ( )
inline

Definition at line 114 of file static_graph.h.

Member Function Documentation

◆ create_arg()

void deeplima::nets::StaticGraphImpl::create_arg ( const std::vector< std::string > &  names,
const std::map< std::string, std::string > &  opts 
)
protectedvirtual

Definition at line 751 of file static_graph.cpp.

◆ create_submodule_DeepBiaffineAttentionDecoder()

void deeplima::nets::StaticGraphImpl::create_submodule_DeepBiaffineAttentionDecoder ( const std::string &  name,
const std::map< std::string, std::string > &  opts 
)
protectedvirtual

Definition at line 889 of file static_graph.cpp.

◆ create_submodule_DeepBiaffineAttentionLabelDecoder()

void deeplima::nets::StaticGraphImpl::create_submodule_DeepBiaffineAttentionLabelDecoder ( const std::string &  name,
const std::map< std::string, std::string > &  opts 
)
protectedvirtual

Definition at line 901 of file static_graph.cpp.

◆ create_submodule_Dropout()

void deeplima::nets::StaticGraphImpl::create_submodule_Dropout ( const std::string &  name,
const std::map< std::string, std::string > &  opts 
)
protectedvirtual

Definition at line 795 of file static_graph.cpp.

◆ create_submodule_Embedding()

void deeplima::nets::StaticGraphImpl::create_submodule_Embedding ( const std::string &  name,
const std::map< std::string, std::string > &  opts 
)
protectedvirtual

Definition at line 771 of file static_graph.cpp.

◆ create_submodule_Linear()

void deeplima::nets::StaticGraphImpl::create_submodule_Linear ( const std::string &  name,
const std::map< std::string, std::string > &  opts 
)
protectedvirtual

Definition at line 815 of file static_graph.cpp.

◆ create_submodule_LSTM()

void deeplima::nets::StaticGraphImpl::create_submodule_LSTM ( const std::string &  name,
const std::map< std::string, std::string > &  opts 
)
protectedvirtual

Definition at line 836 of file static_graph.cpp.

◆ forward() [1/3]

std::map< std::string, torch::Tensor > deeplima::nets::StaticGraphImpl::forward ( const std::map< std::string, torch::Tensor > &  inputs,
const std::string &  output_name 
)
inline

Definition at line 130 of file static_graph.h.

◆ forward() [2/3]

std::map< std::string, torch::Tensor > deeplima::nets::StaticGraphImpl::forward ( const std::map< std::string, torch::Tensor > &  inputs,
const std::vector< std::string > &  output_names 
)
inline

Definition at line 138 of file static_graph.h.

◆ forward() [3/3]

template<class InputIt >
std::map< std::string, torch::Tensor > deeplima::nets::StaticGraphImpl::forward ( const std::map< std::string, torch::Tensor > &  inputs,
InputIt  outputs_begin,
InputIt  outputs_end 
)
inline

Definition at line 146 of file static_graph.h.

◆ get_bool_option()

bool deeplima::nets::StaticGraphImpl::get_bool_option ( const std::map< std::string, std::string > &  opts,
const std::string &  name 
)
inlineprotected

Definition at line 343 of file static_graph.h.

◆ get_dicts()

const DictsHolder & deeplima::nets::StaticGraphImpl::get_dicts ( ) const
inline

Definition at line 213 of file static_graph.h.

◆ get_exec_plan_key()

template<class InputIt >
std::string deeplima::nets::StaticGraphImpl::get_exec_plan_key ( const std::map< std::string, torch::Tensor > &  inputs,
InputIt  outputs_begin,
InputIt  outputs_end 
)
inlineprotected

Definition at line 298 of file static_graph.h.

◆ get_layers_deep_biaffine_attn_decoder()

const std::vector< deeplima::nets::torch_modules::DeepBiaffineAttentionDecoder > & deeplima::nets::StaticGraphImpl::get_layers_deep_biaffine_attn_decoder ( ) const
inline

Definition at line 411 of file static_graph.h.

◆ get_layers_deep_biaffine_attn_label_decoder()

const std::vector< deeplima::nets::torch_modules::DeepBiaffineAttentionLabelDecoder > & deeplima::nets::StaticGraphImpl::get_layers_deep_biaffine_attn_label_decoder ( ) const
inline

Definition at line 416 of file static_graph.h.

◆ get_layers_dropout()

const std::vector< torch::nn::Dropout > & deeplima::nets::StaticGraphImpl::get_layers_dropout ( ) const
inline

Definition at line 406 of file static_graph.h.

◆ get_layers_embedding()

const std::vector< torch::nn::Embedding > & deeplima::nets::StaticGraphImpl::get_layers_embedding ( ) const
inline

Definition at line 401 of file static_graph.h.

◆ get_layers_linear()

const std::vector< torch::nn::Linear > & deeplima::nets::StaticGraphImpl::get_layers_linear ( ) const
inline

Definition at line 396 of file static_graph.h.

◆ get_layers_lstm()

const std::vector< torch::nn::LSTM > & deeplima::nets::StaticGraphImpl::get_layers_lstm ( ) const
inline

Definition at line 391 of file static_graph.h.

◆ get_module_by_name()

torch::nn::Embedding deeplima::nets::StaticGraphImpl::get_module_by_name ( const std::string &  name) const
inline

Definition at line 426 of file static_graph.h.

◆ get_module_name()

const std::string deeplima::nets::StaticGraphImpl::get_module_name ( size_t  idx,
const std::string &  type 
) const
inline

Definition at line 438 of file static_graph.h.

◆ get_option()

template<class T >
T deeplima::nets::StaticGraphImpl::get_option ( const std::map< std::string, std::string > &  opts,
const std::string &  name 
)
inlineprotected

Definition at line 324 of file static_graph.h.

◆ get_script()

const std::string & deeplima::nets::StaticGraphImpl::get_script ( ) const
inline

Definition at line 385 of file static_graph.h.

◆ get_tags()

virtual const std::map< std::string, std::string > & deeplima::nets::StaticGraphImpl::get_tags ( ) const
inlinevirtual

Definition at line 119 of file static_graph.h.

◆ has_tag()

virtual bool deeplima::nets::StaticGraphImpl::has_tag ( const std::string &  key) const
inlinevirtual

Definition at line 123 of file static_graph.h.

◆ init_rnns()

void deeplima::nets::StaticGraphImpl::init_rnns ( )
protectedvirtual

Definition at line 943 of file static_graph.cpp.

◆ load()

◆ parse_iargs()

vector< int64_t > deeplima::nets::StaticGraphImpl::parse_iargs ( const std::string &  str)
protectedvirtual

Definition at line 741 of file static_graph.cpp.

◆ parse_list()

vector< string > deeplima::nets::StaticGraphImpl::parse_list ( std::string &  str,
char  sep 
)
protectedvirtual

Definition at line 593 of file static_graph.cpp.

◆ parse_options()

map< string, string > deeplima::nets::StaticGraphImpl::parse_options ( std::istringstream &  ss)
protectedvirtual

Definition at line 569 of file static_graph.cpp.

◆ parse_script()

void deeplima::nets::StaticGraphImpl::parse_script ( const std::string &  script)
protectedvirtual

Definition at line 200 of file static_graph.cpp.

◆ parse_script_line()

StaticGraphImpl::step_descr_t deeplima::nets::StaticGraphImpl::parse_script_line ( const std::string &  line)
protectedvirtual

Definition at line 611 of file static_graph.cpp.

◆ prepare_exec_plan()

template<class InputIt >
void deeplima::nets::StaticGraphImpl::prepare_exec_plan ( const std::map< std::string, torch::Tensor > &  inputs,
InputIt  outputs_begin,
InputIt  outputs_end 
)
inlineprotected

Definition at line 228 of file static_graph.h.

◆ pretty_dump()

void deeplima::nets::StaticGraphImpl::pretty_dump ( std::ostream &  stream) const
virtual

Definition at line 168 of file static_graph.cpp.

◆ save()

◆ set_tags()

void deeplima::nets::StaticGraphImpl::set_tags ( const std::map< std::string, std::string > &  tags)
virtual

Definition at line 160 of file static_graph.cpp.

◆ to()

void deeplima::nets::StaticGraphImpl::to ( torch::Device  device,
bool  non_blocking = false 
)
overridevirtual

Definition at line 188 of file static_graph.cpp.

Member Data Documentation

◆ m_args

std::set<std::string> deeplima::nets::StaticGraphImpl::m_args
protected

Definition at line 500 of file static_graph.h.

◆ m_deep_biaffine_attention_decoder

std::vector<deeplima::nets::torch_modules::DeepBiaffineAttentionDecoder> deeplima::nets::StaticGraphImpl::m_deep_biaffine_attention_decoder
protected

Definition at line 380 of file static_graph.h.

◆ m_deep_biaffine_attention_label_decoder

std::vector<deeplima::nets::torch_modules::DeepBiaffineAttentionLabelDecoder> deeplima::nets::StaticGraphImpl::m_deep_biaffine_attention_label_decoder
protected

Definition at line 381 of file static_graph.h.

◆ m_dicts

DictsHolder deeplima::nets::StaticGraphImpl::m_dicts
protected

Definition at line 372 of file static_graph.h.

◆ m_dropout

std::vector<torch::nn::Dropout> deeplima::nets::StaticGraphImpl::m_dropout
protected

Definition at line 379 of file static_graph.h.

◆ m_embedding

std::vector<torch::nn::Embedding> deeplima::nets::StaticGraphImpl::m_embedding
protected

Definition at line 376 of file static_graph.h.

◆ m_exec_plans

std::map<std::string, std::vector<size_t> > deeplima::nets::StaticGraphImpl::m_exec_plans
protected

Definition at line 225 of file static_graph.h.

◆ m_linear

std::vector<torch::nn::Linear> deeplima::nets::StaticGraphImpl::m_linear
protected

Definition at line 378 of file static_graph.h.

◆ m_lstm

std::vector<torch::nn::LSTM> deeplima::nets::StaticGraphImpl::m_lstm
protected

Definition at line 377 of file static_graph.h.

◆ m_modules

std::map<std::string, module_ref_t> deeplima::nets::StaticGraphImpl::m_modules
protected

Definition at line 499 of file static_graph.h.

◆ m_ops

std::vector<op_t> deeplima::nets::StaticGraphImpl::m_ops
protected

Definition at line 502 of file static_graph.h.

◆ m_outidx_to_opidx

std::map<size_t, size_t> deeplima::nets::StaticGraphImpl::m_outidx_to_opidx
protected

Definition at line 503 of file static_graph.h.

◆ m_script

std::string deeplima::nets::StaticGraphImpl::m_script
protected

Definition at line 373 of file static_graph.h.

◆ m_tags

std::map<std::string, std::string> deeplima::nets::StaticGraphImpl::m_tags
protected

Definition at line 374 of file static_graph.h.

◆ m_tensor_name_to_idx

std::map<std::string, size_t> deeplima::nets::StaticGraphImpl::m_tensor_name_to_idx
protected

Definition at line 501 of file static_graph.h.


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