reduce_sum.https.any.js (40448B)
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-reducesum 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 reduceSum(MLOperand input, optional MLReduceOptions options = {}); 21 22 const reduceSumTests = [ 23 { 24 'name': 'reduceSum float32 0D constant tensor default options', 25 'graph': { 26 'inputs': { 27 'reduceSumInput': { 28 'data': [69.6038589477539], 29 'descriptor': {shape: [], dataType: 'float32'}, 30 'constant': true 31 } 32 }, 33 'operators': [{ 34 'name': 'reduceSum', 35 'arguments': [{'input': 'reduceSumInput'}], 36 'outputs': 'reduceSumOutput' 37 }], 38 'expectedOutputs': { 39 'reduceSumOutput': { 40 'data': 69.6038589477539, 41 'descriptor': {shape: [], dataType: 'float32'} 42 } 43 } 44 } 45 }, 46 { 47 'name': 'reduceSum float32 0D tensor default options', 48 'graph': { 49 'inputs': { 50 'reduceSumInput': { 51 'data': [69.6038589477539], 52 'descriptor': {shape: [], dataType: 'float32'}, 53 'constant': false 54 } 55 }, 56 'operators': [{ 57 'name': 'reduceSum', 58 'arguments': [{'input': 'reduceSumInput'}], 59 'outputs': 'reduceSumOutput' 60 }], 61 'expectedOutputs': { 62 'reduceSumOutput': { 63 'data': 69.6038589477539, 64 'descriptor': {shape: [], dataType: 'float32'} 65 } 66 } 67 } 68 }, 69 { 70 'name': 'reduceSum float32 0D constant tensor empty axes', 71 'graph': { 72 'inputs': { 73 'reduceSumInput': { 74 'data': [69.6038589477539], 75 'descriptor': {shape: [], dataType: 'float32'}, 76 'constant': true 77 } 78 }, 79 'operators': [{ 80 'name': 'reduceSum', 81 'arguments': [{'input': 'reduceSumInput'}, {'options': {'axes': []}}], 82 'outputs': 'reduceSumOutput' 83 }], 84 'expectedOutputs': { 85 'reduceSumOutput': { 86 'data': 69.6038589477539, 87 'descriptor': {shape: [], dataType: 'float32'} 88 } 89 } 90 } 91 }, 92 { 93 'name': 'reduceSum float32 0D tensor empty axes', 94 'graph': { 95 'inputs': { 96 'reduceSumInput': { 97 'data': [69.6038589477539], 98 'descriptor': {shape: [], dataType: 'float32'}, 99 'constant': false 100 } 101 }, 102 'operators': [{ 103 'name': 'reduceSum', 104 'arguments': [{'input': 'reduceSumInput'}, {'options': {'axes': []}}], 105 'outputs': 'reduceSumOutput' 106 }], 107 'expectedOutputs': { 108 'reduceSumOutput': { 109 'data': 69.6038589477539, 110 'descriptor': {shape: [], dataType: 'float32'} 111 } 112 } 113 } 114 }, 115 { 116 'name': 'reduceSum float32 1D constant tensor empty axes', 117 'graph': { 118 'inputs': { 119 'reduceSumInput': { 120 'data': [69.6038589477539, 69.6038589477538], 121 'descriptor': {shape: [2], dataType: 'float32'}, 122 'constant': true 123 } 124 }, 125 'operators': [{ 126 'name': 'reduceSum', 127 'arguments': [{'input': 'reduceSumInput'}, {'options': {'axes': []}}], 128 'outputs': 'reduceSumOutput' 129 }], 130 'expectedOutputs': { 131 'reduceSumOutput': { 132 'data': [69.6038589477539, 69.6038589477538], 133 'descriptor': {shape: [2], dataType: 'float32'} 134 } 135 } 136 } 137 }, 138 { 139 'name': 'reduceSum float32 1D constant tensor all positive default options', 140 'graph': { 141 'inputs': { 142 'reduceSumInput': { 143 'data': [ 144 69.6038589477539, 99.17485809326172, 32.78234100341797, 145 8.881362915039062, 16.094295501708984, 11.80689525604248, 146 32.64223861694336, 43.99836349487305, 77.01776885986328, 147 79.79425811767578, 45.00794982910156, 24.397796630859375, 148 57.502685546875, 57.60173034667969, 80.26985931396484, 149 43.65110778808594, 87.5036849975586, 94.50203704833984, 150 35.54289627075195, 42.856414794921875, 88.58631896972656, 151 98.85772705078125, 25.626853942871094, 60.1761360168457 152 ], 153 'descriptor': {shape: [24], dataType: 'float32'}, 154 'constant': true 155 } 156 }, 157 'operators': [{ 158 'name': 'reduceSum', 159 'arguments': [{'input': 'reduceSumInput'}], 160 'outputs': 'reduceSumOutput' 161 }], 162 'expectedOutputs': { 163 'reduceSumOutput': { 164 'data': 1313.87939453125, 165 'descriptor': {shape: [], dataType: 'float32'} 166 } 167 } 168 } 169 }, 170 { 171 'name': 'reduceSum float32 1D tensor all positive default options', 172 'graph': { 173 'inputs': { 174 'reduceSumInput': { 175 'data': [ 176 69.6038589477539, 99.17485809326172, 32.78234100341797, 177 8.881362915039062, 16.094295501708984, 11.80689525604248, 178 32.64223861694336, 43.99836349487305, 77.01776885986328, 179 79.79425811767578, 45.00794982910156, 24.397796630859375, 180 57.502685546875, 57.60173034667969, 80.26985931396484, 181 43.65110778808594, 87.5036849975586, 94.50203704833984, 182 35.54289627075195, 42.856414794921875, 88.58631896972656, 183 98.85772705078125, 25.626853942871094, 60.1761360168457 184 ], 185 'descriptor': {shape: [24], dataType: 'float32'} 186 } 187 }, 188 'operators': [{ 189 'name': 'reduceSum', 190 'arguments': [{'input': 'reduceSumInput'}], 191 'outputs': 'reduceSumOutput' 192 }], 193 'expectedOutputs': { 194 'reduceSumOutput': { 195 'data': 1313.87939453125, 196 'descriptor': {shape: [], dataType: 'float32'} 197 } 198 } 199 } 200 }, 201 { 202 'name': 'reduceSum float32 1D tensor all negative default options', 203 'graph': { 204 'inputs': { 205 'reduceSumInput': { 206 'data': [ 207 -51.77016830444336, -34.46467971801758, -40.98350524902344, 208 -83.34922790527344, -67.67525482177734, -18.7031192779541, 209 -20.28106117248535, -20.12305450439453, -83.63451385498047, 210 -23.651084899902344, -10.208438873291016, -36.2129020690918, 211 -76.26201629638672, -9.094745635986328, -53.889339447021484, 212 -67.52340698242188, -71.14580535888672, -82.04484558105469, 213 -96.29924774169922, -68.46700286865234, -26.107192993164062, 214 -68.0182113647461, -4.8330769538879395, -48.900699615478516 215 ], 216 'descriptor': {shape: [24], dataType: 'float32'} 217 } 218 }, 219 'operators': [{ 220 'name': 'reduceSum', 221 'arguments': [{'input': 'reduceSumInput'}], 222 'outputs': 'reduceSumOutput' 223 }], 224 'expectedOutputs': { 225 'reduceSumOutput': { 226 'data': -1163.642578125, 227 'descriptor': {shape: [], dataType: 'float32'} 228 } 229 } 230 } 231 }, 232 { 233 'name': 'reduceSum float32 1D tensor all positive integers default options', 234 'graph': { 235 'inputs': { 236 'reduceSumInput': { 237 'data': [ 238 56, 90, 67, 33, 20, 58, 22, 15, 86, 79, 59, 99, 239 16, 95, 67, 11, 60, 89, 50, 57, 77, 89, 10, 2 240 ], 241 'descriptor': {shape: [24], dataType: 'float32'} 242 } 243 }, 244 'operators': [{ 245 'name': 'reduceSum', 246 'arguments': [{'input': 'reduceSumInput'}], 247 'outputs': 'reduceSumOutput' 248 }], 249 'expectedOutputs': { 250 'reduceSumOutput': 251 {'data': 1307, 'descriptor': {shape: [], dataType: 'float32'}} 252 } 253 } 254 }, 255 { 256 'name': 'reduceSum float32 1D tensor all negative integers default options', 257 'graph': { 258 'inputs': { 259 'reduceSumInput': { 260 'data': [ 261 -55, -36, -74, -17, -67, -95, -3, -67, -95, -13, -45, -9, 262 -33, -98, -86, -11, -70, -44, -31, -68, -79, -24, -60, -36 263 ], 264 'descriptor': {shape: [24], dataType: 'float32'} 265 } 266 }, 267 'operators': [{ 268 'name': 'reduceSum', 269 'arguments': [{'input': 'reduceSumInput'}], 270 'outputs': 'reduceSumOutput' 271 }], 272 'expectedOutputs': { 273 'reduceSumOutput': 274 {'data': -1216, 'descriptor': {shape: [], dataType: 'float32'}} 275 } 276 } 277 }, 278 { 279 'name': 'reduceSum float32 2D tensor default options', 280 'graph': { 281 'inputs': { 282 'reduceSumInput': { 283 'data': [ 284 69.6038589477539, 99.17485809326172, 32.78234100341797, 285 8.881362915039062, 16.094295501708984, 11.80689525604248, 286 32.64223861694336, 43.99836349487305, 77.01776885986328, 287 79.79425811767578, 45.00794982910156, 24.397796630859375, 288 57.502685546875, 57.60173034667969, 80.26985931396484, 289 43.65110778808594, 87.5036849975586, 94.50203704833984, 290 35.54289627075195, 42.856414794921875, 88.58631896972656, 291 98.85772705078125, 25.626853942871094, 60.1761360168457 292 ], 293 'descriptor': {shape: [4, 6], dataType: 'float32'} 294 } 295 }, 296 'operators': [{ 297 'name': 'reduceSum', 298 'arguments': [{'input': 'reduceSumInput'}], 299 'outputs': 'reduceSumOutput' 300 }], 301 'expectedOutputs': { 302 'reduceSumOutput': { 303 'data': 1313.87939453125, 304 'descriptor': {shape: [], dataType: 'float32'} 305 } 306 } 307 } 308 }, 309 { 310 'name': 'reduceSum float32 3D tensor default options', 311 'graph': { 312 'inputs': { 313 'reduceSumInput': { 314 'data': [ 315 69.6038589477539, 99.17485809326172, 32.78234100341797, 316 8.881362915039062, 16.094295501708984, 11.80689525604248, 317 32.64223861694336, 43.99836349487305, 77.01776885986328, 318 79.79425811767578, 45.00794982910156, 24.397796630859375, 319 57.502685546875, 57.60173034667969, 80.26985931396484, 320 43.65110778808594, 87.5036849975586, 94.50203704833984, 321 35.54289627075195, 42.856414794921875, 88.58631896972656, 322 98.85772705078125, 25.626853942871094, 60.1761360168457 323 ], 324 'descriptor': {shape: [2, 3, 4], dataType: 'float32'} 325 } 326 }, 327 'operators': [{ 328 'name': 'reduceSum', 329 'arguments': [{'input': 'reduceSumInput'}], 330 'outputs': 'reduceSumOutput' 331 }], 332 'expectedOutputs': { 333 'reduceSumOutput': { 334 'data': 1313.87939453125, 335 'descriptor': {shape: [], dataType: 'float32'} 336 } 337 } 338 } 339 }, 340 { 341 'name': 'reduceSum float32 4D tensor default options', 342 'graph': { 343 'inputs': { 344 'reduceSumInput': { 345 'data': [ 346 69.6038589477539, 99.17485809326172, 32.78234100341797, 347 8.881362915039062, 16.094295501708984, 11.80689525604248, 348 32.64223861694336, 43.99836349487305, 77.01776885986328, 349 79.79425811767578, 45.00794982910156, 24.397796630859375, 350 57.502685546875, 57.60173034667969, 80.26985931396484, 351 43.65110778808594, 87.5036849975586, 94.50203704833984, 352 35.54289627075195, 42.856414794921875, 88.58631896972656, 353 98.85772705078125, 25.626853942871094, 60.1761360168457 354 ], 355 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 356 } 357 }, 358 'operators': [{ 359 'name': 'reduceSum', 360 'arguments': [{'input': 'reduceSumInput'}], 361 'outputs': 'reduceSumOutput' 362 }], 363 'expectedOutputs': { 364 'reduceSumOutput': { 365 'data': 1313.87939453125, 366 'descriptor': {shape: [], dataType: 'float32'} 367 } 368 } 369 } 370 }, 371 { 372 'name': 'reduceSum float32 5D tensor default options', 373 'graph': { 374 'inputs': { 375 'reduceSumInput': { 376 'data': [ 377 69.6038589477539, 99.17485809326172, 32.78234100341797, 378 8.881362915039062, 16.094295501708984, 11.80689525604248, 379 32.64223861694336, 43.99836349487305, 77.01776885986328, 380 79.79425811767578, 45.00794982910156, 24.397796630859375, 381 57.502685546875, 57.60173034667969, 80.26985931396484, 382 43.65110778808594, 87.5036849975586, 94.50203704833984, 383 35.54289627075195, 42.856414794921875, 88.58631896972656, 384 98.85772705078125, 25.626853942871094, 60.1761360168457 385 ], 386 'descriptor': {shape: [2, 1, 4, 1, 3], dataType: 'float32'} 387 } 388 }, 389 'operators': [{ 390 'name': 'reduceSum', 391 'arguments': [{'input': 'reduceSumInput'}], 392 'outputs': 'reduceSumOutput' 393 }], 394 'expectedOutputs': { 395 'reduceSumOutput': { 396 'data': 1313.87939453125, 397 'descriptor': {shape: [], dataType: 'float32'} 398 } 399 } 400 } 401 }, 402 { 403 'name': 'reduceSum float32 3D tensor options.axes', 404 'graph': { 405 'inputs': { 406 'reduceSumInput': { 407 'data': [ 408 69.6038589477539, 99.17485809326172, 32.78234100341797, 409 8.881362915039062, 16.094295501708984, 11.80689525604248, 410 32.64223861694336, 43.99836349487305, 77.01776885986328, 411 79.79425811767578, 45.00794982910156, 24.397796630859375, 412 57.502685546875, 57.60173034667969, 80.26985931396484, 413 43.65110778808594, 87.5036849975586, 94.50203704833984, 414 35.54289627075195, 42.856414794921875, 88.58631896972656, 415 98.85772705078125, 25.626853942871094, 60.1761360168457 416 ], 417 'descriptor': {shape: [2, 3, 4], dataType: 'float32'} 418 } 419 }, 420 'operators': [{ 421 'name': 'reduceSum', 422 'arguments': [{'input': 'reduceSumInput'}, {'options': {'axes': [2]}}], 423 'outputs': 'reduceSumOutput' 424 }], 425 'expectedOutputs': { 426 'reduceSumOutput': { 427 'data': [ 428 210.44241333007812, 104.54179382324219, 226.2177734375, 429 239.025390625, 260.405029296875, 273.2470397949219 430 ], 431 'descriptor': {shape: [2, 3], dataType: 'float32'} 432 } 433 } 434 } 435 }, 436 { 437 'name': 'reduceSum float32 4D tensor options.axes', 438 'graph': { 439 'inputs': { 440 'reduceSumInput': { 441 'data': [ 442 69.6038589477539, 99.17485809326172, 32.78234100341797, 443 8.881362915039062, 16.094295501708984, 11.80689525604248, 444 32.64223861694336, 43.99836349487305, 77.01776885986328, 445 79.79425811767578, 45.00794982910156, 24.397796630859375, 446 57.502685546875, 57.60173034667969, 80.26985931396484, 447 43.65110778808594, 87.5036849975586, 94.50203704833984, 448 35.54289627075195, 42.856414794921875, 88.58631896972656, 449 98.85772705078125, 25.626853942871094, 60.1761360168457 450 ], 451 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 452 } 453 }, 454 'operators': [{ 455 'name': 'reduceSum', 456 'arguments': 457 [{'input': 'reduceSumInput'}, {'options': {'axes': [0, 2]}}], 458 'outputs': 'reduceSumOutput' 459 }], 460 'expectedOutputs': { 461 'reduceSumOutput': { 462 'data': [ 463 179.63900756835938, 260.37457275390625, 219.3611297607422, 464 246.83712768554688, 157.4895782470703, 250.1780242919922 465 ], 466 'descriptor': {shape: [2, 3], dataType: 'float32'} 467 } 468 } 469 } 470 }, 471 { 472 'name': 'reduceSum float32 3D tensor options.keepDimensions=false', 473 'graph': { 474 'inputs': { 475 'reduceSumInput': { 476 'data': [ 477 69.6038589477539, 99.17485809326172, 32.78234100341797, 478 8.881362915039062, 16.094295501708984, 11.80689525604248, 479 32.64223861694336, 43.99836349487305, 77.01776885986328, 480 79.79425811767578, 45.00794982910156, 24.397796630859375, 481 57.502685546875, 57.60173034667969, 80.26985931396484, 482 43.65110778808594, 87.5036849975586, 94.50203704833984, 483 35.54289627075195, 42.856414794921875, 88.58631896972656, 484 98.85772705078125, 25.626853942871094, 60.1761360168457 485 ], 486 'descriptor': {shape: [2, 3, 4], dataType: 'float32'} 487 } 488 }, 489 'operators': [{ 490 'name': 'reduceSum', 491 'arguments': [ 492 {'input': 'reduceSumInput'}, {'options': {'keepDimensions': false}} 493 ], 494 'outputs': 'reduceSumOutput' 495 }], 496 'expectedOutputs': { 497 'reduceSumOutput': { 498 'data': 1313.87939453125, 499 'descriptor': {shape: [], dataType: 'float32'} 500 } 501 } 502 } 503 }, 504 { 505 'name': 'reduceSum float32 3D tensor options.keepDimensions=true', 506 'graph': { 507 'inputs': { 508 'reduceSumInput': { 509 'data': [ 510 69.6038589477539, 99.17485809326172, 32.78234100341797, 511 8.881362915039062, 16.094295501708984, 11.80689525604248, 512 32.64223861694336, 43.99836349487305, 77.01776885986328, 513 79.79425811767578, 45.00794982910156, 24.397796630859375, 514 57.502685546875, 57.60173034667969, 80.26985931396484, 515 43.65110778808594, 87.5036849975586, 94.50203704833984, 516 35.54289627075195, 42.856414794921875, 88.58631896972656, 517 98.85772705078125, 25.626853942871094, 60.1761360168457 518 ], 519 'descriptor': {shape: [2, 3, 4], dataType: 'float32'} 520 } 521 }, 522 'operators': [{ 523 'name': 'reduceSum', 524 'arguments': [ 525 {'input': 'reduceSumInput'}, {'options': {'keepDimensions': true}} 526 ], 527 'outputs': 'reduceSumOutput' 528 }], 529 'expectedOutputs': { 530 'reduceSumOutput': { 531 'data': [1313.87939453125], 532 'descriptor': {shape: [1, 1, 1], dataType: 'float32'} 533 } 534 } 535 } 536 }, 537 { 538 'name': 'reduceSum float32 4D tensor options.keepDimensions=false', 539 'graph': { 540 'inputs': { 541 'reduceSumInput': { 542 'data': [ 543 69.6038589477539, 99.17485809326172, 32.78234100341797, 544 8.881362915039062, 16.094295501708984, 11.80689525604248, 545 32.64223861694336, 43.99836349487305, 77.01776885986328, 546 79.79425811767578, 45.00794982910156, 24.397796630859375, 547 57.502685546875, 57.60173034667969, 80.26985931396484, 548 43.65110778808594, 87.5036849975586, 94.50203704833984, 549 35.54289627075195, 42.856414794921875, 88.58631896972656, 550 98.85772705078125, 25.626853942871094, 60.1761360168457 551 ], 552 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 553 } 554 }, 555 'operators': [{ 556 'name': 'reduceSum', 557 'arguments': [ 558 {'input': 'reduceSumInput'}, {'options': {'keepDimensions': false}} 559 ], 560 'outputs': 'reduceSumOutput' 561 }], 562 'expectedOutputs': { 563 'reduceSumOutput': { 564 'data': 1313.87939453125, 565 'descriptor': {shape: [], dataType: 'float32'} 566 } 567 } 568 } 569 }, 570 { 571 'name': 'reduceSum float32 4D tensor options.keepDimensions=true', 572 'graph': { 573 'inputs': { 574 'reduceSumInput': { 575 'data': [ 576 69.6038589477539, 99.17485809326172, 32.78234100341797, 577 8.881362915039062, 16.094295501708984, 11.80689525604248, 578 32.64223861694336, 43.99836349487305, 77.01776885986328, 579 79.79425811767578, 45.00794982910156, 24.397796630859375, 580 57.502685546875, 57.60173034667969, 80.26985931396484, 581 43.65110778808594, 87.5036849975586, 94.50203704833984, 582 35.54289627075195, 42.856414794921875, 88.58631896972656, 583 98.85772705078125, 25.626853942871094, 60.1761360168457 584 ], 585 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 586 } 587 }, 588 'operators': [{ 589 'name': 'reduceSum', 590 'arguments': [ 591 {'input': 'reduceSumInput'}, {'options': {'keepDimensions': true}} 592 ], 593 'outputs': 'reduceSumOutput' 594 }], 595 'expectedOutputs': { 596 'reduceSumOutput': { 597 'data': [1313.87939453125], 598 'descriptor': {shape: [1, 1, 1, 1], dataType: 'float32'} 599 } 600 } 601 } 602 }, 603 { 604 'name': 605 'reduceSum float32 4D tensor options.axes with options.keepDimensions=false', 606 'graph': { 607 'inputs': { 608 'reduceSumInput': { 609 'data': [ 610 69.6038589477539, 99.17485809326172, 32.78234100341797, 611 8.881362915039062, 16.094295501708984, 11.80689525604248, 612 32.64223861694336, 43.99836349487305, 77.01776885986328, 613 79.79425811767578, 45.00794982910156, 24.397796630859375, 614 57.502685546875, 57.60173034667969, 80.26985931396484, 615 43.65110778808594, 87.5036849975586, 94.50203704833984, 616 35.54289627075195, 42.856414794921875, 88.58631896972656, 617 98.85772705078125, 25.626853942871094, 60.1761360168457 618 ], 619 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 620 } 621 }, 622 'operators': [{ 623 'name': 'reduceSum', 624 'arguments': [ 625 {'input': 'reduceSumInput'}, 626 {'options': {'axes': [1, 3], 'keepDimensions': false}} 627 ], 628 'outputs': 'reduceSumOutput' 629 }], 630 'expectedOutputs': { 631 'reduceSumOutput': { 632 'data': [ 633 355.21942138671875, 185.98255920410156, 362.3598937988281, 634 410.3175354003906 635 ], 636 'descriptor': {shape: [2, 2], dataType: 'float32'} 637 } 638 } 639 } 640 }, 641 { 642 'name': 643 'reduceSum float32 4D tensor options.axes with options.keepDimensions=true', 644 'graph': { 645 'inputs': { 646 'reduceSumInput': { 647 'data': [ 648 69.6038589477539, 99.17485809326172, 32.78234100341797, 649 8.881362915039062, 16.094295501708984, 11.80689525604248, 650 32.64223861694336, 43.99836349487305, 77.01776885986328, 651 79.79425811767578, 45.00794982910156, 24.397796630859375, 652 57.502685546875, 57.60173034667969, 80.26985931396484, 653 43.65110778808594, 87.5036849975586, 94.50203704833984, 654 35.54289627075195, 42.856414794921875, 88.58631896972656, 655 98.85772705078125, 25.626853942871094, 60.1761360168457 656 ], 657 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 658 } 659 }, 660 'operators': [{ 661 'name': 'reduceSum', 662 'arguments': [ 663 {'input': 'reduceSumInput'}, 664 {'options': {'axes': [1, 3], 'keepDimensions': true}} 665 ], 666 'outputs': 'reduceSumOutput' 667 }], 668 'expectedOutputs': { 669 'reduceSumOutput': { 670 'data': [ 671 355.21942138671875, 185.98255920410156, 362.3598937988281, 672 410.3175354003906 673 ], 674 'descriptor': {shape: [2, 1, 2, 1], dataType: 'float32'} 675 } 676 } 677 } 678 }, 679 680 // float16 tests 681 { 682 'name': 'reduceSum float16 0D constant tensor default options', 683 'graph': { 684 'inputs': { 685 'reduceSumInput': { 686 'data': [69.625], 687 'descriptor': {shape: [], dataType: 'float16'}, 688 'constant': true 689 } 690 }, 691 'operators': [{ 692 'name': 'reduceSum', 693 'arguments': [{'input': 'reduceSumInput'}], 694 'outputs': 'reduceSumOutput' 695 }], 696 'expectedOutputs': { 697 'reduceSumOutput': 698 {'data': [69.625], 'descriptor': {shape: [], dataType: 'float16'}} 699 } 700 } 701 }, 702 { 703 'name': 'reduceSum float16 0D tensor default options', 704 'graph': { 705 'inputs': { 706 'reduceSumInput': { 707 'data': [69.625], 708 'descriptor': {shape: [], dataType: 'float16'}, 709 'constant': false 710 } 711 }, 712 'operators': [{ 713 'name': 'reduceSum', 714 'arguments': [{'input': 'reduceSumInput'}], 715 'outputs': 'reduceSumOutput' 716 }], 717 'expectedOutputs': { 718 'reduceSumOutput': 719 {'data': [69.625], 'descriptor': {shape: [], dataType: 'float16'}} 720 } 721 } 722 }, 723 { 724 'name': 'reduceSum float16 0D constant tensor empty axes', 725 'graph': { 726 'inputs': { 727 'reduceSumInput': { 728 'data': [69.625], 729 'descriptor': {shape: [], dataType: 'float16'}, 730 'constant': true 731 } 732 }, 733 'operators': [{ 734 'name': 'reduceSum', 735 'arguments': [{'input': 'reduceSumInput'}, {'options': {'axes': []}}], 736 'outputs': 'reduceSumOutput' 737 }], 738 'expectedOutputs': { 739 'reduceSumOutput': 740 {'data': [69.625], 'descriptor': {shape: [], dataType: 'float16'}} 741 } 742 } 743 }, 744 { 745 'name': 'reduceSum float16 0D tensor empty axes', 746 'graph': { 747 'inputs': { 748 'reduceSumInput': { 749 'data': [69.625], 750 'descriptor': {shape: [], dataType: 'float16'}, 751 'constant': false 752 } 753 }, 754 'operators': [{ 755 'name': 'reduceSum', 756 'arguments': [{'input': 'reduceSumInput'}, {'options': {'axes': []}}], 757 'outputs': 'reduceSumOutput' 758 }], 759 'expectedOutputs': { 760 'reduceSumOutput': 761 {'data': [69.625], 'descriptor': {shape: [], dataType: 'float16'}} 762 } 763 } 764 }, 765 { 766 'name': 'reduceSum float16 1D constant tensor all positive default options', 767 'graph': { 768 'inputs': { 769 'reduceSumInput': { 770 'data': [ 771 69.625, 99.1875, 32.78125, 8.8828125, 16.09375, 11.8046875, 772 32.65625, 44, 77, 79.8125, 45, 24.390625, 773 57.5, 57.59375, 80.25, 43.65625, 87.5, 94.5, 774 35.53125, 42.84375, 88.5625, 98.875, 25.625, 60.1875 775 ], 776 'descriptor': {shape: [24], dataType: 'float16'}, 777 'constant': true 778 } 779 }, 780 'operators': [{ 781 'name': 'reduceSum', 782 'arguments': [{'input': 'reduceSumInput'}], 783 'outputs': 'reduceSumOutput' 784 }], 785 'expectedOutputs': { 786 'reduceSumOutput': 787 {'data': [1314], 'descriptor': {shape: [], dataType: 'float16'}} 788 } 789 } 790 }, 791 { 792 'name': 'reduceSum float16 1D tensor all positive default options', 793 'graph': { 794 'inputs': { 795 'reduceSumInput': { 796 'data': [ 797 69.625, 99.1875, 32.78125, 8.8828125, 16.09375, 11.8046875, 798 32.65625, 44, 77, 79.8125, 45, 24.390625, 799 57.5, 57.59375, 80.25, 43.65625, 87.5, 94.5, 800 35.53125, 42.84375, 88.5625, 98.875, 25.625, 60.1875 801 ], 802 'descriptor': {shape: [24], dataType: 'float16'} 803 } 804 }, 805 'operators': [{ 806 'name': 'reduceSum', 807 'arguments': [{'input': 'reduceSumInput'}], 808 'outputs': 'reduceSumOutput' 809 }], 810 'expectedOutputs': { 811 'reduceSumOutput': 812 {'data': [1314], 'descriptor': {shape: [], dataType: 'float16'}} 813 } 814 } 815 }, 816 { 817 'name': 'reduceSum float16 1D tensor all negative default options', 818 'graph': { 819 'inputs': { 820 'reduceSumInput': { 821 'data': [ 822 -51.78125, -34.46875, -40.96875, -83.375, -67.6875, 823 -18.703125, -20.28125, -20.125, -83.625, -23.65625, 824 -10.2109375, -36.21875, -76.25, -9.09375, -53.875, 825 -67.5, -71.125, -82.0625, -96.3125, -68.4375, 826 -26.109375, -68, -4.83203125, -48.90625 827 ], 828 'descriptor': {shape: [24], dataType: 'float16'} 829 } 830 }, 831 'operators': [{ 832 'name': 'reduceSum', 833 'arguments': [{'input': 'reduceSumInput'}], 834 'outputs': 'reduceSumOutput' 835 }], 836 'expectedOutputs': { 837 'reduceSumOutput': 838 {'data': [-1164], 'descriptor': {shape: [], dataType: 'float16'}} 839 } 840 } 841 }, 842 { 843 'name': 'reduceSum float16 1D tensor all positive integers default options', 844 'graph': { 845 'inputs': { 846 'reduceSumInput': { 847 'data': [ 848 56, 90, 67, 33, 20, 58, 22, 15, 86, 79, 59, 99, 849 16, 95, 67, 11, 60, 89, 50, 57, 77, 89, 10, 2 850 ], 851 'descriptor': {shape: [24], dataType: 'float16'} 852 } 853 }, 854 'operators': [{ 855 'name': 'reduceSum', 856 'arguments': [{'input': 'reduceSumInput'}], 857 'outputs': 'reduceSumOutput' 858 }], 859 'expectedOutputs': { 860 'reduceSumOutput': 861 {'data': [1307], 'descriptor': {shape: [], dataType: 'float16'}} 862 } 863 } 864 }, 865 { 866 'name': 'reduceSum float16 1D tensor all negative integers default options', 867 'graph': { 868 'inputs': { 869 'reduceSumInput': { 870 'data': [ 871 -55, -36, -74, -17, -67, -95, -3, -67, -95, -13, -45, -9, 872 -33, -98, -86, -11, -70, -44, -31, -68, -79, -24, -60, -36 873 ], 874 'descriptor': {shape: [24], dataType: 'float16'} 875 } 876 }, 877 'operators': [{ 878 'name': 'reduceSum', 879 'arguments': [{'input': 'reduceSumInput'}], 880 'outputs': 'reduceSumOutput' 881 }], 882 'expectedOutputs': { 883 'reduceSumOutput': 884 {'data': [-1216], 'descriptor': {shape: [], dataType: 'float16'}} 885 } 886 } 887 }, 888 { 889 'name': 'reduceSum float16 2D tensor default options', 890 'graph': { 891 'inputs': { 892 'reduceSumInput': { 893 'data': [ 894 69.625, 99.1875, 32.78125, 8.8828125, 16.09375, 11.8046875, 895 32.65625, 44, 77, 79.8125, 45, 24.390625, 896 57.5, 57.59375, 80.25, 43.65625, 87.5, 94.5, 897 35.53125, 42.84375, 88.5625, 98.875, 25.625, 60.1875 898 ], 899 'descriptor': {shape: [4, 6], dataType: 'float16'} 900 } 901 }, 902 'operators': [{ 903 'name': 'reduceSum', 904 'arguments': [{'input': 'reduceSumInput'}], 905 'outputs': 'reduceSumOutput' 906 }], 907 'expectedOutputs': { 908 'reduceSumOutput': 909 {'data': [1314], 'descriptor': {shape: [], dataType: 'float16'}} 910 } 911 } 912 }, 913 { 914 'name': 'reduceSum float16 3D tensor default options', 915 'graph': { 916 'inputs': { 917 'reduceSumInput': { 918 'data': [ 919 69.625, 99.1875, 32.78125, 8.8828125, 16.09375, 11.8046875, 920 32.65625, 44, 77, 79.8125, 45, 24.390625, 921 57.5, 57.59375, 80.25, 43.65625, 87.5, 94.5, 922 35.53125, 42.84375, 88.5625, 98.875, 25.625, 60.1875 923 ], 924 'descriptor': {shape: [2, 3, 4], dataType: 'float16'} 925 } 926 }, 927 'operators': [{ 928 'name': 'reduceSum', 929 'arguments': [{'input': 'reduceSumInput'}], 930 'outputs': 'reduceSumOutput' 931 }], 932 'expectedOutputs': { 933 'reduceSumOutput': 934 {'data': [1314], 'descriptor': {shape: [], dataType: 'float16'}} 935 } 936 } 937 }, 938 { 939 'name': 'reduceSum float16 4D tensor default options', 940 'graph': { 941 'inputs': { 942 'reduceSumInput': { 943 'data': [ 944 69.625, 99.1875, 32.78125, 8.8828125, 16.09375, 11.8046875, 945 32.65625, 44, 77, 79.8125, 45, 24.390625, 946 57.5, 57.59375, 80.25, 43.65625, 87.5, 94.5, 947 35.53125, 42.84375, 88.5625, 98.875, 25.625, 60.1875 948 ], 949 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 950 } 951 }, 952 'operators': [{ 953 'name': 'reduceSum', 954 'arguments': [{'input': 'reduceSumInput'}], 955 'outputs': 'reduceSumOutput' 956 }], 957 'expectedOutputs': { 958 'reduceSumOutput': 959 {'data': [1314], 'descriptor': {shape: [], dataType: 'float16'}} 960 } 961 } 962 }, 963 { 964 'name': 'reduceSum float16 5D tensor default options', 965 'graph': { 966 'inputs': { 967 'reduceSumInput': { 968 'data': [ 969 69.625, 99.1875, 32.78125, 8.8828125, 16.09375, 11.8046875, 970 32.65625, 44, 77, 79.8125, 45, 24.390625, 971 57.5, 57.59375, 80.25, 43.65625, 87.5, 94.5, 972 35.53125, 42.84375, 88.5625, 98.875, 25.625, 60.1875 973 ], 974 'descriptor': {shape: [2, 1, 4, 1, 3], dataType: 'float16'} 975 } 976 }, 977 'operators': [{ 978 'name': 'reduceSum', 979 'arguments': [{'input': 'reduceSumInput'}], 980 'outputs': 'reduceSumOutput' 981 }], 982 'expectedOutputs': { 983 'reduceSumOutput': 984 {'data': [1314], 'descriptor': {shape: [], dataType: 'float16'}} 985 } 986 } 987 }, 988 { 989 'name': 'reduceSum float16 3D tensor options.axes', 990 'graph': { 991 'inputs': { 992 'reduceSumInput': { 993 'data': [ 994 69.625, 99.1875, 32.78125, 8.8828125, 16.09375, 11.8046875, 995 32.65625, 44, 77, 79.8125, 45, 24.390625, 996 57.5, 57.59375, 80.25, 43.65625, 87.5, 94.5, 997 35.53125, 42.84375, 88.5625, 98.875, 25.625, 60.1875 998 ], 999 'descriptor': {shape: [2, 3, 4], dataType: 'float16'} 1000 } 1001 }, 1002 'operators': [{ 1003 'name': 'reduceSum', 1004 'arguments': [{'input': 'reduceSumInput'}, {'options': {'axes': [2]}}], 1005 'outputs': 'reduceSumOutput' 1006 }], 1007 'expectedOutputs': { 1008 'reduceSumOutput': { 1009 'data': [210.5, 104.5625, 226.25, 239, 260.5, 273.25], 1010 'descriptor': {shape: [2, 3], dataType: 'float16'} 1011 } 1012 } 1013 } 1014 }, 1015 { 1016 'name': 'reduceSum float16 4D tensor options.axes', 1017 'graph': { 1018 'inputs': { 1019 'reduceSumInput': { 1020 'data': [ 1021 69.625, 99.1875, 32.78125, 8.8828125, 16.09375, 11.8046875, 1022 32.65625, 44, 77, 79.8125, 45, 24.390625, 1023 57.5, 57.59375, 80.25, 43.65625, 87.5, 94.5, 1024 35.53125, 42.84375, 88.5625, 98.875, 25.625, 60.1875 1025 ], 1026 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 1027 } 1028 }, 1029 'operators': [{ 1030 'name': 'reduceSum', 1031 'arguments': 1032 [{'input': 'reduceSumInput'}, {'options': {'axes': [0, 2]}}], 1033 'outputs': 'reduceSumOutput' 1034 }], 1035 'expectedOutputs': { 1036 'reduceSumOutput': { 1037 'data': [179.625, 260.5, 219.375, 246.875, 157.5, 250.125], 1038 'descriptor': {shape: [2, 3], dataType: 'float16'} 1039 } 1040 } 1041 } 1042 }, 1043 { 1044 'name': 'reduceSum float16 3D tensor options.keepDimensions=false', 1045 'graph': { 1046 'inputs': { 1047 'reduceSumInput': { 1048 'data': [ 1049 69.625, 99.1875, 32.78125, 8.8828125, 16.09375, 11.8046875, 1050 32.65625, 44, 77, 79.8125, 45, 24.390625, 1051 57.5, 57.59375, 80.25, 43.65625, 87.5, 94.5, 1052 35.53125, 42.84375, 88.5625, 98.875, 25.625, 60.1875 1053 ], 1054 'descriptor': {shape: [2, 3, 4], dataType: 'float16'} 1055 } 1056 }, 1057 'operators': [{ 1058 'name': 'reduceSum', 1059 'arguments': [ 1060 {'input': 'reduceSumInput'}, {'options': {'keepDimensions': false}} 1061 ], 1062 'outputs': 'reduceSumOutput' 1063 }], 1064 'expectedOutputs': { 1065 'reduceSumOutput': 1066 {'data': [1314], 'descriptor': {shape: [], dataType: 'float16'}} 1067 } 1068 } 1069 }, 1070 { 1071 'name': 'reduceSum float16 3D tensor options.keepDimensions=true', 1072 'graph': { 1073 'inputs': { 1074 'reduceSumInput': { 1075 'data': [ 1076 69.625, 99.1875, 32.78125, 8.8828125, 16.09375, 11.8046875, 1077 32.65625, 44, 77, 79.8125, 45, 24.390625, 1078 57.5, 57.59375, 80.25, 43.65625, 87.5, 94.5, 1079 35.53125, 42.84375, 88.5625, 98.875, 25.625, 60.1875 1080 ], 1081 'descriptor': {shape: [2, 3, 4], dataType: 'float16'} 1082 } 1083 }, 1084 'operators': [{ 1085 'name': 'reduceSum', 1086 'arguments': [ 1087 {'input': 'reduceSumInput'}, {'options': {'keepDimensions': true}} 1088 ], 1089 'outputs': 'reduceSumOutput' 1090 }], 1091 'expectedOutputs': { 1092 'reduceSumOutput': { 1093 'data': [1314], 1094 'descriptor': {shape: [1, 1, 1], dataType: 'float16'} 1095 } 1096 } 1097 } 1098 }, 1099 { 1100 'name': 'reduceSum float16 4D tensor options.keepDimensions=false', 1101 'graph': { 1102 'inputs': { 1103 'reduceSumInput': { 1104 'data': [ 1105 69.625, 99.1875, 32.78125, 8.8828125, 16.09375, 11.8046875, 1106 32.65625, 44, 77, 79.8125, 45, 24.390625, 1107 57.5, 57.59375, 80.25, 43.65625, 87.5, 94.5, 1108 35.53125, 42.84375, 88.5625, 98.875, 25.625, 60.1875 1109 ], 1110 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 1111 } 1112 }, 1113 'operators': [{ 1114 'name': 'reduceSum', 1115 'arguments': [ 1116 {'input': 'reduceSumInput'}, {'options': {'keepDimensions': false}} 1117 ], 1118 'outputs': 'reduceSumOutput' 1119 }], 1120 'expectedOutputs': { 1121 'reduceSumOutput': 1122 {'data': [1314], 'descriptor': {shape: [], dataType: 'float16'}} 1123 } 1124 } 1125 }, 1126 { 1127 'name': 'reduceSum float16 4D tensor options.keepDimensions=true', 1128 'graph': { 1129 'inputs': { 1130 'reduceSumInput': { 1131 'data': [ 1132 69.625, 99.1875, 32.78125, 8.8828125, 16.09375, 11.8046875, 1133 32.65625, 44, 77, 79.8125, 45, 24.390625, 1134 57.5, 57.59375, 80.25, 43.65625, 87.5, 94.5, 1135 35.53125, 42.84375, 88.5625, 98.875, 25.625, 60.1875 1136 ], 1137 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 1138 } 1139 }, 1140 'operators': [{ 1141 'name': 'reduceSum', 1142 'arguments': [ 1143 {'input': 'reduceSumInput'}, {'options': {'keepDimensions': true}} 1144 ], 1145 'outputs': 'reduceSumOutput' 1146 }], 1147 'expectedOutputs': { 1148 'reduceSumOutput': { 1149 'data': [1314], 1150 'descriptor': {shape: [1, 1, 1, 1], dataType: 'float16'} 1151 } 1152 } 1153 } 1154 }, 1155 { 1156 'name': 1157 'reduceSum float16 4D tensor options.axes with options.keepDimensions=false', 1158 'graph': { 1159 'inputs': { 1160 'reduceSumInput': { 1161 'data': [ 1162 69.625, 99.1875, 32.78125, 8.8828125, 16.09375, 11.8046875, 1163 32.65625, 44, 77, 79.8125, 45, 24.390625, 1164 57.5, 57.59375, 80.25, 43.65625, 87.5, 94.5, 1165 35.53125, 42.84375, 88.5625, 98.875, 25.625, 60.1875 1166 ], 1167 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 1168 } 1169 }, 1170 'operators': [{ 1171 'name': 'reduceSum', 1172 'arguments': [ 1173 {'input': 'reduceSumInput'}, 1174 {'options': {'axes': [1, 3], 'keepDimensions': false}} 1175 ], 1176 'outputs': 'reduceSumOutput' 1177 }], 1178 'expectedOutputs': { 1179 'reduceSumOutput': { 1180 'data': [355.25, 186, 362.25, 410.25], 1181 'descriptor': {shape: [2, 2], dataType: 'float16'} 1182 } 1183 } 1184 } 1185 }, 1186 { 1187 'name': 1188 'reduceSum float16 4D tensor options.axes with options.keepDimensions=true', 1189 'graph': { 1190 'inputs': { 1191 'reduceSumInput': { 1192 'data': [ 1193 69.625, 99.1875, 32.78125, 8.8828125, 16.09375, 11.8046875, 1194 32.65625, 44, 77, 79.8125, 45, 24.390625, 1195 57.5, 57.59375, 80.25, 43.65625, 87.5, 94.5, 1196 35.53125, 42.84375, 88.5625, 98.875, 25.625, 60.1875 1197 ], 1198 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 1199 } 1200 }, 1201 'operators': [{ 1202 'name': 'reduceSum', 1203 'arguments': [ 1204 {'input': 'reduceSumInput'}, 1205 {'options': {'axes': [1, 3], 'keepDimensions': true}} 1206 ], 1207 'outputs': 'reduceSumOutput' 1208 }], 1209 'expectedOutputs': { 1210 'reduceSumOutput': { 1211 'data': [355.25, 186, 362.25, 410.25], 1212 'descriptor': {shape: [2, 1, 2, 1], dataType: 'float16'} 1213 } 1214 } 1215 } 1216 } 1217 ]; 1218 1219 webnn_conformance_test( 1220 reduceSumTests, buildAndExecuteGraph, getPrecisionTolerance);