Skip to content

Use non-fatal input checks for view operator #9264

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

Merged
merged 5 commits into from
Mar 15, 2025

Conversation

zhenyan-zhang-meta
Copy link
Contributor

@zhenyan-zhang-meta zhenyan-zhang-meta commented Mar 14, 2025

Summary

Fixes #9130

Use non-fatal input checks for view operator, just like https://github.com/pytorch/executorch/pull/2115/files, since there are existing cases that an internal app crashed due to a check failure.

Test is updated as well for RegisterPrimOpsTest.

Test plan

Pass updated test:

mkdir cmake-out && cd cmake-out && cmake -DEXECUTORCH_BUILD_TESTS=ON .. && cmake --build . --target kernels_prim_ops_test -j9 && ctest -R kernels_prim_ops_test

Pass existing CI/CD.

cc @GregoryComer

Copy link

pytorch-bot bot commented Mar 14, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/9264

Note: Links to docs will display an error until the docs builds have been completed.

❌ 2 New Failures, 1 Unrelated Failure

As of commit df7b286 with merge base 2bee76e (image):

NEW FAILURES - The following jobs have failed:

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot
Copy link
Contributor

Hi @zhenyan-zhang-meta!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@zhenyan-zhang-meta
Copy link
Contributor Author

@pytorchbot label "topic: not user facing"

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 14, 2025
@@ -72,28 +72,38 @@ void et_view(KernelRuntimeContext& context, EValue** stack) {
auto size = (*stack[1]).toIntList();
auto out = (*stack[2]).toTensor();

ET_CHECK(tensors_have_same_dtype(self, out));
ET_KERNEL_CHECK(
context, tensors_have_same_dtype(self, out), InvalidArgument, );
Copy link
Contributor

@Gasoonjia Gasoonjia Mar 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plz remove the extra , on the end of function; same as below

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commas has to be there since it needs an extra, though empty, param passed in for retval (return value).

Similar commas can be seen in main branch:

ET_KERNEL_CHECK(
ctx,
torch::executor::native::utils::extract_scalar(alpha, &alpha_val),
InvalidArgument, );

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah you're right i forgot that. Thanks for noticing!

internal::set_tensor_data(
out,
/*buffer=*/self.mutable_data_ptr(),
/*buffer_size=*/out.nbytes()) == Error::Ok,
InvalidArgument,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@manuelcandales know better, but I'm thinking we should use Internal here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated as suggested.

Copy link
Contributor

@swolchok swolchok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shipit (when tests are green)

@mergennachin mergennachin self-requested a review March 14, 2025 18:40
@mergennachin
Copy link
Contributor

Hi, @zhenyan-zhang-meta
Can you add a corresponding test to exercise the code?

@zhenyan-zhang-meta
Copy link
Contributor Author

Hi, @zhenyan-zhang-meta Can you add a corresponding test to exercise the code?

Sure, actually I am exploring how to run the relevant tests locally and some of them needs to be updated based on the failed signals.

@zhenyan-zhang-meta
Copy link
Contributor Author

@mergennachin The tests are updated to reflecting the changes.

Also cc @Gasoonjia @swolchok @manuelcandales @GregoryComer if need another look on tests before I ship.

@zhenyan-zhang-meta
Copy link
Contributor Author

I think the current 3 failing checks left are not relevant to the changes I made.

Copy link
Member

@GregoryComer GregoryComer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks for taking this!

@GregoryComer GregoryComer merged commit 157bf91 into pytorch:main Mar 15, 2025
77 of 80 checks passed
@zhenyan-zhang-meta zhenyan-zhang-meta deleted the issue/9130 branch March 17, 2025 02:52
DannyYuyang-quic pushed a commit to CodeLinaro/executorch that referenced this pull request Apr 2, 2025
### Summary
Fixes pytorch#9130

Use non-fatal input checks for view operator, just like
https://github.com/pytorch/executorch/pull/2115/files, since there are
existing cases that an internal app crashed due to a check failure.

Test is updated as well for `RegisterPrimOpsTest`.

### Test plan
Pass updated test:
```
mkdir cmake-out && cd cmake-out && cmake -DEXECUTORCH_BUILD_TESTS=ON .. && cmake --build . --target kernels_prim_ops_test -j9 && ctest -R kernels_prim_ops_test
```

Pass existing CI/CD.

cc @GregoryComer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. topic: not user facing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

View op asserts should use non-fatal input checks
6 participants