-
Notifications
You must be signed in to change notification settings - Fork 526
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. |
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.
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.