Class ComputationCache is used inside class CachingOptimizingCompiler to cache previously computed computations. More...
#include <nnet-optimize-utils.h>

Public Member Functions | |
| ComputationCache (int32 cache_capacity) | |
| void | Read (std::istream &is, bool binary) |
| void | Write (std::ostream &os, bool binary) const |
| std::shared_ptr< const NnetComputation > | Find (const ComputationRequest &request) |
| std::shared_ptr< const NnetComputation > | Insert (const ComputationRequest &request, const NnetComputation *computation) |
| ~ComputationCache () | |
| void | Check (const Nnet &nnet) const |
Private Types | |
| typedef std::list< const ComputationRequest * > | AqType |
| typedef unordered_map< const ComputationRequest *, std::pair< std::shared_ptr< const NnetComputation >, AqType::iterator >, ComputationRequestHasher, ComputationRequestPtrEqual > | CacheType |
Private Attributes | |
| std::mutex | mutex_ |
| int32 | cache_capacity_ |
| AqType | access_queue_ |
| CacheType | computation_cache_ |
Class ComputationCache is used inside class CachingOptimizingCompiler to cache previously computed computations.
The code was moved from class CachingOptimizingCompiler to this separate class for clarity when adding thread-safety functionality. It's OK to call Find() and Insert() from multiple threads without additional synchronization.
Definition at line 625 of file nnet-optimize-utils.h.
|
private |
Definition at line 668 of file nnet-optimize-utils.h.
|
private |
Definition at line 677 of file nnet-optimize-utils.h.
| ComputationCache | ( | int32 | cache_capacity | ) |
Definition at line 4969 of file nnet-optimize-utils.cc.
References KALDI_ASSERT.
| ~ComputationCache | ( | ) |
Definition at line 5062 of file nnet-optimize-utils.cc.
References ComputationCache::computation_cache_.
| void Check | ( | const Nnet & | nnet | ) | const |
Definition at line 5037 of file nnet-optimize-utils.cc.
References ComputationChecker::Check(), and ComputationCache::computation_cache_.
Referenced by CachingOptimizingCompiler::ReadCache().
| std::shared_ptr< const NnetComputation > Find | ( | const ComputationRequest & | request | ) |
Definition at line 4951 of file nnet-optimize-utils.cc.
Referenced by CachingOptimizingCompiler::CompileInternal().
| std::shared_ptr< const NnetComputation > Insert | ( | const ComputationRequest & | request, |
| const NnetComputation * | computation | ||
| ) |
Definition at line 4974 of file nnet-optimize-utils.cc.
References ComputationCache::access_queue_, ComputationCache::cache_capacity_, ComputationCache::computation_cache_, KALDI_ASSERT, and ComputationCache::mutex_.
Referenced by CachingOptimizingCompiler::CompileInternal(), and ComputationCache::Read().
| void Read | ( | std::istream & | is, |
| bool | binary | ||
| ) |
Definition at line 5018 of file nnet-optimize-utils.cc.
References ComputationCache::access_queue_, ComputationCache::computation_cache_, kaldi::nnet3::ExpectToken(), ComputationCache::Insert(), KALDI_ASSERT, kaldi::nnet2::NnetComputation(), ComputationRequest::Read(), NnetComputation::Read(), and kaldi::ReadBasicType().
Referenced by CachingOptimizingCompiler::ReadCache().
| void Write | ( | std::ostream & | os, |
| bool | binary | ||
| ) | const |
Definition at line 5051 of file nnet-optimize-utils.cc.
References ComputationCache::computation_cache_, kaldi::WriteBasicType(), and kaldi::WriteToken().
Referenced by CachingOptimizingCompiler::WriteCache().
|
private |
Definition at line 669 of file nnet-optimize-utils.h.
Referenced by ComputationCache::Insert(), and ComputationCache::Read().
|
private |
Definition at line 660 of file nnet-optimize-utils.h.
Referenced by ComputationCache::Insert().
|
private |
Definition at line 678 of file nnet-optimize-utils.h.
Referenced by ComputationCache::Check(), ComputationCache::Insert(), ComputationCache::Read(), ComputationCache::Write(), and ComputationCache::~ComputationCache().
|
private |
Definition at line 658 of file nnet-optimize-utils.h.
Referenced by ComputationCache::Insert().