Skip to content

Commit 6f219db

Browse files
BruceDaichromium-wpt-export-bot
authored andcommitted
webnn: only use positive scale for dequantizeLinear and quantizeLinear
Due to the lack of widespread support for the current negative scale across all backends, this CL removes four tests related to negative scale and updates 16 tests to exclusively use positive scale for the dequantizeLinear and quantizeLinear operators. Bug: 457473747 Change-Id: I45e51d3736dad286d7416ab207c7d7629695af80 Cq-Include-Trybots: luci.chromium.try:win11-blink-rel, mac14.arm64-blink-rel, mac14-blink-rel, mac15.arm64-blink-rel, mac15-blink-rel, linux-blink-rel Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7181723 Auto-Submit: Dai, Feng <feng.dai@intel.com> Reviewed-by: Reilly Grant <reillyg@chromium.org> Commit-Queue: Dai, Feng <feng.dai@intel.com> Reviewed-by: Hu, Ningxin <ningxin.hu@intel.com> Cr-Commit-Position: refs/heads/main@{#1550844}
1 parent fe2342b commit 6f219db

File tree

2 files changed

+52
-216
lines changed

2 files changed

+52
-216
lines changed

webnn/conformance_tests/dequantizeLinear.https.any.js

Lines changed: 43 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -146,52 +146,6 @@ const dequantizeLinearTests = [
146146
}
147147
}
148148
},
149-
{
150-
'name':
151-
'dequantizeLinear uint8 1D tensor with negative float32 1D scale',
152-
'graph': {
153-
'inputs': {
154-
'dequantizeLinearInput': {
155-
'data': [12, 24, 35, 123],
156-
'descriptor': {shape: [4], dataType: 'uint8'},
157-
'constant': false
158-
},
159-
'dequantizeLinearScale': {
160-
'data': [
161-
9.343092918395996,
162-
0.2800687253475189,
163-
-4.617084980010986,
164-
1.1202747821807861,
165-
],
166-
'descriptor': {shape: [4], dataType: 'float32'},
167-
'constant': true
168-
},
169-
'dequantizeLinearZeroPoint': {
170-
'data': [128, 128, 128, 128],
171-
'descriptor': {shape: [4], dataType: 'uint8'},
172-
'constant': true
173-
}
174-
},
175-
'operators': [{
176-
'name': 'dequantizeLinear',
177-
'arguments': [
178-
{'input': 'dequantizeLinearInput'},
179-
{'scale': 'dequantizeLinearScale'},
180-
{'zeroPoint': 'dequantizeLinearZeroPoint'}
181-
],
182-
'outputs': 'dequantizeLinearOutput'
183-
}],
184-
'expectedOutputs': {
185-
'dequantizeLinearOutput': {
186-
'data': [
187-
-1083.798828125, -29.127147674560547, 429.388916015625,
188-
-5.601373672485352
189-
],
190-
'descriptor': {shape: [4], dataType: 'float32'}
191-
}
192-
}
193-
}
194-
},
195149
{
196150
'name':
197151
'dequantizeLinear uint8 1D tensor with float32 1D scale, implicit block_size = 2',
@@ -205,7 +159,7 @@ const dequantizeLinearTests = [
205159
'dequantizeLinearScale': {
206160
'data': [
207161
9.343092918395996,
208-
-4.617084980010986,
162+
4.617084980010986,
209163
],
210164
'descriptor': {shape: [2], dataType: 'float32'},
211165
'constant': true
@@ -228,8 +182,8 @@ const dequantizeLinearTests = [
228182
'expectedOutputs': {
229183
'dequantizeLinearOutput': {
230184
'data': [
231-
-1083.798828125, -971.681640625, 346.2813720703125,
232-
-60.0221061706543
185+
-1083.798828125, -971.681640625, -346.2813720703125,
186+
60.0221061706543
233187
],
234188
'descriptor': {shape: [4], dataType: 'float32'}
235189
}
@@ -247,7 +201,7 @@ const dequantizeLinearTests = [
247201
'constant': false
248202
},
249203
'dequantizeLinearScale': {
250-
'data': [0.2800687253475189, -4.617084980010986],
204+
'data': [0.2800687253475189, 4.617084980010986],
251205
'descriptor': {shape: [1, 1, 2, 1], dataType: 'float32'},
252206
'constant': true
253207
},
@@ -269,8 +223,8 @@ const dequantizeLinearTests = [
269223
'expectedOutputs': {
270224
'dequantizeLinearOutput': {
271225
'data': [
272-
-38.08934783935547, -3.3608245849609375, -50.787933349609375,
273-
-507.87933349609375
226+
-38.08934783935547, -3.3608245849609375, 50.787933349609375,
227+
507.87933349609375
274228
],
275229
'descriptor': {shape: [1, 1, 2, 2], dataType: 'float32'}
276230
}
@@ -292,8 +246,8 @@ const dequantizeLinearTests = [
292246
},
293247
'dequantizeLinearScale': {
294248
'data': [
295-
0.2800687253475189, -4.617084980010986, 1.2800687253475189,
296-
-3.617084980010986
249+
0.2800687253475189, 4.617084980010986, 1.2800687253475189,
250+
3.617084980010986
297251
],
298252
'descriptor': {shape: [2, 2], dataType: 'float32'},
299253
'constant': true
@@ -318,28 +272,28 @@ const dequantizeLinearTests = [
318272
'data': [
319273
-35.00859069824219,
320274
-0.2800687253475189,
321-
-92.3416976928711,
322-
-549.43310546875,
275+
92.3416976928711,
276+
549.43310546875,
323277
3.0807559490203857,
324278
6.1615118980407715,
325-
-193.91757202148438,
326-
-152.36380004882812,
279+
193.91757202148438,
280+
152.36380004882812,
327281
18.484535217285156,
328282
21.565292358398438,
329-
115.4271240234375,
330-
13.851255416870117,
283+
-115.4271240234375,
284+
-13.851255416870117,
331285
-49.92267990112305,
332286
-64.0034408569336,
333-
245.96177673339844,
334-
285.7497253417969,
287+
-245.96177673339844,
288+
-285.7497253417969,
335289
107.52577209472656,
336290
32.0017204284668,
337291
0,
338-
-39.787933349609375,
292+
39.787933349609375,
339293
65.28350830078125,
340294
79.36426544189453,
341-
-159.1517333984375,
342-
86.81004333496094
295+
159.1517333984375,
296+
-86.81004333496094
343297
],
344298
'descriptor': {shape: [6, 4], dataType: 'float32'}
345299
}
@@ -435,7 +389,7 @@ const dequantizeLinearTests = [
435389
'dequantizeLinearScale': {
436390
'data': [
437391
9.343092918395996,
438-
-4.617084980010986,
392+
4.617084980010986,
439393
],
440394
'descriptor': {shape: [1, 1, 2, 1], dataType: 'float32'},
441395
'constant': true
@@ -458,8 +412,8 @@ const dequantizeLinearTests = [
458412
'expectedOutputs': {
459413
'dequantizeLinearOutput': {
460414
'data': [
461-
-18.686185836791992, -9.343092918395996, -32.31959533691406,
462-
-55.40502166748047
415+
-18.686185836791992, -9.343092918395996, 32.31959533691406,
416+
55.40502166748047
463417
],
464418
'descriptor': {shape: [1, 1, 2, 2], dataType: 'float32'}
465419
}
@@ -479,7 +433,7 @@ const dequantizeLinearTests = [
479433
'dequantizeLinearScale': {
480434
'data': [
481435
9.343092918395996,
482-
-4.617084980010986,
436+
4.617084980010986,
483437
],
484438
'descriptor': {shape: [1, 1, 2], dataType: 'float32'},
485439
'constant': true
@@ -502,8 +456,8 @@ const dequantizeLinearTests = [
502456
'expectedOutputs': {
503457
'dequantizeLinearOutput': {
504458
'data': [
505-
-18.686185836791992, -9.343092918395996, -32.31959533691406,
506-
-55.40502166748047
459+
-18.686185836791992, -9.343092918395996, 32.31959533691406,
460+
55.40502166748047
507461
],
508462
'descriptor': {shape: [1, 1, 4], dataType: 'float32'}
509463
}
@@ -597,7 +551,7 @@ const dequantizeLinearTests = [
597551
},
598552
'dequantizeLinearScale': {
599553
'data': [
600-
1.1202747821807861, -4.617084980010986, 6.2405495643615723,
554+
1.1202747821807861, 4.617084980010986, 6.2405495643615723,
601555
3.841923713684082
602556
],
603557
'descriptor': {shape: [1, 1, 2, 2], dataType: 'float32'},
@@ -621,7 +575,7 @@ const dequantizeLinearTests = [
621575
'expectedOutputs': {
622576
'dequantizeLinearOutput': {
623577
'data': [
624-
-2.2405495643615723, -9.234169960021973, -6.240549564361572,
578+
-2.2405495643615723, 9.234169960021973, -6.240549564361572,
625579
-11.525771141052246
626580
],
627581
'descriptor': {shape: [1, 1, 2, 2], dataType: 'float32'}
@@ -893,44 +847,6 @@ const dequantizeLinearTests = [
893847
}
894848
}
895849
},
896-
{
897-
'name':
898-
'dequantizeLinear uint8 1D tensor with negative float16 1D scale',
899-
'graph': {
900-
'inputs': {
901-
'dequantizeLinearInput': {
902-
'data': [12, 24, 35, 123],
903-
'descriptor': {'shape': [4], 'dataType': 'uint8'},
904-
'constant': false
905-
},
906-
'dequantizeLinearScale': {
907-
'data': [9.34375, 0.280029296875, -4.6171875, 1.1201171875],
908-
'descriptor': {'shape': [4], 'dataType': 'float16'},
909-
'constant': true
910-
},
911-
'dequantizeLinearZeroPoint': {
912-
'data': [128, 128, 128, 128],
913-
'descriptor': {'shape': [4], 'dataType': 'uint8'},
914-
'constant': true
915-
}
916-
},
917-
'operators': [{
918-
'name': 'dequantizeLinear',
919-
'arguments': [
920-
{'input': 'dequantizeLinearInput'},
921-
{'scale': 'dequantizeLinearScale'},
922-
{'zeroPoint': 'dequantizeLinearZeroPoint'}
923-
],
924-
'outputs': 'dequantizeLinearOutput'
925-
}],
926-
'expectedOutputs': {
927-
'dequantizeLinearOutput': {
928-
'data': [-1084, -29.125, 429.5, -5.6015625],
929-
'descriptor': {'shape': [4], 'dataType': 'float16'}
930-
}
931-
}
932-
}
933-
},
934850
{
935851
'name':
936852
'dequantizeLinear uint8 1D tensor with float16 1D scale, implicit block_size = 2',
@@ -942,7 +858,7 @@ const dequantizeLinearTests = [
942858
'constant': false
943859
},
944860
'dequantizeLinearScale': {
945-
'data': [9.34375, -4.6171875],
861+
'data': [9.34375, 4.6171875],
946862
'descriptor': {'shape': [2], 'dataType': 'float16'},
947863
'constant': true
948864
},
@@ -963,7 +879,7 @@ const dequantizeLinearTests = [
963879
}],
964880
'expectedOutputs': {
965881
'dequantizeLinearOutput': {
966-
'data': [-1084, -972, 346.25, -60.03125],
882+
'data': [-1084, -972, -346.25, 60.03125],
967883
'descriptor': {'shape': [4], 'dataType': 'float16'}
968884
}
969885
}
@@ -980,7 +896,7 @@ const dequantizeLinearTests = [
980896
'constant': false
981897
},
982898
'dequantizeLinearScale': {
983-
'data': [0.280029296875, -4.6171875],
899+
'data': [0.280029296875, 4.6171875],
984900
'descriptor': {'shape': [1, 1, 2, 1], 'dataType': 'float16'},
985901
'constant': true
986902
},
@@ -1001,7 +917,7 @@ const dequantizeLinearTests = [
1001917
}],
1002918
'expectedOutputs': {
1003919
'dequantizeLinearOutput': {
1004-
'data': [-38.09375, -3.359375, -50.78125, -508],
920+
'data': [-38.09375, -3.359375, 50.78125, 508],
1005921
'descriptor': {'shape': [1, 1, 2, 2], 'dataType': 'float16'}
1006922
}
1007923
}
@@ -1021,7 +937,7 @@ const dequantizeLinearTests = [
1021937
'constant': false
1022938
},
1023939
'dequantizeLinearScale': {
1024-
'data': [0.280029296875, -4.6171875, 1.2802734375, -3.6171875],
940+
'data': [0.280029296875, 4.6171875, 1.2802734375, 3.6171875],
1025941
'descriptor': {'shape': [2, 2], 'dataType': 'float16'},
1026942
'constant': true
1027943
},
@@ -1043,11 +959,11 @@ const dequantizeLinearTests = [
1043959
'expectedOutputs': {
1044960
'dequantizeLinearOutput': {
1045961
'data': [
1046-
-35, -0.280029296875, -92.375, -549.5, 3.080078125,
1047-
6.16015625, -193.875, -152.375, 18.484375, 21.5625,
1048-
115.4375, 13.8515625, -49.9375, -64, 246,
1049-
285.75, 107.5625, 32, 0, -39.78125,
1050-
65.3125, 79.375, -159.125, 86.8125
962+
-35, -0.280029296875, 92.375, 549.5, 3.080078125,
963+
6.16015625, 193.875, 152.375, 18.484375, 21.5625,
964+
-115.4375, -13.8515625, -49.9375, -64, -246,
965+
-285.75, 107.5625, 32, 0, 39.78125,
966+
65.3125, 79.375, 159.125, -86.8125
1051967
],
1052968
'descriptor': {'shape': [6, 4], 'dataType': 'float16'}
1053969
}
@@ -1141,7 +1057,7 @@ const dequantizeLinearTests = [
11411057
'constant': false
11421058
},
11431059
'dequantizeLinearScale': {
1144-
'data': [9.34375, -4.6171875],
1060+
'data': [9.34375, 4.6171875],
11451061
'descriptor': {'shape': [1, 1, 2, 1], 'dataType': 'float16'},
11461062
'constant': true
11471063
},
@@ -1162,7 +1078,7 @@ const dequantizeLinearTests = [
11621078
}],
11631079
'expectedOutputs': {
11641080
'dequantizeLinearOutput': {
1165-
'data': [-18.6875, -9.34375, -32.3125, -55.40625],
1081+
'data': [-18.6875, -9.34375, 32.3125, 55.40625],
11661082
'descriptor': {'shape': [1, 1, 2, 2], 'dataType': 'float16'}
11671083
}
11681084
}
@@ -1179,7 +1095,7 @@ const dequantizeLinearTests = [
11791095
'constant': false
11801096
},
11811097
'dequantizeLinearScale': {
1182-
'data': [9.34375, -4.6171875],
1098+
'data': [9.34375, 4.6171875],
11831099
'descriptor': {'shape': [1, 1, 2], 'dataType': 'float16'},
11841100
'constant': true
11851101
},
@@ -1200,7 +1116,7 @@ const dequantizeLinearTests = [
12001116
}],
12011117
'expectedOutputs': {
12021118
'dequantizeLinearOutput': {
1203-
'data': [-18.6875, -9.34375, -32.3125, -55.40625],
1119+
'data': [-18.6875, -9.34375, 32.3125, 55.40625],
12041120
'descriptor': {'shape': [1, 1, 4], 'dataType': 'float16'}
12051121
}
12061122
}
@@ -1292,7 +1208,7 @@ const dequantizeLinearTests = [
12921208
'constant': false
12931209
},
12941210
'dequantizeLinearScale': {
1295-
'data': [1.1201171875, -4.6171875, 6.2421875, 3.841796875],
1211+
'data': [1.1201171875, 4.6171875, 6.2421875, 3.841796875],
12961212
'descriptor': {'shape': [1, 1, 2, 2], 'dataType': 'float16'},
12971213
'constant': true
12981214
},
@@ -1313,7 +1229,7 @@ const dequantizeLinearTests = [
13131229
}],
13141230
'expectedOutputs': {
13151231
'dequantizeLinearOutput': {
1316-
'data': [-2.240234375, -9.234375, -6.2421875, -11.5234375],
1232+
'data': [-2.240234375, 9.234375, -6.2421875, -11.5234375],
13171233
'descriptor': {'shape': [1, 1, 2, 2], 'dataType': 'float16'}
13181234
}
13191235
}

0 commit comments

Comments
 (0)