Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit acdb292

Browse files
fujunweimoz-wptsync-bot
authored andcommitted
Bug 1934612 [wpt PR 49466] - webnn: Support scatterElements in tflite converter, a=testonly
Automatic update from web-platform-tests webnn: Support scatterElements in tflite converter There is no TFLite operator to map directly WebNN scatterElements, but it can be supported with tfl.scatter_nd as the test cases[1] and the doc[2] described. The indices also need to be converted like gatherElements. The update operand must be reshaped to one dimension[3]. [1] https://source.chromium.org/chromium/chromium/src/+/main:third_party/tflite/src/tensorflow/lite/kernels/scatter_nd_test.cc;l=73 [2] https://www.tensorflow.org/guide/tensor_slicing#insert_data_into_tensors [3] https://source.chromium.org/chromium/chromium/src/+/main:third_party/tflite/src/tensorflow/lite/kernels/scatter_nd.cc;l=64?q=scatter_nd.cc&ss=chromium%2Fchromium%2Fsrc Bug: 40206287 Change-Id: If0461ceb6c4cb8bcee6ff2b59443851a5cdc7de5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6048693 Reviewed-by: Phillis Tang <[email protected]> Commit-Queue: Phillis Tang <[email protected]> Reviewed-by: ningxin hu <[email protected]> Cr-Commit-Position: refs/heads/main@{#1391759} -- wpt-commits: e9d8459f9c413260ace922b865157075bc12b465 wpt-pr: 49466
1 parent 658332c commit acdb292

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

testing/web-platform/tests/webnn/conformance_tests/scatterElements.https.any.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,40 @@ const scatterElementsTests = [
4646
}
4747
}
4848
},
49+
{
50+
'name': 'Scatter elements along axis 0 and constant indices',
51+
'graph': {
52+
'inputs': {
53+
'input': {
54+
'data': [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
55+
'descriptor': {shape: [3, 3], dataType: 'float32'}
56+
},
57+
'indices': {
58+
'data': [1, 0, 2, 0, 2, 1],
59+
'descriptor': {shape: [2, 3], dataType: 'int32'},
60+
'constant': true
61+
},
62+
'updates': {
63+
'data': [1.0, 1.1, 1.2, 2.0, 2.1, 2.2],
64+
'descriptor': {shape: [2, 3], dataType: 'float32'}
65+
}
66+
},
67+
'operators': [{
68+
'name': 'scatterElements',
69+
'arguments': [
70+
{'input': 'input'}, {'indices': 'indices'}, {'updates': 'updates'},
71+
{'options': {'axis': 0}}
72+
],
73+
'outputs': 'output'
74+
}],
75+
'expectedOutputs': {
76+
'output': {
77+
'data': [2.0, 1.1, 0.0, 1.0, 0.0, 2.2, 0.0, 2.1, 1.2],
78+
'descriptor': {shape: [3, 3], dataType: 'float32'}
79+
}
80+
}
81+
}
82+
},
4983
{
5084
'name': 'Scatter elements along axis 1',
5185
'graph': {
@@ -78,6 +112,40 @@ const scatterElementsTests = [
78112
}
79113
}
80114
}
115+
},
116+
{
117+
'name': 'Scatter elements along axis 1 and constant indices',
118+
'graph': {
119+
'inputs': {
120+
'input': {
121+
'data': [1.0, 2.0, 3.0, 4.0, 5.0],
122+
'descriptor': {shape: [1, 5], dataType: 'float32'}
123+
},
124+
'indices': {
125+
'data': [1, 3],
126+
'descriptor': {shape: [1, 2], dataType: 'int32'},
127+
'constant': true
128+
},
129+
'updates': {
130+
'data': [1.1, 2.1],
131+
'descriptor': {shape: [1, 2], dataType: 'float32'}
132+
}
133+
},
134+
'operators': [{
135+
'name': 'scatterElements',
136+
'arguments': [
137+
{'input': 'input'}, {'indices': 'indices'}, {'updates': 'updates'},
138+
{'options': {'axis': 1}}
139+
],
140+
'outputs': 'output'
141+
}],
142+
'expectedOutputs': {
143+
'output': {
144+
'data': [1.0, 1.1, 3.0, 2.1, 5.0],
145+
'descriptor': {shape: [1, 5], dataType: 'float32'}
146+
}
147+
}
148+
}
81149
}
82150
];
83151

0 commit comments

Comments
 (0)