Support for saving exceptions in async CPU ops (#12904)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/12904
Enabling support for saving exceptions in async parts of CPU ops via
event().SaveException(). The error contract for CPU ops becomes:
- return false in sync part -> net->Run() returns false
- throw in sync part -> net->Run() rethrows the same exception
- SetFinished("error msg") in async part -> net->Run() returns false
- event().SetFinishedWithException() in async part -> net->Run() rethrows the same
exception
Reviewed By: andrewwdye
Differential Revision: D10479130
fbshipit-source-id: 850ee9cbf83b04dd24b25eba359439b0cf7853c0