-
Notifications
You must be signed in to change notification settings - Fork 683
Prim ops replace abort with error code #11985
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
Prim ops replace abort with error code #11985
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/11985
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ✅ No FailuresAs of commit bd272f6 with merge base 9c9f665 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
@pytorchbot label "release notes: none" |
ET_CHECK_MSG(false, "%zu, %zu", (size_t)a.tag, (size_t)b.tag); \ | ||
#define __ET_PRIM_OP_ERROR_IMPL(a, b, context) \ | ||
else { \ | ||
ET_KERNEL_CHECK(context, false, InvalidType, /* void */); \ |
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.
Could we use ET_KERNEL_CHECK_MSG
to keep the format string/error message?
e.g.
ET_KERNEL_CHECK_MSG(context, false, InvalidType, "%zu, %zu", (size_t)a.tag, (size_t)b.tag);
// Try to negate a tensor, which should cause a runtime error. | ||
ET_EXPECT_DEATH(getOpsFn("executorch_prim::neg.Scalar")(context_, stack), ""); | ||
ET_EXPECT_KERNEL_FAILURE( | ||
context_, |
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.
Linter failure here - can you try run lintrunner -a
?
See: https://github.com/pytorch/executorch/blob/main/CONTRIBUTING.md#lintrunner
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.
Looks good, thanks for adding this!
Summary
We want to minimize the scenarios where ET fails fatally. If we need to check a precondition inside a kernel rather then calling ET_CHECK which internally dispatches to ABORT we should call ET_KERNEL_CHECK which sets an error state and returns.
Test plan
Replaced TestNegScalarWithTensorDies with TestNegScalarWithTensorFails. Before, it would expect an abort when negating a tensor. The new test expects a failure state instead.
The test can be run with
test/run_oss_cpp_tests.sh