pytorch
310ebb45 - Fix race condition in Function::optimized_graph(). (#27012)

Commit
6 years ago
Fix race condition in Function::optimized_graph(). (#27012) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/27012 The current logic is buggy, and will fail in the following situation: Thread A: check optimized_graph_, it is empty. Thread A: claim the mutex in order to initialize optimized_graph_. Thread A: copy graph_ into optimized_graph_. Thread A: start running optimizations on optimized_graph_. Thread B: check optimized_graph_, it is not empty. Thread B: start using optimized_graph_. BUG: Thread B is using the graph while it's still being mutated by Thread A. Test Plan: Imported from OSS Differential Revision: D17649149 Pulled By: ZolotukhinM fbshipit-source-id: ab82a4e76003b88733d219ecd47a42d38be2269c
Author
Mikhail Zolotukhin
Parents
Loading