| 152 | } |
| 153 | |
| 154 | void EagerContext::ClearCaches() { |
| 155 | { |
| 156 | mutex_lock ml(executor_map_mu_); |
| 157 | for (auto& entry : thread_local_executor_) { |
| 158 | entry.second->WaitForAllPendingNodes().IgnoreError(); |
| 159 | } |
| 160 | } |
| 161 | { |
| 162 | // The executor stores pointers to kernels, so we need to make sure that no |
| 163 | // async eager ops are still executing. We lock the cache during this time |
| 164 | // as well. |
| 165 | mutex_lock ml(cache_mu_); |
| 166 | default_executor_.WaitForAllPendingNodes().IgnoreError(); |
| 167 | kernel_cache_.clear(); |
| 168 | for (auto& entry : registered_functions_) { |
| 169 | entry.second->cached_kernel_keys->clear(); |
| 170 | } |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | void EagerContext::SetThreadLocalDevicePlacementPolicy( |
| 175 | ContextDevicePlacementPolicy policy) { |
no test coverage detected