Skip to content

Commit

Permalink
Bug 1914677 [wpt PR 47768] - webnn: support all axes for resample2d, …
Browse files Browse the repository at this point in the history
…a=testonly

Automatic update from web-platform-tests
webnn: support all axes for resample2d

Allow arbitrary axes as long as they are valid dimensions for
resample2d instead of restricting them to point to spacial dimensions.
Apply transposes for input & output when the axes is not supported by
the backend.

See spec pr: webmachinelearning/webnn#752

Change-Id: I5112abf1f43328d901000a4cff8468bd9bfe2dfb
Cq-Include-Trybots: luci.chromium.try​:win11-blink-rel,mac14.arm64-blink-rel,mac14-blink-rel, linux-blink-rel
Bug: 329658123, 334914468
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5798093
Commit-Queue: Phillis Tang <[email protected]>
Reviewed-by: ningxin hu <[email protected]>
Reviewed-by: Alex Gough <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1346174}

--

wpt-commits: 536c5951f70d77c0be08552be6bd5bbc2a082e5c
wpt-pr: 47768
  • Loading branch information
philloooo authored and moz-wptsync-bot committed Aug 24, 2024
1 parent e283c6b commit 32c0bc2
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,44 @@ const resample2dTests = [
}
}
},
{
'name':
'resample2d(upsample) float32 4D tensor explicit options.axes=[3, 2]',
'graph': {
'inputs': {
'resample2dInput': {
'data': [
59.92947006225586, 41.98918914794922, 66.39534759521484,
90.7006607055664, 86.95105743408203, 79.10005187988281
],
'descriptor': {'dimensions': [1, 1, 2, 3], 'dataType': 'float32'}
}
},
'operators': [{
'name': 'resample2d',
'arguments': [
{'input': 'resample2dInput'},
{'options': {'sizes': [6, 4], 'axes': [3, 2]}}
],
'outputs': 'resample2dOutput'
}],
'expectedOutputs': {
'resample2dOutput': {
'data': [
59.92947006225586, 59.92947006225586, 41.98918914794922,
41.98918914794922, 66.39534759521484, 66.39534759521484,
59.92947006225586, 59.92947006225586, 41.98918914794922,
41.98918914794922, 66.39534759521484, 66.39534759521484,
90.7006607055664, 90.7006607055664, 86.95105743408203,
86.95105743408203, 79.10005187988281, 79.10005187988281,
90.7006607055664, 90.7006607055664, 86.95105743408203,
86.95105743408203, 79.10005187988281, 79.10005187988281
],
'descriptor': {'dimensions': [1, 1, 4, 6], 'dataType': 'float32'}
}
}
}
},
{
'name':
'resample2d(upsample) float32 4D tensor explicit options.mode=\'nearest-neighbor\'',
Expand Down Expand Up @@ -429,6 +467,80 @@ const resample2dTests = [
}
}
}
},
{
'name': 'resample2d(upsample) float32 4D tensor options.axes=[0, 1]',
'graph': {
'inputs': {
'resample2dInput': {
'data': [
59.92947006225586, 90.7006607055664, 41.98918914794922,
86.95105743408203, 66.39534759521484, 79.10005187988281
],
'descriptor': {'dimensions': [3, 2, 1, 1], 'dataType': 'float32'}
}
},
'operators': [{
'name': 'resample2d',
'arguments': [
{'input': 'resample2dInput'},
{'options': {'sizes': [6, 4], 'axes': [0, 1]}}
],
'outputs': 'resample2dOutput'
}],
'expectedOutputs': {
'resample2dOutput': {
'data': [
59.92947006225586, 59.92947006225586, 90.7006607055664,
90.7006607055664, 59.92947006225586, 59.92947006225586,
90.7006607055664, 90.7006607055664, 41.98918914794922,
41.98918914794922, 86.95105743408203, 86.95105743408203,
41.98918914794922, 41.98918914794922, 86.95105743408203,
86.95105743408203, 66.39534759521484, 66.39534759521484,
79.10005187988281, 79.10005187988281, 66.39534759521484,
66.39534759521484, 79.10005187988281, 79.10005187988281
],
'descriptor': {'dimensions': [6, 4, 1, 1], 'dataType': 'float32'}
}
}
}
},
{
'name': 'resample2d(upsample) float32 4D tensor options.axes=[1, 0]',
'graph': {
'inputs': {
'resample2dInput': {
'data': [
59.92947006225586, 90.7006607055664, 41.98918914794922,
86.95105743408203, 66.39534759521484, 79.10005187988281
],
'descriptor': {'dimensions': [3, 2, 1, 1], 'dataType': 'float32'}
}
},
'operators': [{
'name': 'resample2d',
'arguments': [
{'input': 'resample2dInput'},
{'options': {'sizes': [4, 6], 'axes': [1, 0]}}
],
'outputs': 'resample2dOutput'
}],
'expectedOutputs': {
'resample2dOutput': {
'data': [
59.92947006225586, 59.92947006225586, 90.7006607055664,
90.7006607055664, 59.92947006225586, 59.92947006225586,
90.7006607055664, 90.7006607055664, 41.98918914794922,
41.98918914794922, 86.95105743408203, 86.95105743408203,
41.98918914794922, 41.98918914794922, 86.95105743408203,
86.95105743408203, 66.39534759521484, 66.39534759521484,
79.10005187988281, 79.10005187988281, 66.39534759521484,
66.39534759521484, 79.10005187988281, 79.10005187988281
],
'descriptor': {'dimensions': [6, 4, 1, 1], 'dataType': 'float32'}
}
}
}
}
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ const tests = [
options: {scales: [2.0, 2.0], sizes: [3, 6]},
output: {dataType: 'float32', dimensions: [1, 1, 3, 6]},
},
{
name:
'[resample2d] Test building resample2d with non consecutive axes=[0,2]',
input: {dataType: 'float32', dimensions: [1, 1, 2, 4]},
options: {
axes: [0, 2],
label: label,
},
output: {dataType: 'float32', dimensions: [1, 1, 2, 4]},
},
{
name:
'[resample2d] Throw if the dataType of input is not float32 or float16',
Expand Down Expand Up @@ -177,15 +187,6 @@ const tests = [
label: label,
},
},
{
// The valid values in the axes sequence are [0, 1], [1, 2] or [2, 3]
name: '[resample2d] Throw if the values of axes are inconsecutive',
input: {dataType: 'float32', dimensions: [1, 1, 2, 4]},
options: {
axes: [0, 2],
label: label,
},
},
{
name: '[resample2d] Throw if the values of axes are same',
input: {dataType: 'float32', dimensions: [1, 1, 2, 4]},
Expand Down

0 comments on commit 32c0bc2

Please sign in to comment.