-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
[webnn] Add float32 tests for WebNN resample2d op #41811
[webnn] Add float32 tests for WebNN resample2d op #41811
Conversation
Both are reasonable and not really "wrong" - we just have to pick one. The only truly wrong ones are those libraries that always floor pixels (broken libraries) which result in shifted images, but I believe most image resampling API's round input coordinate on halves toward negative infinity, and ONNX's Resize defaults This is easy to control via |
@fdwr May we first to land PASS tests and create another pr of these failure 3 tests on "nearest-neighbor" mode which would help for resolving https://issues.chromium.org/issues/327337526, thanks. |
Yeah, go ahead 👍. |
9b9a710
to
1750e02
Compare
* Get ULP tolerance of resample2d operations. | ||
* @param {Object} resources - Resources used for building a graph | ||
* @param {String} operationName - An operation name | ||
* @returns {Number} A tolerance number |
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.
* @returns {Number} A tolerance number | |
* @returns {Number} A tolerance number in ULP |
(to clarify it's not absolute difference, because 84 would be a huuuge tolerance 😉)
tolerance = 84; | ||
} else if (precisionType === 'float16') { | ||
tolerance = 10; | ||
} |
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.
else {
tolerance = 1;
}
tolerance
remains uninitialized in the else
code path path. For integer types (e.g. uint8
), even if many backends don't currently support them, a reasonable default for linear is 1 ULP (due to rounding up or down).
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.
Updated. 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.
Note my comment above too (in case you missed it), but approved either way.
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.
@fdwr Please take another look, thanks.
tolerance = 84; | ||
} else if (precisionType === 'float16') { | ||
tolerance = 10; | ||
} |
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.
Updated. 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, thanks!
…#41811) * [webnn] Add float32 tests for WebNN resample2d op * [webnn] Removed some downsample tests for resample2d * [webnn] Rebased code * [webnn] Add default ULP tolerance for resample2d on linear mode.
@fdwr This PR is to add 13 float32 resample2d tests. I ran these tests by internal Chromium build using WebNN DirectML backend, got 10 PASS and 3 FAIL.
These 3 FAIL tests are all for resample(down sampling) on "nearest-neighbor" mode with below 4D input of shape [1, 1, 4, 6]
by
options.sizes = [2, 3]
oroptions.scales = [0.5, 0.5]
,output is of shape [1, 1, 2, 3] and its actual value as below
while our expected data were generated by https://github.com/webmachinelearning/webnn-baseline/blob/main/src/resample2d.js with same input data and options:
I'm not sure which is wrong on
Do you have any ideas? Thanks.