-
Notifications
You must be signed in to change notification settings - Fork 48
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
Support rounding type of pool2d operations #208
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
See my comment on #198. Rounding mode for tensor size calculation should be done above WebNN, similar to how it is done in ONNX Runtime above DirectML.
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.
@wchao1115 , thanks for your comments on #198.
However a caller may not calculate the tensor shape and rely on WebNN to do that, e.g. the OpenCV WebNN backend mentioned in #198. The MLOperand interface of WebNN doesn't allow query the shape. So if the caller doesn't infer the shape by itself, it would be hard to calculate the output shape with a desired rounding type from the input shape, especially when the input is an intermediate operand. That's why I propose to let the callers to just configure the rounding type instead of calculating the output shape at all by themselves.
I suppose this would map ONNX
ceil_mode
well. What do you think?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.
That's a fair point. The current WebNN design does allow dynamic shape inference, which would make it somewhat easier to call the API directly (since the caller needs not worry about correctly implementing shape inference for all cases themselves), but it does come at a cost of additional work on the implementer's side, and in theory some long-term maintenance cost of the API due to the additional policy that must be implemented for such a caller.
If we want to continue to allow dynamic shape inference in the WebNN API, then adding an optional output size's rounding mode would not be out of line. In that case, I would suggest that we also add
outputSizes
so if the framework callers already calculate the output size themselves (most frameworks do), then they can just ignore the rounding mode.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.
It sounds good to me.
@wchao1115 , according to DirectML backend implementation, how does pooling ops of DirectMLX, such as
AveragePooling
, support rounding mode? It calculates the output sizes inside and doesn't allow to configure neither rounding type nor output sizes.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.
DirectMLX is just a helper library to DirectML. It doesn't add any meaningful feature to it, just literally reduces typing and makes DirectML easier to access. The library also doesn't do shape inference at runtime, only at construction time, so if the framework that uses it supports runtime shape inference, it needs to handle that before passing it down to DirectMLX. Also wanted to point out that ONNX Runtime doesn't actually use DirectMLX, but TensorFlow does.
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 @wchao1115 .
outputSizes
is added into the latest commit. Please take another look.