![]() |
LIMA
Libre Multilingual Analyzer — C++ API
|
Handles multithreading. More...
#include <deeplima/nets/birnn_seq_cls.h>
Classes | |
| struct | slot_t |
| slot_t represents the part of the job processed by a classifier thread (tokenizer or tagger). More... | |
Public Member Functions | |
| RnnSequenceClassifier () | |
| virtual | ~RnnSequenceClassifier () |
| int32_t | next_slot (uint32_t idx) |
| std::shared_ptr< StdMatrix< Out > > | get_output () |
| virtual void | reset () |
| Need to be called to be able to reuse this classifier on several sequences. | |
| virtual void | init (uint32_t max_feat, uint32_t overlap, uint32_t num_slots, uint32_t slot_len, uint32_t num_threads, bool precomputed_input=false) |
| void | load (const std::string &fn) |
| void | get_classes_from_fn (const std::string &fn, std::vector< std::string > &classes_names, std::vector< std::vector< std::string > > &classes) |
| uint8_t | get_output (uint64_t pos, uint8_t cls) |
| uint64_t | get_slot_begin (uint32_t idx) const |
| uint64_t | get_slot_base (uint32_t idx) const |
| bool | get_slot_started (uint32_t idx) const |
| uint64_t | get_slot_end (uint32_t idx) const |
| uint8_t | get_lock_count (uint32_t idx) const |
| void | increment_lock_count (uint32_t idx, uint8_t v=1) |
| void | decrement_lock_count (uint32_t idx) |
| uint64_t | get_start_timepoint () const |
| void | increment_timepoint (uint64_t &timepoint) |
| uint32_t | get_num_slots () const |
| uint32_t | get_slot_size () const |
| int32_t | get_slot_idx (uint64_t timepoint) const |
| void | set_slot_lengths (uint32_t idx, const std::vector< size_t > &lengths) |
| void | set_slot_begin (uint32_t idx, uint64_t slot_begin) |
| void | set_slot_end (uint32_t idx, uint64_t slot_end) |
| void | start_job (uint32_t idx, bool no_more_data=false) |
| void | wait_for_slot (uint32_t idx) |
| void | pretty_print () const |
| Public Member Functions inherited from deeplima::ThreadPool< RnnSequenceClassifier< Model, InputVectorizer, Out > > | |
| ThreadPool (size_t num_threads=0) | |
| void | init (size_t num_threads) |
| size_t | get_num_threads () const |
| virtual | ~ThreadPool () |
| void | stop () |
| size_t | running () |
| void | push (void *job) |
Protected Types | |
| enum | slot_flags_t : uint8_t { none = 0x00 , left_overlap = 0x01 , right_overlap = 0x02 , max_flags } |
| typedef RnnSequenceClassifier< Model, InputVectorizer, Out > | ThisClass |
| typedef ThreadPool< ThisClass > | RnnSequenceClassifierThreadPool |
Protected Member Functions | |
| int32_t | prev_slot (uint32_t idx) |
| void | clear_slot (uint32_t idx) |
| void | start_job_impl (uint32_t idx) |
| Push the slot idx in the thread pool for starting the job on it. | |
| Protected Member Functions inherited from deeplima::ThreadPool< RnnSequenceClassifier< Model, InputVectorizer, Out > > | |
| bool | wait_for_new_job (void **job) |
| This will wait until a job is available and then job parameter will be set to this available which will be removed from the list. | |
| void | wait_for_any_job_notification (const std::function< bool()> fn) |
| void | thread_fn (size_t worker_id) |
Static Protected Member Functions | |
| static void | run_one_job (ThisClass *this_ptr, size_t worker_id, void *p) |
Protected Attributes | |
| friend | RnnSequenceClassifierThreadPool |
| uint32_t | m_overlap |
| uint32_t | m_num_slots |
| uint32_t | m_slot_len |
| std::vector< slot_t > | m_slots |
| std::vector< std::vector< size_t > > | m_lengths |
| std::shared_ptr< StdMatrix< Out > > | m_output |
| Protected Attributes inherited from deeplima::ThreadPool< RnnSequenceClassifier< Model, InputVectorizer, Out > > | |
| std::vector< std::thread > | m_workers |
| std::atomic< bool > | m_stop |
| std::queue< void * > | m_jobs |
| std::mutex | m_mutex |
| std::condition_variable | m_cv |
| std::mutex | m_mutex_notify |
| std::condition_variable | m_cv_notify |
Handles multithreading.
buffers from elsewhere are called slots here
Starts and stops threads. Each classifier has its own threadpool Each thread has its own stack so on machines with low memory, could be a problem.
The RnnSequenceClassifier is a Model, able to infer but also a thread pool to dispatch the work between several threads. And also a vectorizer, here a matrix.
Definition at line 46 of file birnn_seq_cls.h.
|
protected |
Definition at line 84 of file birnn_seq_cls.h.
|
protected |
Definition at line 83 of file birnn_seq_cls.h.
|
protected |
| Enumerator | |
|---|---|
| none | |
| left_overlap | |
| right_overlap | |
| max_flags | |
Definition at line 87 of file birnn_seq_cls.h.
|
inline |
Definition at line 51 of file birnn_seq_cls.h.
|
inlinevirtual |
Definition at line 75 of file birnn_seq_cls.h.
|
inlineprotected |
Definition at line 168 of file birnn_seq_cls.h.
|
inline |
Definition at line 415 of file birnn_seq_cls.h.
|
inline |
Definition at line 360 of file birnn_seq_cls.h.
|
inline |
Definition at line 399 of file birnn_seq_cls.h.
|
inline |
Definition at line 446 of file birnn_seq_cls.h.
|
inline |
Definition at line 261 of file birnn_seq_cls.h.
|
inline |
Definition at line 364 of file birnn_seq_cls.h.
|
inline |
Definition at line 381 of file birnn_seq_cls.h.
|
inline |
Definition at line 373 of file birnn_seq_cls.h.
|
inline |
Definition at line 393 of file birnn_seq_cls.h.
|
inline |
Definition at line 456 of file birnn_seq_cls.h.
|
inline |
Definition at line 451 of file birnn_seq_cls.h.
|
inline |
Definition at line 387 of file birnn_seq_cls.h.
|
inline |
Definition at line 430 of file birnn_seq_cls.h.
|
inline |
Definition at line 405 of file birnn_seq_cls.h.
|
inline |
Definition at line 437 of file birnn_seq_cls.h.
|
inlinevirtual |
Definition at line 312 of file birnn_seq_cls.h.
|
inline |
Definition at line 354 of file birnn_seq_cls.h.
|
inline |
Definition at line 254 of file birnn_seq_cls.h.
|
inline |
Definition at line 569 of file birnn_seq_cls.h.
|
inlineprotected |
Definition at line 161 of file birnn_seq_cls.h.
|
inlinevirtual |
Need to be called to be able to reuse this classifier on several sequences.
Reimplemented in deeplima::tagging::impl::TaggingImpl< TaggingAuxScalar >, and deeplima::tagging::impl::TaggingImpl< float >.
Definition at line 269 of file birnn_seq_cls.h.
|
inlinestaticprotected |
Definition at line 202 of file birnn_seq_cls.h.
|
inline |
Definition at line 476 of file birnn_seq_cls.h.
|
inline |
Definition at line 498 of file birnn_seq_cls.h.
|
inline |
Definition at line 464 of file birnn_seq_cls.h.
|
inline |
Definition at line 514 of file birnn_seq_cls.h.
|
inlineprotected |
Push the slot idx in the thread pool for starting the job on it.
Definition at line 185 of file birnn_seq_cls.h.
|
inline |
Definition at line 550 of file birnn_seq_cls.h.
|
protected |
Definition at line 585 of file birnn_seq_cls.h.
|
protected |
Definition at line 581 of file birnn_seq_cls.h.
|
protected |
Definition at line 586 of file birnn_seq_cls.h.
|
protected |
Definition at line 580 of file birnn_seq_cls.h.
|
protected |
Definition at line 582 of file birnn_seq_cls.h.
|
protected |
Definition at line 584 of file birnn_seq_cls.h.
|
protected |
Definition at line 85 of file birnn_seq_cls.h.