[webnn] Add float16 tests for WebNN concat op#42420
Merged
Honry merged 2 commits intoweb-platform-tests:masterfrom Nov 28, 2023
Merged
[webnn] Add float16 tests for WebNN concat op#42420Honry merged 2 commits intoweb-platform-tests:masterfrom
Honry merged 2 commits intoweb-platform-tests:masterfrom
Conversation
fdwr
reviewed
Oct 12, 2023
webnn/resources/utils.js
Outdated
|
|
||
| /* This method is faster than the OpenEXR implementation (very often | ||
| * used, eg. in Ogre), with the additional benefit of rounding, inspired | ||
| * by James Tursa?s half-precision code. */ |
fdwr
reviewed
Oct 12, 2023
webnn/resources/utils.js
Outdated
| const getTypedArrayData = (type, data) => { | ||
| let outData; | ||
| if (type === 'float16') { | ||
| // workaround to convert Float16 to Unit16 |
fdwr
reviewed
Nov 16, 2023
| expectedBitwise = toHalf(expected[i]); | ||
| } | ||
| distance = actualBitwise - expectedBitwise; | ||
| distance = distance >= 0 ? distance : -distance; |
There was a problem hiding this comment.
Isn't this just distance = Math.abs(distance)?
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I'm still working on implement scripts to generate test data & baseline data for float16 tests based on previous test data & baseline data of float32 precision.
Here I firstly submit this PR to show the overview of testing float16 precision.
These new added float16 tests in webnn/resources/test_data/concat.json use the same input data of float64 precision as ones used for testing float32 precision before, and such expected baseline data of float16 precision.
I'm struggled on readability like Solution-1 which is usingwith this PR and simple like Solution-2.
Solution 1 - positive: do not need modify more current test framework / negative: exist many duplicated test data code
{ "name": "concat two float32 1D tensors of same shape along axis 0", "inputs": [ { "name": "input1", "shape": [12], "data": [ -0.39444134019222243, ... ... -0.6731740531810844 ], "type": "float32" }, { "name": "input2", "shape": [12], "data": [ 0.4918989118791477, ... ... 0.1211843166661235 ], "type": "float32" } ], "axis": 0, "expected": { "name": "output", "shape": [24], "data": [ -0.3944413363933563, ... ... 0.1211843192577362 ], "type": "float32" } }, { "name": "concat two float16 1D tensors of same shape along axis 0", "inputs": [ { "name": "input1", "shape": [12], "data": [ -0.39444134019222243, ... ... -0.6731740531810844 ], "type": "float16" }, { "name": "input2", "shape": [12], "data": [ 0.4918989118791477, ... ... 0.1211843166661235 ], "type": "float16" } ], "axis": 0, "expected": { "name": "output", "shape": [24], "data": [ -0.39453125, ... .... 0.12115478515625 ], "type": "float16" } },Solution 2 - positive: simple, no duplicated test data code / negative: need modify more to support this updated struct, for examples, need iterate precision keys list of "expected" dictionary to test float32 and float16 precisions, according to precision key to prepare relative TypedArray data for input/constant operands and output operand(s), generate each test name with precision word for them to show clearly on UI, etc.,
{ "name": "concat two 1D tensors of same shape along axis 0", "inputs": [ { "name": "input1", "shape": [12], "data": [ -0.39444134019222243, ... ... -0.6731740531810844 ], "type": "float64" }, { "name": "input2", "shape": [12], "data": [ 0.4918989118791477, ... ... 0.1211843166661235 ], "type": "float64" } ], "axis": 0, "expected": { "name": "output", "shape": [24], "data": { "float32": [ // baseline for test float32 precision -0.3944413363933563, ... ... 0.1211843192577362 ], "float16": [ // baseline for test float16 precision -0.39453125, ... .... 0.12115478515625 ] } } },@fdwr PTAL, and any suggestions, thanks.