-
Notifications
You must be signed in to change notification settings - Fork 8
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
Implement scatterElements #105
Implement scatterElements #105
Conversation
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.
Thanks Bruce. Some small comments, and then LGTM.
@fdwr I've addressed your comments in the new commit, please take another look, 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.
LGTM with a comment
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.
Thanks @huningxin!
I've addressed your comments, please take another review in new commit.
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.
👍 Thanks Bruce.
let indicesValue = indices.getValueByIndex(indicesIndex); | ||
indicesValue = indicesValue < 0 ? indicesValue + input.shape[axis] : indicesValue; | ||
const outputLocation = | ||
[...indicesLocation.slice(0, axis), indicesValue, ...indicesLocation .slice(axis + 1)]; |
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.
Should we restrict indices sizes are less than or equal to input sizes along every dimensions except axis
? (indices.shape[i] <= input.shape[i] if i != axis
). Otherwise, indicesLocation.slice()
would contain invalid index value that is greater than output size.
BTW, DirectML requires "IndicesTensor.Sizes must match InputTensor.Sizes for every dimension except Axis." https://learn.microsoft.com/en-us/windows/win32/api/directml/ns-directml-dml_scatter_operator_desc. The current Chromium prototype follows this rule: https://chromium-review.googlesource.com/c/chromium/src/+/5921136/9/services/webnn/public/cpp/graph_validation_utils.cc#2563
CoreML only requires rank(indices)== rank(input)
: https://apple.github.io/coremltools/source/coremltools.converters.mil.mil.ops.defs.html#coremltools.converters.mil.mil.ops.defs.iOS15.scatter_gather.scatter_along_axis
@huningxin @fdwr @shiyi9801 PTAL, thanks.