gather(): Address indices validation and other algorithm nits#642
gather(): Address indices validation and other algorithm nits#642fdwr merged 9 commits intowebmachinelearning:mainfrom inexorabletash:bugfix-gather-validation
Conversation
|
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? |
huningxin
left a comment
There was a problem hiding this comment.
LGTM with a comment, thanks!
Co-authored-by: Ningxin Hu <[email protected]>
|
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 |
|
@fdwr can you do a final review and merge if it looks good to you? Thanks! |
fdwr
left a comment
There was a problem hiding this comment.
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 <[email protected]>
Co-authored-by: Dwayne Robinson <[email protected]>
…fix-gather-validation
|
Thanks @fdwr - I incorporated your change then fixed one grammar glitch. |
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