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