-
Notifications
You must be signed in to change notification settings - Fork 536
Add optimized op_where #8866
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
Add optimized op_where #8866
Conversation
Stack from ghstack (oldest at bottom): |
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/8866
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New FailureAs of commit e52508d with merge base cca6917 ( NEW FAILURE - The following job has failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
ghstack-comment-id: 2691805026 ghstack-source-id: ebe8bee4e3ca4184e91058bd7033e69e130644da ghstack-comment-id: 2691808920 Pull Request resolved: #8866
ghstack-comment-id: 2691805026 ghstack-source-id: aaf66178b1902763ebaaaa2f0b3a312505722ea8 ghstack-comment-id: 2691808920 Pull Request resolved: #8866
data_out[out_index] = | ||
data_cond[cond_index] ? data_a[a_index] : data_b[b_index]; |
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.
Love how clean it reads :)
Couple of high level comments,
- Not too familiar with how people use this op i.e. any common case we see often in the wild, but are there any short-circuits we can do to avoid coming here?
- Similarly, depending on the condition, if we know we are biased towards A vs. B, we can first copy A to the result and then go through data_cond and pick B.
- Lastly, I am assuming we want to do SIMD later, if we do then we can use predicates, that should make it less "branchy". It may not help much with load/stores though.
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.
if we know we are biased towards A vs. B
we can't possibly know this in general.
SIMD later
not currently on my agenda, but I may have to come back.
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 to me.
ghstack-comment-id: 2691805026 ghstack-source-id: 7e5ac3a26e2728bc9e7fca1f37e0368efce5186e ghstack-comment-id: 2691808920 Pull Request resolved: #8866
ghstack-comment-id: 2691805026 ghstack-source-id: c88f9387a18951f40fffb1cc9971daafe7b82122 ghstack-comment-id: 2691808920 Pull Request resolved: #8866
ghstack-comment-id: 2691805026 ghstack-source-id: 1a0f6d2c788778fcb6fcb132f7ef452cd048e3d3 ghstack-comment-id: 2691808920 Pull Request resolved: #8866
unittest-editable failure is a known flake, so noting that we have green CI. I think this will cause -Wunused -Werror builds to fail though, so I need to fix that before merging. |
Checked, works fine, I misread my own code. |
It materializes separate kernels for the cases where the two input data tensors have the same dtype and the third one has dtype bool.
It materializes separate kernels for the cases where the two input data tensors have the same dtype and the third one has dtype bool.