-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Replace std::runtime_error
with TORCH_CHECK
#159344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/159344
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 07c7d51 with merge base 3a56237 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
@pytorchbot label "topic: not user facing" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, but I think it's better to replace TORCH_CHECK(false
with the unsatisfied condition (if possible), which can remove more if branches.
cbe9e2b
to
38f8f42
Compare
38f8f42
to
9005b6d
Compare
torch/csrc/DataLoader.cpp
Outdated
@@ -149,7 +149,7 @@ static PyObject* THPModule_errorIfAnyWorkerFails( | |||
// This is necessary. Otherwise, the runtime error will kill the other | |||
// workers, and trigger this again. | |||
pid_set.clear(); | |||
throw std::runtime_error(oss.str()); | |||
TORCH_CHECK(false, oss.str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slight nit, would be more efficient using fmtlib. Since this string isn't used a lot in the normal passing case, you could also just use c10::LazyStr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed, but not find c10::LazyStr
, is there an example of using it? That it would be helpful. Thanks! :D
@@ -187,15 +188,15 @@ inline std::string_view printEnum(const ArgumentKind& e) { | |||
case ArgumentKind::POSITIONAL: return "POSITIONAL"; | |||
case ArgumentKind::KEYWORD: return "KEYWORD"; | |||
default: | |||
throw std::runtime_error("Unknown enum value"); | |||
TORCH_CHECK(false, "Unknown enum value"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file isn't generated by some other file or schema right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a generated file, the content is tracked by git. Thanks!
9005b6d
to
07c7d51
Compare
Fixes part of #148114