-
Notifications
You must be signed in to change notification settings - Fork 46
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
gather(): Address indices validation and other algorithm nits #642
gather(): Address indices validation and other algorithm nits #642
Conversation
* webmachinelearning#486 points out that indices can't be validated at build-time, and clamping behavior with an implementation note is given instead. * Fix a typo in the steps. * Replace several map-like iterations over lists with list iteration. Fixes webmachinelearning#486
I noticed the other glitches in gather(), then went looking for open bugs and tackled #486 at the same time. Wheeee! |
@a-sully can you take a first look? |
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.
LGTM 👍
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.
LGTM with a comment, thanks!
Co-authored-by: Ningxin Hu <ningxin.hu@intel.com>
Do we want to tweak this at all to also tackle #484 or leave that for another PR? |
Ah good question... To specify support for negative indices in WebNN, we need to assume it's reasonable that every WebNN backend (that doesn't already support negative indices) will be able to transform these values at runtime. For example, the simplest way for our WebNN implementation to polyfill is by inserting
This assumes that an This becomes easier if we say that WebNN must support control flow ops #559 There may be some other more complicated way to transform these values, too... @huningxin any thoughts? |
Thanks, @huningxin!
Seems reasonable. @inexorabletash shall we fold that into this PR (a nonnormative note to implementers, perhaps?) and close #484? |
I added a sentence to the note in 446bc77 - I kept it short, and didn't provide the decomposition. WDYT? |
LGTM, especially since there are multiple reasonable decompositions |
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.
LGTM!
@fdwr can you do a final review and merge if it looks good to you? Thanks! |
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.
Approved with two suggestions. Thanks for adding Josh.
Yep, that looks right. An alternative would be...
...which is slightly shorter (one less
Btw, the former name of |
Co-authored-by: Dwayne Robinson <dwayner@microsoft.com>
Co-authored-by: Dwayne Robinson <dwayner@microsoft.com>
…fix-gather-validation
Thanks @fdwr - I incorporated your change then fixed one grammar glitch. |
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.
👍 Arigatou Josh.
SHA: d846723 Reason: push, by fdwr Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Add "implementation consideration" about how out-of-bound indices of Gather/Scatter should be handled #486 points out that indices can't be validated at build-time, and clamping behavior with an implementation note is given instead.
Fix a typo in the steps.
Replace several map-like iterations over lists with list iteration.
Should Gather's indices data type be integers and support negative value? #484 discusses support for negative indices. Added a note that if the underlying platform doesn't support them, the implementation can "polyfill" this with some additional logic.
Fixes #486
Fixes #484
Preview | Diff