| 37 | } |
| 38 | |
| 39 | void* MutexedGraphExecCache::GetExecGraph(BufferAllocations::KeyType key) { |
| 40 | tensorflow::mutex_lock lock(exec_graph_cache_mu_); |
| 41 | if (gpu_key_to_exec_graphs_map_.find(key) != |
| 42 | gpu_key_to_exec_graphs_map_.end()) { |
| 43 | auto it = std::find(gpu_exec_graphs_.begin(), gpu_exec_graphs_.end(), |
| 44 | *(gpu_key_to_exec_graphs_map_[key])); |
| 45 | if (it == gpu_exec_graphs_.end()) { |
| 46 | gpu_key_to_exec_graphs_map_.erase(key); |
| 47 | return nullptr; |
| 48 | } |
| 49 | auto gpu_exec_graph = *(gpu_key_to_exec_graphs_map_[key]); |
| 50 | gpu_exec_graphs_.remove(gpu_exec_graph); |
| 51 | gpu_exec_graphs_.push_front(gpu_exec_graph); |
| 52 | gpu_key_to_exec_graphs_map_[key] = gpu_exec_graphs_.begin(); |
| 53 | return gpu_exec_graph; |
| 54 | } |
| 55 | return nullptr; |
| 56 | } |
| 57 | |
| 58 | void MutexedGraphExecCache::SetCacheSize(int64 cache_size) { |
| 59 | cache_size_.store(cache_size); |
no test coverage detected