Replace throw std::runtime_error with torch_check in torch/csrc/distributed (#59683)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/59683

Replaces usages of throw std::runtime_error("foo") with the better
torch_check(false, "foo") which allows C++ stacktraces to show up when
TORCH_SHOW_CPP_STACKTRACES=1. This will hopefully provide much better debugging
information when debugging crashes/flaky tests.
ghstack-source-id: 131167210

Test Plan: CI

Reviewed By: cbalioglu

Differential Revision: D28981327

fbshipit-source-id: 677f569e28600263cab18759eb1b282e0391aa7b
This commit is contained in:
Rohan Varma
2021-06-11 11:14:26 -07:00
committed by Facebook GitHub Bot
parent 9cdbddb3f7
commit d433a55c94
9 changed files with 18 additions and 16 deletions

View File

@ -318,7 +318,7 @@ void PyRRef::backwardOwnerRRef(
try {
value = torch::jit::toIValue(obj, c10::TensorType::get());
} catch (py::cast_error& e) {
throw std::runtime_error("RRef should contain a tensor for .backward()");
TORCH_CHECK(false, "RRef should contain a tensor for .backward()");
}
}