| 19 | namespace gpu { |
| 20 | |
| 21 | bool MutexedGraphExecCache::AddToCache(BufferAllocations::KeyType key, |
| 22 | void* gpu_exec_graph) { |
| 23 | tensorflow::mutex_lock lock(exec_graph_cache_mu_); |
| 24 | bool has_max_cache_size_reached = false; |
| 25 | gpu_exec_graphs_.push_front(gpu_exec_graph); |
| 26 | if (gpu_exec_graphs_.size() > cache_size_.load()) { |
| 27 | has_max_cache_size_reached = true; |
| 28 | auto* exec_graph = |
| 29 | reinterpret_cast<stream_executor::gpu::GpuGraphExecHandle*>( |
| 30 | &gpu_exec_graphs_.back()); |
| 31 | using stream_executor::gpu::GpuDriver; |
| 32 | GpuDriver::DestroyExecutableGraph(gpu_context_, exec_graph); |
| 33 | gpu_exec_graphs_.pop_back(); |
| 34 | } |
| 35 | gpu_key_to_exec_graphs_map_[key] = gpu_exec_graphs_.begin(); |
| 36 | return has_max_cache_size_reached; |
| 37 | } |
| 38 | |
| 39 | void* MutexedGraphExecCache::GetExecGraph(BufferAllocations::KeyType key) { |
| 40 | tensorflow::mutex_lock lock(exec_graph_cache_mu_); |
no test coverage detected