reduce_l1.https.any.js (42361B)
1 // META: title=test WebNN API reduction operations 2 // META: global=window 3 // META: variant=?cpu 4 // META: variant=?gpu 5 // META: variant=?npu 6 // META: script=../resources/utils.js 7 // META: timeout=long 8 9 'use strict'; 10 11 // https://www.w3.org/TR/webnn/#dom-mlgraphbuilder-reducel1 12 // Reduce the input tensor along all dimensions, or along the axes specified in 13 // the axes array parameter. 14 // 15 // dictionary MLReduceOptions { 16 // sequence<[EnforceRange] unsigned long> axes; 17 // boolean keepDimensions = false; 18 // }; 19 // 20 // MLOperand reduceL1(MLOperand input, optional MLReduceOptions options = {}); 21 22 const reduceL1Tests = [ 23 { 24 'name': 'reduceL1 float32 0D constant tensor default options', 25 'graph': { 26 'inputs': { 27 'reduceL1Input': { 28 'data': [5.50882625579834], 29 'descriptor': {shape: [], dataType: 'float32'}, 30 'constant': true 31 } 32 }, 33 'operators': [{ 34 'name': 'reduceL1', 35 'arguments': [{'input': 'reduceL1Input'}], 36 'outputs': 'reduceL1Output' 37 }], 38 'expectedOutputs': { 39 'reduceL1Output': { 40 'data': 5.50882625579834, 41 'descriptor': {shape: [], dataType: 'float32'} 42 } 43 } 44 } 45 }, 46 { 47 'name': 'reduceL1 float32 0D tensor default options', 48 'graph': { 49 'inputs': { 50 'reduceL1Input': { 51 'data': [5.50882625579834], 52 'descriptor': {shape: [], dataType: 'float32'}, 53 'constant': false 54 } 55 }, 56 'operators': [{ 57 'name': 'reduceL1', 58 'arguments': [{'input': 'reduceL1Input'}], 59 'outputs': 'reduceL1Output' 60 }], 61 'expectedOutputs': { 62 'reduceL1Output': { 63 'data': 5.50882625579834, 64 'descriptor': {shape: [], dataType: 'float32'} 65 } 66 } 67 } 68 }, 69 { 70 'name': 'reduceL1 float32 0D constant tensor empty axes', 71 'graph': { 72 'inputs': { 73 'reduceL1Input': { 74 'data': [5.50882625579834], 75 'descriptor': {shape: [], dataType: 'float32'}, 76 'constant': true 77 } 78 }, 79 'operators': [{ 80 'name': 'reduceL1', 81 'arguments': [{'input': 'reduceL1Input'}, {'options': {'axes': []}}], 82 'outputs': 'reduceL1Output' 83 }], 84 'expectedOutputs': { 85 'reduceL1Output': { 86 'data': 5.50882625579834, 87 'descriptor': {shape: [], dataType: 'float32'} 88 } 89 } 90 } 91 }, 92 { 93 'name': 'reduceL1 float32 0D tensor empty axes', 94 'graph': { 95 'inputs': { 96 'reduceL1Input': { 97 'data': [5.50882625579834], 98 'descriptor': {shape: [], dataType: 'float32'}, 99 'constant': false 100 } 101 }, 102 'operators': [{ 103 'name': 'reduceL1', 104 'arguments': [{'input': 'reduceL1Input'}, {'options': {'axes': []}}], 105 'outputs': 'reduceL1Output' 106 }], 107 'expectedOutputs': { 108 'reduceL1Output': { 109 'data': 5.50882625579834, 110 'descriptor': {shape: [], dataType: 'float32'} 111 } 112 } 113 } 114 }, 115 { 116 'name': 'reduceL1 float32 1D constant tensor empty axes', 117 'graph': { 118 'inputs': { 119 'reduceL1Input': { 120 'data': [-5.50882625579834, 5.50882625579833], 121 'descriptor': {shape: [2], dataType: 'float32'}, 122 'constant': true 123 } 124 }, 125 'operators': [{ 126 'name': 'reduceL1', 127 'arguments': [{'input': 'reduceL1Input'}, {'options': {'axes': []}}], 128 'outputs': 'reduceL1Output' 129 }], 130 'expectedOutputs': { 131 'reduceL1Output': { 132 'data': [5.50882625579834, 5.50882625579833], 133 'descriptor': {shape: [2], dataType: 'float32'} 134 } 135 } 136 } 137 }, 138 { 139 'name': 'reduceL1 float32 1D constant tensor all positive default options', 140 'graph': { 141 'inputs': { 142 'reduceL1Input': { 143 'data': [ 144 5.50882625579834, 50.61575698852539, 1.6773051023483276, 145 84.2135238647461, 15.664374351501465, 52.89714813232422, 146 9.125157356262207, 28.937623977661133, 12.567061424255371, 147 11.39999008178711, 86.91246032714844, 64.51329803466797, 148 71.2834243774414, 76.34410858154297, 41.53409194946289, 149 97.5653305053711, 31.803831100463867, 6.089754581451416, 150 61.70843505859375, 69.76119232177734, 38.919403076171875, 151 52.288333892822266, 22.31783676147461, 99.0719223022461 152 ], 153 'descriptor': {shape: [24], dataType: 'float32'}, 154 'constant': true 155 } 156 }, 157 'operators': [{ 158 'name': 'reduceL1', 159 'arguments': [{'input': 'reduceL1Input'}], 160 'outputs': 'reduceL1Output' 161 }], 162 'expectedOutputs': { 163 'reduceL1Output': { 164 'data': 1092.72021484375, 165 'descriptor': {shape: [], dataType: 'float32'} 166 } 167 } 168 } 169 }, 170 { 171 'name': 'reduceL1 float32 1D tensor all positive default options', 172 'graph': { 173 'inputs': { 174 'reduceL1Input': { 175 'data': [ 176 5.50882625579834, 50.61575698852539, 1.6773051023483276, 177 84.2135238647461, 15.664374351501465, 52.89714813232422, 178 9.125157356262207, 28.937623977661133, 12.567061424255371, 179 11.39999008178711, 86.91246032714844, 64.51329803466797, 180 71.2834243774414, 76.34410858154297, 41.53409194946289, 181 97.5653305053711, 31.803831100463867, 6.089754581451416, 182 61.70843505859375, 69.76119232177734, 38.919403076171875, 183 52.288333892822266, 22.31783676147461, 99.0719223022461 184 ], 185 'descriptor': {shape: [24], dataType: 'float32'} 186 } 187 }, 188 'operators': [{ 189 'name': 'reduceL1', 190 'arguments': [{'input': 'reduceL1Input'}], 191 'outputs': 'reduceL1Output' 192 }], 193 'expectedOutputs': { 194 'reduceL1Output': { 195 'data': 1092.72021484375, 196 'descriptor': {shape: [], dataType: 'float32'} 197 } 198 } 199 } 200 }, 201 { 202 'name': 'reduceL1 float32 1D tensor all negative default options', 203 'graph': { 204 'inputs': { 205 'reduceL1Input': { 206 'data': [ 207 -98.83928680419922, -57.66743850708008, -57.101200103759766, 208 -6.693042278289795, -45.30584716796875, -86.68338775634766, 209 -74.71875, -76.46739959716797, -75.37677001953125, 210 -18.22093963623047, -54.64426803588867, -36.45240020751953, 211 -18.322681427001953, -47.94379425048828, -40.19978332519531, 212 -15.830483436584473, -48.883358001708984, -41.600242614746094, 213 -20.6556339263916, -92.2993392944336, -46.28858184814453, 214 -80.57186126708984, -25.49472999572754, -48.96730041503906 215 ], 216 'descriptor': {shape: [24], dataType: 'float32'} 217 } 218 }, 219 'operators': [{ 220 'name': 'reduceL1', 221 'arguments': [{'input': 'reduceL1Input'}], 222 'outputs': 'reduceL1Output' 223 }], 224 'expectedOutputs': { 225 'reduceL1Output': { 226 'data': 1215.228515625, 227 'descriptor': {shape: [], dataType: 'float32'} 228 } 229 } 230 } 231 }, 232 { 233 'name': 'reduceL1 float32 1D tensor all positive integers default options', 234 'graph': { 235 'inputs': { 236 'reduceL1Input': { 237 'data': [ 238 18, 29, 35, 36, 4, 76, 41, 18, 53, 29, 25, 94, 239 26, 1, 3, 68, 39, 25, 87, 30, 39, 75, 76, 66 240 ], 241 'descriptor': {shape: [24], dataType: 'float32'} 242 } 243 }, 244 'operators': [{ 245 'name': 'reduceL1', 246 'arguments': [{'input': 'reduceL1Input'}], 247 'outputs': 'reduceL1Output' 248 }], 249 'expectedOutputs': { 250 'reduceL1Output': 251 {'data': 993, 'descriptor': {shape: [], dataType: 'float32'}} 252 } 253 } 254 }, 255 { 256 'name': 'reduceL1 float32 1D tensor all negative integers default options', 257 'graph': { 258 'inputs': { 259 'reduceL1Input': { 260 'data': [ 261 -92, -52, -88, -78, -20, -73, -42, -57, -39, -75, -17, -36, 262 -81, -24, -88, -91, -76, -5, -44, -66, -96, -8, -69, -27 263 ], 264 'descriptor': {shape: [24], dataType: 'float32'} 265 } 266 }, 267 'operators': [{ 268 'name': 'reduceL1', 269 'arguments': [{'input': 'reduceL1Input'}], 270 'outputs': 'reduceL1Output' 271 }], 272 'expectedOutputs': { 273 'reduceL1Output': 274 {'data': 1344, 'descriptor': {shape: [], dataType: 'float32'}} 275 } 276 } 277 }, 278 { 279 'name': 'reduceL1 float32 2D tensor default options', 280 'graph': { 281 'inputs': { 282 'reduceL1Input': { 283 'data': [ 284 5.50882625579834, 50.61575698852539, 1.6773051023483276, 285 84.2135238647461, 15.664374351501465, 52.89714813232422, 286 9.125157356262207, 28.937623977661133, 12.567061424255371, 287 11.39999008178711, 86.91246032714844, 64.51329803466797, 288 71.2834243774414, 76.34410858154297, 41.53409194946289, 289 97.5653305053711, 31.803831100463867, 6.089754581451416, 290 61.70843505859375, 69.76119232177734, 38.919403076171875, 291 52.288333892822266, 22.31783676147461, 99.0719223022461 292 ], 293 'descriptor': {shape: [4, 6], dataType: 'float32'} 294 } 295 }, 296 'operators': [{ 297 'name': 'reduceL1', 298 'arguments': [{'input': 'reduceL1Input'}], 299 'outputs': 'reduceL1Output' 300 }], 301 'expectedOutputs': { 302 'reduceL1Output': { 303 'data': 1092.72021484375, 304 'descriptor': {shape: [], dataType: 'float32'} 305 } 306 } 307 } 308 }, 309 { 310 'name': 'reduceL1 float32 3D tensor default options', 311 'graph': { 312 'inputs': { 313 'reduceL1Input': { 314 'data': [ 315 5.50882625579834, 50.61575698852539, 1.6773051023483276, 316 84.2135238647461, 15.664374351501465, 52.89714813232422, 317 9.125157356262207, 28.937623977661133, 12.567061424255371, 318 11.39999008178711, 86.91246032714844, 64.51329803466797, 319 71.2834243774414, 76.34410858154297, 41.53409194946289, 320 97.5653305053711, 31.803831100463867, 6.089754581451416, 321 61.70843505859375, 69.76119232177734, 38.919403076171875, 322 52.288333892822266, 22.31783676147461, 99.0719223022461 323 ], 324 'descriptor': {shape: [2, 3, 4], dataType: 'float32'} 325 } 326 }, 327 'operators': [{ 328 'name': 'reduceL1', 329 'arguments': [{'input': 'reduceL1Input'}], 330 'outputs': 'reduceL1Output' 331 }], 332 'expectedOutputs': { 333 'reduceL1Output': { 334 'data': 1092.72021484375, 335 'descriptor': {shape: [], dataType: 'float32'} 336 } 337 } 338 } 339 }, 340 { 341 'name': 'reduceL1 float32 4D tensor default options', 342 'graph': { 343 'inputs': { 344 'reduceL1Input': { 345 'data': [ 346 5.50882625579834, 50.61575698852539, 1.6773051023483276, 347 84.2135238647461, 15.664374351501465, 52.89714813232422, 348 9.125157356262207, 28.937623977661133, 12.567061424255371, 349 11.39999008178711, 86.91246032714844, 64.51329803466797, 350 71.2834243774414, 76.34410858154297, 41.53409194946289, 351 97.5653305053711, 31.803831100463867, 6.089754581451416, 352 61.70843505859375, 69.76119232177734, 38.919403076171875, 353 52.288333892822266, 22.31783676147461, 99.0719223022461 354 ], 355 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 356 } 357 }, 358 'operators': [{ 359 'name': 'reduceL1', 360 'arguments': [{'input': 'reduceL1Input'}], 361 'outputs': 'reduceL1Output' 362 }], 363 'expectedOutputs': { 364 'reduceL1Output': { 365 'data': 1092.72021484375, 366 'descriptor': {shape: [], dataType: 'float32'} 367 } 368 } 369 } 370 }, 371 { 372 'name': 'reduceL1 float32 5D tensor default options', 373 'graph': { 374 'inputs': { 375 'reduceL1Input': { 376 'data': [ 377 5.50882625579834, 50.61575698852539, 1.6773051023483276, 378 84.2135238647461, 15.664374351501465, 52.89714813232422, 379 9.125157356262207, 28.937623977661133, 12.567061424255371, 380 11.39999008178711, 86.91246032714844, 64.51329803466797, 381 71.2834243774414, 76.34410858154297, 41.53409194946289, 382 97.5653305053711, 31.803831100463867, 6.089754581451416, 383 61.70843505859375, 69.76119232177734, 38.919403076171875, 384 52.288333892822266, 22.31783676147461, 99.0719223022461 385 ], 386 'descriptor': {shape: [2, 1, 4, 1, 3], dataType: 'float32'} 387 } 388 }, 389 'operators': [{ 390 'name': 'reduceL1', 391 'arguments': [{'input': 'reduceL1Input'}], 392 'outputs': 'reduceL1Output' 393 }], 394 'expectedOutputs': { 395 'reduceL1Output': { 396 'data': 1092.72021484375, 397 'descriptor': {shape: [], dataType: 'float32'} 398 } 399 } 400 } 401 }, 402 { 403 'name': 'reduceL1 float32 3D tensor options.axes', 404 'graph': { 405 'inputs': { 406 'reduceL1Input': { 407 'data': [ 408 5.50882625579834, 50.61575698852539, 1.6773051023483276, 409 84.2135238647461, 15.664374351501465, 52.89714813232422, 410 9.125157356262207, 28.937623977661133, 12.567061424255371, 411 11.39999008178711, 86.91246032714844, 64.51329803466797, 412 71.2834243774414, 76.34410858154297, 41.53409194946289, 413 97.5653305053711, 31.803831100463867, 6.089754581451416, 414 61.70843505859375, 69.76119232177734, 38.919403076171875, 415 52.288333892822266, 22.31783676147461, 99.0719223022461 416 ], 417 'descriptor': {shape: [2, 3, 4], dataType: 'float32'} 418 } 419 }, 420 'operators': [{ 421 'name': 'reduceL1', 422 'arguments': [{'input': 'reduceL1Input'}, {'options': {'axes': [2]}}], 423 'outputs': 'reduceL1Output' 424 }], 425 'expectedOutputs': { 426 'reduceL1Output': { 427 'data': [ 428 142.01541137695312, 106.62430572509766, 175.39280700683594, 429 286.7269592285156, 169.36322021484375, 212.59750366210938 430 ], 431 'descriptor': {shape: [2, 3], dataType: 'float32'} 432 } 433 } 434 } 435 }, 436 { 437 'name': 'reduceL1 float32 4D tensor options.axes', 438 'graph': { 439 'inputs': { 440 'reduceL1Input': { 441 'data': [ 442 5.50882625579834, 50.61575698852539, 1.6773051023483276, 443 84.2135238647461, 15.664374351501465, 52.89714813232422, 444 9.125157356262207, 28.937623977661133, 12.567061424255371, 445 11.39999008178711, 86.91246032714844, 64.51329803466797, 446 71.2834243774414, 76.34410858154297, 41.53409194946289, 447 97.5653305053711, 31.803831100463867, 6.089754581451416, 448 61.70843505859375, 69.76119232177734, 38.919403076171875, 449 52.288333892822266, 22.31783676147461, 99.0719223022461 450 ], 451 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 452 } 453 }, 454 'operators': [{ 455 'name': 'reduceL1', 456 'arguments': 457 [{'input': 'reduceL1Input'}, {'options': {'axes': [0, 2]}}], 458 'outputs': 'reduceL1Output' 459 }], 460 'expectedOutputs': { 461 'reduceL1Output': { 462 'data': [ 463 258.57110595703125, 174.42807006835938, 102.19830322265625, 464 134.52191162109375, 207.92910766601562, 215.07168579101562 465 ], 466 'descriptor': {shape: [2, 3], dataType: 'float32'} 467 } 468 } 469 } 470 }, 471 { 472 'name': 'reduceL1 float32 3D tensor options.keepDimensions=false', 473 'graph': { 474 'inputs': { 475 'reduceL1Input': { 476 'data': [ 477 5.50882625579834, 50.61575698852539, 1.6773051023483276, 478 84.2135238647461, 15.664374351501465, 52.89714813232422, 479 9.125157356262207, 28.937623977661133, 12.567061424255371, 480 11.39999008178711, 86.91246032714844, 64.51329803466797, 481 71.2834243774414, 76.34410858154297, 41.53409194946289, 482 97.5653305053711, 31.803831100463867, 6.089754581451416, 483 61.70843505859375, 69.76119232177734, 38.919403076171875, 484 52.288333892822266, 22.31783676147461, 99.0719223022461 485 ], 486 'descriptor': {shape: [2, 3, 4], dataType: 'float32'} 487 } 488 }, 489 'operators': [{ 490 'name': 'reduceL1', 491 'arguments': [ 492 {'input': 'reduceL1Input'}, {'options': {'keepDimensions': false}} 493 ], 494 'outputs': 'reduceL1Output' 495 }], 496 'expectedOutputs': { 497 'reduceL1Output': { 498 'data': 1092.72021484375, 499 'descriptor': {shape: [], dataType: 'float32'} 500 } 501 } 502 } 503 }, 504 { 505 'name': 'reduceL1 float32 3D tensor options.keepDimensions=true', 506 'graph': { 507 'inputs': { 508 'reduceL1Input': { 509 'data': [ 510 5.50882625579834, 50.61575698852539, 1.6773051023483276, 511 84.2135238647461, 15.664374351501465, 52.89714813232422, 512 9.125157356262207, 28.937623977661133, 12.567061424255371, 513 11.39999008178711, 86.91246032714844, 64.51329803466797, 514 71.2834243774414, 76.34410858154297, 41.53409194946289, 515 97.5653305053711, 31.803831100463867, 6.089754581451416, 516 61.70843505859375, 69.76119232177734, 38.919403076171875, 517 52.288333892822266, 22.31783676147461, 99.0719223022461 518 ], 519 'descriptor': {shape: [2, 3, 4], dataType: 'float32'} 520 } 521 }, 522 'operators': [{ 523 'name': 'reduceL1', 524 'arguments': 525 [{'input': 'reduceL1Input'}, {'options': {'keepDimensions': true}}], 526 'outputs': 'reduceL1Output' 527 }], 528 'expectedOutputs': { 529 'reduceL1Output': { 530 'data': [1092.72021484375], 531 'descriptor': {shape: [1, 1, 1], dataType: 'float32'} 532 } 533 } 534 } 535 }, 536 { 537 'name': 'reduceL1 float32 4D tensor options.keepDimensions=false', 538 'graph': { 539 'inputs': { 540 'reduceL1Input': { 541 'data': [ 542 5.50882625579834, 50.61575698852539, 1.6773051023483276, 543 84.2135238647461, 15.664374351501465, 52.89714813232422, 544 9.125157356262207, 28.937623977661133, 12.567061424255371, 545 11.39999008178711, 86.91246032714844, 64.51329803466797, 546 71.2834243774414, 76.34410858154297, 41.53409194946289, 547 97.5653305053711, 31.803831100463867, 6.089754581451416, 548 61.70843505859375, 69.76119232177734, 38.919403076171875, 549 52.288333892822266, 22.31783676147461, 99.0719223022461 550 ], 551 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 552 } 553 }, 554 'operators': [{ 555 'name': 'reduceL1', 556 'arguments': [ 557 {'input': 'reduceL1Input'}, {'options': {'keepDimensions': false}} 558 ], 559 'outputs': 'reduceL1Output' 560 }], 561 'expectedOutputs': { 562 'reduceL1Output': { 563 'data': 1092.72021484375, 564 'descriptor': {shape: [], dataType: 'float32'} 565 } 566 } 567 } 568 }, 569 { 570 'name': 'reduceL1 float32 4D tensor options.keepDimensions=true', 571 'graph': { 572 'inputs': { 573 'reduceL1Input': { 574 'data': [ 575 5.50882625579834, 50.61575698852539, 1.6773051023483276, 576 84.2135238647461, 15.664374351501465, 52.89714813232422, 577 9.125157356262207, 28.937623977661133, 12.567061424255371, 578 11.39999008178711, 86.91246032714844, 64.51329803466797, 579 71.2834243774414, 76.34410858154297, 41.53409194946289, 580 97.5653305053711, 31.803831100463867, 6.089754581451416, 581 61.70843505859375, 69.76119232177734, 38.919403076171875, 582 52.288333892822266, 22.31783676147461, 99.0719223022461 583 ], 584 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 585 } 586 }, 587 'operators': [{ 588 'name': 'reduceL1', 589 'arguments': 590 [{'input': 'reduceL1Input'}, {'options': {'keepDimensions': true}}], 591 'outputs': 'reduceL1Output' 592 }], 593 'expectedOutputs': { 594 'reduceL1Output': { 595 'data': [1092.72021484375], 596 'descriptor': {shape: [1, 1, 1, 1], dataType: 'float32'} 597 } 598 } 599 } 600 }, 601 { 602 'name': 603 'reduceL1 float32 4D tensor options.axes with options.keepDimensions=false', 604 'graph': { 605 'inputs': { 606 'reduceL1Input': { 607 'data': [ 608 5.50882625579834, 50.61575698852539, 1.6773051023483276, 609 84.2135238647461, 15.664374351501465, 52.89714813232422, 610 9.125157356262207, 28.937623977661133, 12.567061424255371, 611 11.39999008178711, 86.91246032714844, 64.51329803466797, 612 71.2834243774414, 76.34410858154297, 41.53409194946289, 613 97.5653305053711, 31.803831100463867, 6.089754581451416, 614 61.70843505859375, 69.76119232177734, 38.919403076171875, 615 52.288333892822266, 22.31783676147461, 99.0719223022461 616 ], 617 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 618 } 619 }, 620 'operators': [{ 621 'name': 'reduceL1', 622 'arguments': [ 623 {'input': 'reduceL1Input'}, 624 {'options': {'axes': [1, 3], 'keepDimensions': false}} 625 ], 626 'outputs': 'reduceL1Output' 627 }], 628 'expectedOutputs': { 629 'reduceL1Output': { 630 'data': [ 631 108.43173217773438, 315.6007995605469, 359.5506591796875, 632 309.13702392578125 633 ], 634 'descriptor': {shape: [2, 2], dataType: 'float32'} 635 } 636 } 637 } 638 }, 639 { 640 'name': 641 'reduceL1 float32 4D tensor options.axes with options.keepDimensions=true', 642 'graph': { 643 'inputs': { 644 'reduceL1Input': { 645 'data': [ 646 5.50882625579834, 50.61575698852539, 1.6773051023483276, 647 84.2135238647461, 15.664374351501465, 52.89714813232422, 648 9.125157356262207, 28.937623977661133, 12.567061424255371, 649 11.39999008178711, 86.91246032714844, 64.51329803466797, 650 71.2834243774414, 76.34410858154297, 41.53409194946289, 651 97.5653305053711, 31.803831100463867, 6.089754581451416, 652 61.70843505859375, 69.76119232177734, 38.919403076171875, 653 52.288333892822266, 22.31783676147461, 99.0719223022461 654 ], 655 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 656 } 657 }, 658 'operators': [{ 659 'name': 'reduceL1', 660 'arguments': [ 661 {'input': 'reduceL1Input'}, 662 {'options': {'axes': [1, 3], 'keepDimensions': true}} 663 ], 664 'outputs': 'reduceL1Output' 665 }], 666 'expectedOutputs': { 667 'reduceL1Output': { 668 'data': [ 669 108.43173217773438, 315.6007995605469, 359.5506591796875, 670 309.13702392578125 671 ], 672 'descriptor': {shape: [2, 1, 2, 1], dataType: 'float32'} 673 } 674 } 675 } 676 }, 677 678 // float16 tests 679 { 680 'name': 'reduceL1 float16 0D constant tensor default options', 681 'graph': { 682 'inputs': { 683 'reduceL1Input': { 684 'data': [5.5078125], 685 'descriptor': {shape: [], dataType: 'float16'}, 686 'constant': true 687 } 688 }, 689 'operators': [{ 690 'name': 'reduceL1', 691 'arguments': [{'input': 'reduceL1Input'}], 692 'outputs': 'reduceL1Output' 693 }], 694 'expectedOutputs': { 695 'reduceL1Output': { 696 'data': [5.5078125], 697 'descriptor': {shape: [], dataType: 'float16'} 698 } 699 } 700 } 701 }, 702 { 703 'name': 'reduceL1 float16 0D tensor default options', 704 'graph': { 705 'inputs': { 706 'reduceL1Input': { 707 'data': [5.5078125], 708 'descriptor': {shape: [], dataType: 'float16'}, 709 'constant': false 710 } 711 }, 712 'operators': [{ 713 'name': 'reduceL1', 714 'arguments': [{'input': 'reduceL1Input'}], 715 'outputs': 'reduceL1Output' 716 }], 717 'expectedOutputs': { 718 'reduceL1Output': { 719 'data': [5.5078125], 720 'descriptor': {shape: [], dataType: 'float16'} 721 } 722 } 723 } 724 }, 725 { 726 'name': 'reduceL1 float16 0D constant tensor empty axes', 727 'graph': { 728 'inputs': { 729 'reduceL1Input': { 730 'data': [5.5078125], 731 'descriptor': {shape: [], dataType: 'float16'}, 732 'constant': true 733 } 734 }, 735 'operators': [{ 736 'name': 'reduceL1', 737 'arguments': [{'input': 'reduceL1Input'}, {'options': {'axes': []}}], 738 'outputs': 'reduceL1Output' 739 }], 740 'expectedOutputs': { 741 'reduceL1Output': { 742 'data': [5.5078125], 743 'descriptor': {shape: [], dataType: 'float16'} 744 } 745 } 746 } 747 }, 748 { 749 'name': 'reduceL1 float16 0D tensor empty axes', 750 'graph': { 751 'inputs': { 752 'reduceL1Input': { 753 'data': [5.5078125], 754 'descriptor': {shape: [], dataType: 'float16'}, 755 'constant': false 756 } 757 }, 758 'operators': [{ 759 'name': 'reduceL1', 760 'arguments': [{'input': 'reduceL1Input'}, {'options': {'axes': []}}], 761 'outputs': 'reduceL1Output' 762 }], 763 'expectedOutputs': { 764 'reduceL1Output': { 765 'data': [5.5078125], 766 'descriptor': {shape: [], dataType: 'float16'} 767 } 768 } 769 } 770 }, 771 { 772 'name': 'reduceL1 float16 1D constant tensor all positive default options', 773 'graph': { 774 'inputs': { 775 'reduceL1Input': { 776 'data': [ 777 5.5078125, 50.625, 1.677734375, 84.1875, 15.6640625, 52.90625, 778 9.125, 28.9375, 12.5703125, 11.3984375, 86.9375, 64.5, 779 71.3125, 76.375, 41.53125, 97.5625, 31.796875, 6.08984375, 780 61.71875, 69.75, 38.90625, 52.28125, 22.3125, 99.0625 781 ], 782 'descriptor': {shape: [24], dataType: 'float16'}, 783 'constant': true 784 } 785 }, 786 'operators': [{ 787 'name': 'reduceL1', 788 'arguments': [{'input': 'reduceL1Input'}], 789 'outputs': 'reduceL1Output' 790 }], 791 'expectedOutputs': { 792 'reduceL1Output': 793 {'data': [1093], 'descriptor': {shape: [], dataType: 'float16'}} 794 } 795 } 796 }, 797 { 798 'name': 'reduceL1 float16 1D tensor all positive default options', 799 'graph': { 800 'inputs': { 801 'reduceL1Input': { 802 'data': [ 803 5.5078125, 50.625, 1.677734375, 84.1875, 15.6640625, 52.90625, 804 9.125, 28.9375, 12.5703125, 11.3984375, 86.9375, 64.5, 805 71.3125, 76.375, 41.53125, 97.5625, 31.796875, 6.08984375, 806 61.71875, 69.75, 38.90625, 52.28125, 22.3125, 99.0625 807 ], 808 'descriptor': {shape: [24], dataType: 'float16'} 809 } 810 }, 811 'operators': [{ 812 'name': 'reduceL1', 813 'arguments': [{'input': 'reduceL1Input'}], 814 'outputs': 'reduceL1Output' 815 }], 816 'expectedOutputs': { 817 'reduceL1Output': 818 {'data': [1093], 'descriptor': {shape: [], dataType: 'float16'}} 819 } 820 } 821 }, 822 { 823 'name': 'reduceL1 float16 1D tensor all negative default options', 824 'graph': { 825 'inputs': { 826 'reduceL1Input': { 827 'data': [ 828 -98.8125, -57.65625, -57.09375, -6.69140625, -45.3125, 829 -86.6875, -74.75, -76.4375, -75.375, -18.21875, 830 -54.65625, -36.4375, -18.328125, -47.9375, -40.1875, 831 -15.828125, -48.875, -41.59375, -20.65625, -92.3125, 832 -46.28125, -80.5625, -25.5, -48.96875 833 ], 834 'descriptor': {shape: [24], dataType: 'float16'} 835 } 836 }, 837 'operators': [{ 838 'name': 'reduceL1', 839 'arguments': [{'input': 'reduceL1Input'}], 840 'outputs': 'reduceL1Output' 841 }], 842 'expectedOutputs': { 843 'reduceL1Output': 844 {'data': [1215], 'descriptor': {shape: [], dataType: 'float16'}} 845 } 846 } 847 }, 848 { 849 'name': 'reduceL1 float16 1D tensor all positive integers default options', 850 'graph': { 851 'inputs': { 852 'reduceL1Input': { 853 'data': [ 854 18, 29, 35, 36, 4, 76, 41, 18, 53, 29, 25, 94, 855 26, 1, 3, 68, 39, 25, 87, 30, 39, 75, 76, 66 856 ], 857 'descriptor': {shape: [24], dataType: 'float16'} 858 } 859 }, 860 'operators': [{ 861 'name': 'reduceL1', 862 'arguments': [{'input': 'reduceL1Input'}], 863 'outputs': 'reduceL1Output' 864 }], 865 'expectedOutputs': { 866 'reduceL1Output': 867 {'data': [993], 'descriptor': {shape: [], dataType: 'float16'}} 868 } 869 } 870 }, 871 { 872 'name': 'reduceL1 float16 1D tensor all negative integers default options', 873 'graph': { 874 'inputs': { 875 'reduceL1Input': { 876 'data': [ 877 -92, -52, -88, -78, -20, -73, -42, -57, -39, -75, -17, -36, 878 -81, -24, -88, -91, -76, -5, -44, -66, -96, -8, -69, -27 879 ], 880 'descriptor': {shape: [24], dataType: 'float16'} 881 } 882 }, 883 'operators': [{ 884 'name': 'reduceL1', 885 'arguments': [{'input': 'reduceL1Input'}], 886 'outputs': 'reduceL1Output' 887 }], 888 'expectedOutputs': { 889 'reduceL1Output': 890 {'data': [1344], 'descriptor': {shape: [], dataType: 'float16'}} 891 } 892 } 893 }, 894 { 895 'name': 'reduceL1 float16 2D tensor default options', 896 'graph': { 897 'inputs': { 898 'reduceL1Input': { 899 'data': [ 900 5.5078125, 50.625, 1.677734375, 84.1875, 15.6640625, 52.90625, 901 9.125, 28.9375, 12.5703125, 11.3984375, 86.9375, 64.5, 902 71.3125, 76.375, 41.53125, 97.5625, 31.796875, 6.08984375, 903 61.71875, 69.75, 38.90625, 52.28125, 22.3125, 99.0625 904 ], 905 'descriptor': {shape: [4, 6], dataType: 'float16'} 906 } 907 }, 908 'operators': [{ 909 'name': 'reduceL1', 910 'arguments': [{'input': 'reduceL1Input'}], 911 'outputs': 'reduceL1Output' 912 }], 913 'expectedOutputs': { 914 'reduceL1Output': 915 {'data': [1093], 'descriptor': {shape: [], dataType: 'float16'}} 916 } 917 } 918 }, 919 { 920 'name': 'reduceL1 float16 3D tensor default options', 921 'graph': { 922 'inputs': { 923 'reduceL1Input': { 924 'data': [ 925 5.5078125, 50.625, 1.677734375, 84.1875, 15.6640625, 52.90625, 926 9.125, 28.9375, 12.5703125, 11.3984375, 86.9375, 64.5, 927 71.3125, 76.375, 41.53125, 97.5625, 31.796875, 6.08984375, 928 61.71875, 69.75, 38.90625, 52.28125, 22.3125, 99.0625 929 ], 930 'descriptor': {shape: [2, 3, 4], dataType: 'float16'} 931 } 932 }, 933 'operators': [{ 934 'name': 'reduceL1', 935 'arguments': [{'input': 'reduceL1Input'}], 936 'outputs': 'reduceL1Output' 937 }], 938 'expectedOutputs': { 939 'reduceL1Output': 940 {'data': [1093], 'descriptor': {shape: [], dataType: 'float16'}} 941 } 942 } 943 }, 944 { 945 'name': 'reduceL1 float16 4D tensor default options', 946 'graph': { 947 'inputs': { 948 'reduceL1Input': { 949 'data': [ 950 5.5078125, 50.625, 1.677734375, 84.1875, 15.6640625, 52.90625, 951 9.125, 28.9375, 12.5703125, 11.3984375, 86.9375, 64.5, 952 71.3125, 76.375, 41.53125, 97.5625, 31.796875, 6.08984375, 953 61.71875, 69.75, 38.90625, 52.28125, 22.3125, 99.0625 954 ], 955 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 956 } 957 }, 958 'operators': [{ 959 'name': 'reduceL1', 960 'arguments': [{'input': 'reduceL1Input'}], 961 'outputs': 'reduceL1Output' 962 }], 963 'expectedOutputs': { 964 'reduceL1Output': 965 {'data': [1093], 'descriptor': {shape: [], dataType: 'float16'}} 966 } 967 } 968 }, 969 { 970 'name': 'reduceL1 float16 5D tensor default options', 971 'graph': { 972 'inputs': { 973 'reduceL1Input': { 974 'data': [ 975 5.5078125, 50.625, 1.677734375, 84.1875, 15.6640625, 52.90625, 976 9.125, 28.9375, 12.5703125, 11.3984375, 86.9375, 64.5, 977 71.3125, 76.375, 41.53125, 97.5625, 31.796875, 6.08984375, 978 61.71875, 69.75, 38.90625, 52.28125, 22.3125, 99.0625 979 ], 980 'descriptor': {shape: [2, 1, 4, 1, 3], dataType: 'float16'} 981 } 982 }, 983 'operators': [{ 984 'name': 'reduceL1', 985 'arguments': [{'input': 'reduceL1Input'}], 986 'outputs': 'reduceL1Output' 987 }], 988 'expectedOutputs': { 989 'reduceL1Output': 990 {'data': [1093], 'descriptor': {shape: [], dataType: 'float16'}} 991 } 992 } 993 }, 994 { 995 'name': 'reduceL1 float16 3D tensor options.axes', 996 'graph': { 997 'inputs': { 998 'reduceL1Input': { 999 'data': [ 1000 5.5078125, 50.625, 1.677734375, 84.1875, 15.6640625, 52.90625, 1001 9.125, 28.9375, 12.5703125, 11.3984375, 86.9375, 64.5, 1002 71.3125, 76.375, 41.53125, 97.5625, 31.796875, 6.08984375, 1003 61.71875, 69.75, 38.90625, 52.28125, 22.3125, 99.0625 1004 ], 1005 'descriptor': {shape: [2, 3, 4], dataType: 'float16'} 1006 } 1007 }, 1008 'operators': [{ 1009 'name': 'reduceL1', 1010 'arguments': [{'input': 'reduceL1Input'}, {'options': {'axes': [2]}}], 1011 'outputs': 'reduceL1Output' 1012 }], 1013 'expectedOutputs': { 1014 'reduceL1Output': { 1015 'data': [142, 106.625, 175.375, 286.75, 169.375, 212.5], 1016 'descriptor': {shape: [2, 3], dataType: 'float16'} 1017 } 1018 } 1019 } 1020 }, 1021 { 1022 'name': 'reduceL1 float16 4D tensor options.axes', 1023 'graph': { 1024 'inputs': { 1025 'reduceL1Input': { 1026 'data': [ 1027 5.5078125, 50.625, 1.677734375, 84.1875, 15.6640625, 52.90625, 1028 9.125, 28.9375, 12.5703125, 11.3984375, 86.9375, 64.5, 1029 71.3125, 76.375, 41.53125, 97.5625, 31.796875, 6.08984375, 1030 61.71875, 69.75, 38.90625, 52.28125, 22.3125, 99.0625 1031 ], 1032 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 1033 } 1034 }, 1035 'operators': [{ 1036 'name': 'reduceL1', 1037 'arguments': 1038 [{'input': 'reduceL1Input'}, {'options': {'axes': [0, 2]}}], 1039 'outputs': 'reduceL1Output' 1040 }], 1041 'expectedOutputs': { 1042 'reduceL1Output': { 1043 'data': [258.5, 174.5, 102.1875, 134.5, 208, 215], 1044 'descriptor': {shape: [2, 3], dataType: 'float16'} 1045 } 1046 } 1047 } 1048 }, 1049 { 1050 'name': 'reduceL1 float16 3D tensor options.keepDimensions=false', 1051 'graph': { 1052 'inputs': { 1053 'reduceL1Input': { 1054 'data': [ 1055 5.5078125, 50.625, 1.677734375, 84.1875, 15.6640625, 52.90625, 1056 9.125, 28.9375, 12.5703125, 11.3984375, 86.9375, 64.5, 1057 71.3125, 76.375, 41.53125, 97.5625, 31.796875, 6.08984375, 1058 61.71875, 69.75, 38.90625, 52.28125, 22.3125, 99.0625 1059 ], 1060 'descriptor': {shape: [2, 3, 4], dataType: 'float16'} 1061 } 1062 }, 1063 'operators': [{ 1064 'name': 'reduceL1', 1065 'arguments': [ 1066 {'input': 'reduceL1Input'}, {'options': {'keepDimensions': false}} 1067 ], 1068 'outputs': 'reduceL1Output' 1069 }], 1070 'expectedOutputs': { 1071 'reduceL1Output': 1072 {'data': [1093], 'descriptor': {shape: [], dataType: 'float16'}} 1073 } 1074 } 1075 }, 1076 { 1077 'name': 'reduceL1 float16 3D tensor options.keepDimensions=true', 1078 'graph': { 1079 'inputs': { 1080 'reduceL1Input': { 1081 'data': [ 1082 5.5078125, 50.625, 1.677734375, 84.1875, 15.6640625, 52.90625, 1083 9.125, 28.9375, 12.5703125, 11.3984375, 86.9375, 64.5, 1084 71.3125, 76.375, 41.53125, 97.5625, 31.796875, 6.08984375, 1085 61.71875, 69.75, 38.90625, 52.28125, 22.3125, 99.0625 1086 ], 1087 'descriptor': {shape: [2, 3, 4], dataType: 'float16'} 1088 } 1089 }, 1090 'operators': [{ 1091 'name': 'reduceL1', 1092 'arguments': 1093 [{'input': 'reduceL1Input'}, {'options': {'keepDimensions': true}}], 1094 'outputs': 'reduceL1Output' 1095 }], 1096 'expectedOutputs': { 1097 'reduceL1Output': { 1098 'data': [1093], 1099 'descriptor': {shape: [1, 1, 1], dataType: 'float16'} 1100 } 1101 } 1102 } 1103 }, 1104 { 1105 'name': 'reduceL1 float16 4D tensor options.keepDimensions=false', 1106 'graph': { 1107 'inputs': { 1108 'reduceL1Input': { 1109 'data': [ 1110 5.5078125, 50.625, 1.677734375, 84.1875, 15.6640625, 52.90625, 1111 9.125, 28.9375, 12.5703125, 11.3984375, 86.9375, 64.5, 1112 71.3125, 76.375, 41.53125, 97.5625, 31.796875, 6.08984375, 1113 61.71875, 69.75, 38.90625, 52.28125, 22.3125, 99.0625 1114 ], 1115 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 1116 } 1117 }, 1118 'operators': [{ 1119 'name': 'reduceL1', 1120 'arguments': [ 1121 {'input': 'reduceL1Input'}, {'options': {'keepDimensions': false}} 1122 ], 1123 'outputs': 'reduceL1Output' 1124 }], 1125 'expectedOutputs': { 1126 'reduceL1Output': 1127 {'data': [1093], 'descriptor': {shape: [], dataType: 'float16'}} 1128 } 1129 } 1130 }, 1131 { 1132 'name': 'reduceL1 float16 4D tensor options.keepDimensions=true', 1133 'graph': { 1134 'inputs': { 1135 'reduceL1Input': { 1136 'data': [ 1137 5.5078125, 50.625, 1.677734375, 84.1875, 15.6640625, 52.90625, 1138 9.125, 28.9375, 12.5703125, 11.3984375, 86.9375, 64.5, 1139 71.3125, 76.375, 41.53125, 97.5625, 31.796875, 6.08984375, 1140 61.71875, 69.75, 38.90625, 52.28125, 22.3125, 99.0625 1141 ], 1142 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 1143 } 1144 }, 1145 'operators': [{ 1146 'name': 'reduceL1', 1147 'arguments': 1148 [{'input': 'reduceL1Input'}, {'options': {'keepDimensions': true}}], 1149 'outputs': 'reduceL1Output' 1150 }], 1151 'expectedOutputs': { 1152 'reduceL1Output': { 1153 'data': [1093], 1154 'descriptor': {shape: [1, 1, 1, 1], dataType: 'float16'} 1155 } 1156 } 1157 } 1158 }, 1159 { 1160 'name': 1161 'reduceL1 float16 4D tensor options.axes with options.keepDimensions=false', 1162 'graph': { 1163 'inputs': { 1164 'reduceL1Input': { 1165 'data': [ 1166 5.5078125, 50.625, 1.677734375, 84.1875, 15.6640625, 52.90625, 1167 9.125, 28.9375, 12.5703125, 11.3984375, 86.9375, 64.5, 1168 71.3125, 76.375, 41.53125, 97.5625, 31.796875, 6.08984375, 1169 61.71875, 69.75, 38.90625, 52.28125, 22.3125, 99.0625 1170 ], 1171 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 1172 } 1173 }, 1174 'operators': [{ 1175 'name': 'reduceL1', 1176 'arguments': [ 1177 {'input': 'reduceL1Input'}, 1178 {'options': {'axes': [1, 3], 'keepDimensions': false}} 1179 ], 1180 'outputs': 'reduceL1Output' 1181 }], 1182 'expectedOutputs': { 1183 'reduceL1Output': { 1184 'data': [108.4375, 315.5, 359.5, 309], 1185 'descriptor': {shape: [2, 2], dataType: 'float16'} 1186 } 1187 } 1188 } 1189 }, 1190 { 1191 'name': 1192 'reduceL1 float16 4D tensor options.axes with options.keepDimensions=true', 1193 'graph': { 1194 'inputs': { 1195 'reduceL1Input': { 1196 'data': [ 1197 5.5078125, 50.625, 1.677734375, 84.1875, 15.6640625, 52.90625, 1198 9.125, 28.9375, 12.5703125, 11.3984375, 86.9375, 64.5, 1199 71.3125, 76.375, 41.53125, 97.5625, 31.796875, 6.08984375, 1200 61.71875, 69.75, 38.90625, 52.28125, 22.3125, 99.0625 1201 ], 1202 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 1203 } 1204 }, 1205 'operators': [{ 1206 'name': 'reduceL1', 1207 'arguments': [ 1208 {'input': 'reduceL1Input'}, 1209 {'options': {'axes': [1, 3], 'keepDimensions': true}} 1210 ], 1211 'outputs': 'reduceL1Output' 1212 }], 1213 'expectedOutputs': { 1214 'reduceL1Output': { 1215 'data': [108.4375, 315.5, 359.5, 309], 1216 'descriptor': {shape: [2, 1, 2, 1], dataType: 'float16'} 1217 } 1218 } 1219 } 1220 }, 1221 { 1222 'name': 1223 'reduceL1 int32 4D tensor options.axes with options.keepDimensions=true', 1224 'graph': { 1225 'inputs': { 1226 'reduceL1Input': { 1227 'data': [ 1228 5, 50, 1, 84, 15, 52, 9, 28, 12, 11, 86, 64, 1229 71, 76, 41, 97, 31, 6, 61, 69, 38, 52, 22, 99 1230 ], 1231 'descriptor': {shape: [2, 2, 2, 3], dataType: 'int32'} 1232 } 1233 }, 1234 'operators': [{ 1235 'name': 'reduceL1', 1236 'arguments': [ 1237 {'input': 'reduceL1Input'}, 1238 {'options': {'axes': [1, 3], 'keepDimensions': true}} 1239 ], 1240 'outputs': 'reduceL1Output' 1241 }], 1242 'expectedOutputs': { 1243 'reduceL1Output': { 1244 'data': [105, 312, 356, 307], 1245 'descriptor': {shape: [2, 1, 2, 1], dataType: 'int32'} 1246 } 1247 } 1248 } 1249 }, 1250 { 1251 'name': 1252 'reduceL1 uint32 4D tensor options.axes with options.keepDimensions=false', 1253 'graph': { 1254 'inputs': { 1255 'reduceL1Input': { 1256 'data': [ 1257 5, 50, 1, 84, 15, 52, 9, 28, 12, 11, 86, 64, 1258 71, 76, 41, 97, 31, 6, 61, 69, 38, 52, 22, 99 1259 ], 1260 'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint32'} 1261 } 1262 }, 1263 'operators': [{ 1264 'name': 'reduceL1', 1265 'arguments': [ 1266 {'input': 'reduceL1Input'}, 1267 {'options': {'axes': [0, 2], 'keepDimensions': false}} 1268 ], 1269 'outputs': 'reduceL1Output' 1270 }], 1271 'expectedOutputs': { 1272 'reduceL1Output': { 1273 'data': [257, 172, 100, 133, 205, 213], 1274 'descriptor': {shape: [2, 3], dataType: 'uint32'} 1275 } 1276 } 1277 } 1278 } 1279 ]; 1280 1281 webnn_conformance_test( 1282 reduceL1Tests, buildAndExecuteGraph, getPrecisionTolerance);