reduce_max.https.any.js (36457B)
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-reducemax 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 reduceMax(MLOperand input, optional MLReduceOptions options = {}); 21 22 const reduceMaxTests = [ 23 { 24 'name': 'reduceMax float32 0D constant tensor default options', 25 'graph': { 26 'inputs': { 27 'reduceMaxInput': { 28 'data': [32.16658401489258], 29 'descriptor': {shape: [], dataType: 'float32'}, 30 'constant': true 31 } 32 }, 33 'operators': [{ 34 'name': 'reduceMax', 35 'arguments': [{'input': 'reduceMaxInput'}], 36 'outputs': 'reduceMaxOutput' 37 }], 38 'expectedOutputs': { 39 'reduceMaxOutput': { 40 'data': 32.16658401489258, 41 'descriptor': {shape: [], dataType: 'float32'} 42 } 43 } 44 } 45 }, 46 { 47 'name': 'reduceMax float32 0D tensor default options', 48 'graph': { 49 'inputs': { 50 'reduceMaxInput': { 51 'data': [32.16658401489258], 52 'descriptor': {shape: [], dataType: 'float32'}, 53 'constant': false 54 } 55 }, 56 'operators': [{ 57 'name': 'reduceMax', 58 'arguments': [{'input': 'reduceMaxInput'}], 59 'outputs': 'reduceMaxOutput' 60 }], 61 'expectedOutputs': { 62 'reduceMaxOutput': { 63 'data': 32.16658401489258, 64 'descriptor': {shape: [], dataType: 'float32'} 65 } 66 } 67 } 68 }, 69 { 70 'name': 'reduceMax float32 0D constant tensor empty axes', 71 'graph': { 72 'inputs': { 73 'reduceMaxInput': { 74 'data': [32.16658401489258], 75 'descriptor': {shape: [], dataType: 'float32'}, 76 'constant': true 77 } 78 }, 79 'operators': [{ 80 'name': 'reduceMax', 81 'arguments': [{'input': 'reduceMaxInput'}, {'options': {'axes': []}}], 82 'outputs': 'reduceMaxOutput' 83 }], 84 'expectedOutputs': { 85 'reduceMaxOutput': { 86 'data': 32.16658401489258, 87 'descriptor': {shape: [], dataType: 'float32'} 88 } 89 } 90 } 91 }, 92 { 93 'name': 'reduceMax float32 0D tensor empty axes', 94 'graph': { 95 'inputs': { 96 'reduceMaxInput': { 97 'data': [32.16658401489258], 98 'descriptor': {shape: [], dataType: 'float32'}, 99 'constant': false 100 } 101 }, 102 'operators': [{ 103 'name': 'reduceMax', 104 'arguments': [{'input': 'reduceMaxInput'}, {'options': {'axes': []}}], 105 'outputs': 'reduceMaxOutput' 106 }], 107 'expectedOutputs': { 108 'reduceMaxOutput': { 109 'data': 32.16658401489258, 110 'descriptor': {shape: [], dataType: 'float32'} 111 } 112 } 113 } 114 }, 115 { 116 'name': 'reduceMax float32 1D constant tensor empty axes', 117 'graph': { 118 'inputs': { 119 'reduceMaxInput': { 120 'data': [32.16658401489258, 32.16658401489257], 121 'descriptor': {shape: [2], dataType: 'float32'}, 122 'constant': true 123 } 124 }, 125 'operators': [{ 126 'name': 'reduceMax', 127 'arguments': [{'input': 'reduceMaxInput'}, {'options': {'axes': []}}], 128 'outputs': 'reduceMaxOutput' 129 }], 130 'expectedOutputs': { 131 'reduceMaxOutput': { 132 'data': [32.16658401489258, 32.16658401489257], 133 'descriptor': {shape: [2], dataType: 'float32'} 134 } 135 } 136 } 137 }, 138 { 139 'name': 'reduceMax float32 1D constant tensor default options', 140 'graph': { 141 'inputs': { 142 'reduceMaxInput': { 143 'data': [ 144 32.16658401489258, 90.42288208007812, -26.341794967651367, 145 -7.147959232330322, 75.90379333496094, -48.2042121887207, 146 -53.09425354003906, 66.66099548339844, -96.16854095458984, 147 -88.30545043945312, 94.99645233154297, 37.28493118286133, 148 -42.209861755371094, 96.55397033691406, 0.8807229995727539, 149 62.504642486572266, 36.650634765625, 99.77313232421875, 150 -72.86485290527344, -46.03200912475586, 20.253753662109375, 151 -21.557384490966797, -51.28727340698242, -42.58832931518555 152 ], 153 'descriptor': {shape: [24], dataType: 'float32'}, 154 'constant': true 155 } 156 }, 157 'operators': [{ 158 'name': 'reduceMax', 159 'arguments': [{'input': 'reduceMaxInput'}], 160 'outputs': 'reduceMaxOutput' 161 }], 162 'expectedOutputs': { 163 'reduceMaxOutput': { 164 'data': 99.77313232421875, 165 'descriptor': {shape: [], dataType: 'float32'} 166 } 167 } 168 } 169 }, 170 { 171 'name': 'reduceMax float32 1D tensor default options', 172 'graph': { 173 'inputs': { 174 'reduceMaxInput': { 175 'data': [ 176 32.16658401489258, 90.42288208007812, -26.341794967651367, 177 -7.147959232330322, 75.90379333496094, -48.2042121887207, 178 -53.09425354003906, 66.66099548339844, -96.16854095458984, 179 -88.30545043945312, 94.99645233154297, 37.28493118286133, 180 -42.209861755371094, 96.55397033691406, 0.8807229995727539, 181 62.504642486572266, 36.650634765625, 99.77313232421875, 182 -72.86485290527344, -46.03200912475586, 20.253753662109375, 183 -21.557384490966797, -51.28727340698242, -42.58832931518555 184 ], 185 'descriptor': {shape: [24], dataType: 'float32'} 186 } 187 }, 188 'operators': [{ 189 'name': 'reduceMax', 190 'arguments': [{'input': 'reduceMaxInput'}], 191 'outputs': 'reduceMaxOutput' 192 }], 193 'expectedOutputs': { 194 'reduceMaxOutput': { 195 'data': 99.77313232421875, 196 'descriptor': {shape: [], dataType: 'float32'} 197 } 198 } 199 } 200 }, 201 { 202 'name': 'reduceMax float32 2D tensor default options', 203 'graph': { 204 'inputs': { 205 'reduceMaxInput': { 206 'data': [ 207 32.16658401489258, 90.42288208007812, -26.341794967651367, 208 -7.147959232330322, 75.90379333496094, -48.2042121887207, 209 -53.09425354003906, 66.66099548339844, -96.16854095458984, 210 -88.30545043945312, 94.99645233154297, 37.28493118286133, 211 -42.209861755371094, 96.55397033691406, 0.8807229995727539, 212 62.504642486572266, 36.650634765625, 99.77313232421875, 213 -72.86485290527344, -46.03200912475586, 20.253753662109375, 214 -21.557384490966797, -51.28727340698242, -42.58832931518555 215 ], 216 'descriptor': {shape: [4, 6], dataType: 'float32'} 217 } 218 }, 219 'operators': [{ 220 'name': 'reduceMax', 221 'arguments': [{'input': 'reduceMaxInput'}], 222 'outputs': 'reduceMaxOutput' 223 }], 224 'expectedOutputs': { 225 'reduceMaxOutput': { 226 'data': 99.77313232421875, 227 'descriptor': {shape: [], dataType: 'float32'} 228 } 229 } 230 } 231 }, 232 { 233 'name': 'reduceMax float32 3D tensor default options', 234 'graph': { 235 'inputs': { 236 'reduceMaxInput': { 237 'data': [ 238 32.16658401489258, 90.42288208007812, -26.341794967651367, 239 -7.147959232330322, 75.90379333496094, -48.2042121887207, 240 -53.09425354003906, 66.66099548339844, -96.16854095458984, 241 -88.30545043945312, 94.99645233154297, 37.28493118286133, 242 -42.209861755371094, 96.55397033691406, 0.8807229995727539, 243 62.504642486572266, 36.650634765625, 99.77313232421875, 244 -72.86485290527344, -46.03200912475586, 20.253753662109375, 245 -21.557384490966797, -51.28727340698242, -42.58832931518555 246 ], 247 'descriptor': {shape: [2, 3, 4], dataType: 'float32'} 248 } 249 }, 250 'operators': [{ 251 'name': 'reduceMax', 252 'arguments': [{'input': 'reduceMaxInput'}], 253 'outputs': 'reduceMaxOutput' 254 }], 255 'expectedOutputs': { 256 'reduceMaxOutput': { 257 'data': 99.77313232421875, 258 'descriptor': {shape: [], dataType: 'float32'} 259 } 260 } 261 } 262 }, 263 { 264 'name': 'reduceMax float32 4D tensor default options', 265 'graph': { 266 'inputs': { 267 'reduceMaxInput': { 268 'data': [ 269 32.16658401489258, 90.42288208007812, -26.341794967651367, 270 -7.147959232330322, 75.90379333496094, -48.2042121887207, 271 -53.09425354003906, 66.66099548339844, -96.16854095458984, 272 -88.30545043945312, 94.99645233154297, 37.28493118286133, 273 -42.209861755371094, 96.55397033691406, 0.8807229995727539, 274 62.504642486572266, 36.650634765625, 99.77313232421875, 275 -72.86485290527344, -46.03200912475586, 20.253753662109375, 276 -21.557384490966797, -51.28727340698242, -42.58832931518555 277 ], 278 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 279 } 280 }, 281 'operators': [{ 282 'name': 'reduceMax', 283 'arguments': [{'input': 'reduceMaxInput'}], 284 'outputs': 'reduceMaxOutput' 285 }], 286 'expectedOutputs': { 287 'reduceMaxOutput': { 288 'data': 99.77313232421875, 289 'descriptor': {shape: [], dataType: 'float32'} 290 } 291 } 292 } 293 }, 294 { 295 'name': 'reduceMax float32 5D tensor default options', 296 'graph': { 297 'inputs': { 298 'reduceMaxInput': { 299 'data': [ 300 32.16658401489258, 90.42288208007812, -26.341794967651367, 301 -7.147959232330322, 75.90379333496094, -48.2042121887207, 302 -53.09425354003906, 66.66099548339844, -96.16854095458984, 303 -88.30545043945312, 94.99645233154297, 37.28493118286133, 304 -42.209861755371094, 96.55397033691406, 0.8807229995727539, 305 62.504642486572266, 36.650634765625, 99.77313232421875, 306 -72.86485290527344, -46.03200912475586, 20.253753662109375, 307 -21.557384490966797, -51.28727340698242, -42.58832931518555 308 ], 309 'descriptor': {shape: [2, 1, 4, 1, 3], dataType: 'float32'} 310 } 311 }, 312 'operators': [{ 313 'name': 'reduceMax', 314 'arguments': [{'input': 'reduceMaxInput'}], 315 'outputs': 'reduceMaxOutput' 316 }], 317 'expectedOutputs': { 318 'reduceMaxOutput': { 319 'data': 99.77313232421875, 320 'descriptor': {shape: [], dataType: 'float32'} 321 } 322 } 323 } 324 }, 325 { 326 'name': 'reduceMax float32 3D tensor options.axes', 327 'graph': { 328 'inputs': { 329 'reduceMaxInput': { 330 'data': [ 331 32.16658401489258, 90.42288208007812, -26.341794967651367, 332 -7.147959232330322, 75.90379333496094, -48.2042121887207, 333 -53.09425354003906, 66.66099548339844, -96.16854095458984, 334 -88.30545043945312, 94.99645233154297, 37.28493118286133, 335 -42.209861755371094, 96.55397033691406, 0.8807229995727539, 336 62.504642486572266, 36.650634765625, 99.77313232421875, 337 -72.86485290527344, -46.03200912475586, 20.253753662109375, 338 -21.557384490966797, -51.28727340698242, -42.58832931518555 339 ], 340 'descriptor': {shape: [2, 3, 4], dataType: 'float32'} 341 } 342 }, 343 'operators': [{ 344 'name': 'reduceMax', 345 'arguments': [{'input': 'reduceMaxInput'}, {'options': {'axes': [2]}}], 346 'outputs': 'reduceMaxOutput' 347 }], 348 'expectedOutputs': { 349 'reduceMaxOutput': { 350 'data': [ 351 90.42288208007812, 75.90379333496094, 94.99645233154297, 352 96.55397033691406, 99.77313232421875, 20.253753662109375 353 ], 354 'descriptor': {shape: [2, 3], dataType: 'float32'} 355 } 356 } 357 } 358 }, 359 { 360 'name': 'reduceMax float32 4D tensor options.axes', 361 'graph': { 362 'inputs': { 363 'reduceMaxInput': { 364 'data': [ 365 32.16658401489258, 90.42288208007812, -26.341794967651367, 366 -7.147959232330322, 75.90379333496094, -48.2042121887207, 367 -53.09425354003906, 66.66099548339844, -96.16854095458984, 368 -88.30545043945312, 94.99645233154297, 37.28493118286133, 369 -42.209861755371094, 96.55397033691406, 0.8807229995727539, 370 62.504642486572266, 36.650634765625, 99.77313232421875, 371 -72.86485290527344, -46.03200912475586, 20.253753662109375, 372 -21.557384490966797, -51.28727340698242, -42.58832931518555 373 ], 374 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 375 } 376 }, 377 'operators': [{ 378 'name': 'reduceMax', 379 'arguments': 380 [{'input': 'reduceMaxInput'}, {'options': {'axes': [0, 2]}}], 381 'outputs': 'reduceMaxOutput' 382 }], 383 'expectedOutputs': { 384 'reduceMaxOutput': { 385 'data': [ 386 62.504642486572266, 96.55397033691406, 99.77313232421875, 387 -21.557384490966797, 94.99645233154297, 37.28493118286133 388 ], 389 'descriptor': {shape: [2, 3], dataType: 'float32'} 390 } 391 } 392 } 393 }, 394 { 395 'name': 'reduceMax float32 3D tensor options.keepDimensions=false', 396 'graph': { 397 'inputs': { 398 'reduceMaxInput': { 399 'data': [ 400 32.16658401489258, 90.42288208007812, -26.341794967651367, 401 -7.147959232330322, 75.90379333496094, -48.2042121887207, 402 -53.09425354003906, 66.66099548339844, -96.16854095458984, 403 -88.30545043945312, 94.99645233154297, 37.28493118286133, 404 -42.209861755371094, 96.55397033691406, 0.8807229995727539, 405 62.504642486572266, 36.650634765625, 99.77313232421875, 406 -72.86485290527344, -46.03200912475586, 20.253753662109375, 407 -21.557384490966797, -51.28727340698242, -42.58832931518555 408 ], 409 'descriptor': {shape: [2, 3, 4], dataType: 'float32'} 410 } 411 }, 412 'operators': [{ 413 'name': 'reduceMax', 414 'arguments': [ 415 {'input': 'reduceMaxInput'}, {'options': {'keepDimensions': false}} 416 ], 417 'outputs': 'reduceMaxOutput' 418 }], 419 'expectedOutputs': { 420 'reduceMaxOutput': { 421 'data': 99.77313232421875, 422 'descriptor': {shape: [], dataType: 'float32'} 423 } 424 } 425 } 426 }, 427 { 428 'name': 'reduceMax float32 3D tensor options.keepDimensions=true', 429 'graph': { 430 'inputs': { 431 'reduceMaxInput': { 432 'data': [ 433 32.16658401489258, 90.42288208007812, -26.341794967651367, 434 -7.147959232330322, 75.90379333496094, -48.2042121887207, 435 -53.09425354003906, 66.66099548339844, -96.16854095458984, 436 -88.30545043945312, 94.99645233154297, 37.28493118286133, 437 -42.209861755371094, 96.55397033691406, 0.8807229995727539, 438 62.504642486572266, 36.650634765625, 99.77313232421875, 439 -72.86485290527344, -46.03200912475586, 20.253753662109375, 440 -21.557384490966797, -51.28727340698242, -42.58832931518555 441 ], 442 'descriptor': {shape: [2, 3, 4], dataType: 'float32'} 443 } 444 }, 445 'operators': [{ 446 'name': 'reduceMax', 447 'arguments': [ 448 {'input': 'reduceMaxInput'}, {'options': {'keepDimensions': true}} 449 ], 450 'outputs': 'reduceMaxOutput' 451 }], 452 'expectedOutputs': { 453 'reduceMaxOutput': { 454 'data': [99.77313232421875], 455 'descriptor': {shape: [1, 1, 1], dataType: 'float32'} 456 } 457 } 458 } 459 }, 460 { 461 'name': 'reduceMax float32 4D tensor options.keepDimensions=false', 462 'graph': { 463 'inputs': { 464 'reduceMaxInput': { 465 'data': [ 466 32.16658401489258, 90.42288208007812, -26.341794967651367, 467 -7.147959232330322, 75.90379333496094, -48.2042121887207, 468 -53.09425354003906, 66.66099548339844, -96.16854095458984, 469 -88.30545043945312, 94.99645233154297, 37.28493118286133, 470 -42.209861755371094, 96.55397033691406, 0.8807229995727539, 471 62.504642486572266, 36.650634765625, 99.77313232421875, 472 -72.86485290527344, -46.03200912475586, 20.253753662109375, 473 -21.557384490966797, -51.28727340698242, -42.58832931518555 474 ], 475 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 476 } 477 }, 478 'operators': [{ 479 'name': 'reduceMax', 480 'arguments': [ 481 {'input': 'reduceMaxInput'}, {'options': {'keepDimensions': false}} 482 ], 483 'outputs': 'reduceMaxOutput' 484 }], 485 'expectedOutputs': { 486 'reduceMaxOutput': { 487 'data': 99.77313232421875, 488 'descriptor': {shape: [], dataType: 'float32'} 489 } 490 } 491 } 492 }, 493 { 494 'name': 'reduceMax float32 4D tensor options.keepDimensions=true', 495 'graph': { 496 'inputs': { 497 'reduceMaxInput': { 498 'data': [ 499 32.16658401489258, 90.42288208007812, -26.341794967651367, 500 -7.147959232330322, 75.90379333496094, -48.2042121887207, 501 -53.09425354003906, 66.66099548339844, -96.16854095458984, 502 -88.30545043945312, 94.99645233154297, 37.28493118286133, 503 -42.209861755371094, 96.55397033691406, 0.8807229995727539, 504 62.504642486572266, 36.650634765625, 99.77313232421875, 505 -72.86485290527344, -46.03200912475586, 20.253753662109375, 506 -21.557384490966797, -51.28727340698242, -42.58832931518555 507 ], 508 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 509 } 510 }, 511 'operators': [{ 512 'name': 'reduceMax', 513 'arguments': [ 514 {'input': 'reduceMaxInput'}, {'options': {'keepDimensions': true}} 515 ], 516 'outputs': 'reduceMaxOutput' 517 }], 518 'expectedOutputs': { 519 'reduceMaxOutput': { 520 'data': [99.77313232421875], 521 'descriptor': {shape: [1, 1, 1, 1], dataType: 'float32'} 522 } 523 } 524 } 525 }, 526 { 527 'name': 528 'reduceMax float32 4D tensor options.axes with options.keepDimensions=false', 529 'graph': { 530 'inputs': { 531 'reduceMaxInput': { 532 'data': [ 533 32.16658401489258, 90.42288208007812, -26.341794967651367, 534 -7.147959232330322, 75.90379333496094, -48.2042121887207, 535 -53.09425354003906, 66.66099548339844, -96.16854095458984, 536 -88.30545043945312, 94.99645233154297, 37.28493118286133, 537 -42.209861755371094, 96.55397033691406, 0.8807229995727539, 538 62.504642486572266, 36.650634765625, 99.77313232421875, 539 -72.86485290527344, -46.03200912475586, 20.253753662109375, 540 -21.557384490966797, -51.28727340698242, -42.58832931518555 541 ], 542 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 543 } 544 }, 545 'operators': [{ 546 'name': 'reduceMax', 547 'arguments': [ 548 {'input': 'reduceMaxInput'}, 549 {'options': {'axes': [1, 3], 'keepDimensions': false}} 550 ], 551 'outputs': 'reduceMaxOutput' 552 }], 553 'expectedOutputs': { 554 'reduceMaxOutput': { 555 'data': [ 556 90.42288208007812, 94.99645233154297, 96.55397033691406, 557 99.77313232421875 558 ], 559 'descriptor': {shape: [2, 2], dataType: 'float32'} 560 } 561 } 562 } 563 }, 564 { 565 'name': 566 'reduceMax float32 4D tensor options.axes with options.keepDimensions=true', 567 'graph': { 568 'inputs': { 569 'reduceMaxInput': { 570 'data': [ 571 32.16658401489258, 90.42288208007812, -26.341794967651367, 572 -7.147959232330322, 75.90379333496094, -48.2042121887207, 573 -53.09425354003906, 66.66099548339844, -96.16854095458984, 574 -88.30545043945312, 94.99645233154297, 37.28493118286133, 575 -42.209861755371094, 96.55397033691406, 0.8807229995727539, 576 62.504642486572266, 36.650634765625, 99.77313232421875, 577 -72.86485290527344, -46.03200912475586, 20.253753662109375, 578 -21.557384490966797, -51.28727340698242, -42.58832931518555 579 ], 580 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 581 } 582 }, 583 'operators': [{ 584 'name': 'reduceMax', 585 'arguments': [ 586 {'input': 'reduceMaxInput'}, 587 {'options': {'axes': [1, 3], 'keepDimensions': true}} 588 ], 589 'outputs': 'reduceMaxOutput' 590 }], 591 'expectedOutputs': { 592 'reduceMaxOutput': { 593 'data': [ 594 90.42288208007812, 94.99645233154297, 96.55397033691406, 595 99.77313232421875 596 ], 597 'descriptor': {shape: [2, 1, 2, 1], dataType: 'float32'} 598 } 599 } 600 } 601 }, 602 603 // float16 tests 604 { 605 'name': 'reduceMax float16 0D constant tensor default options', 606 'graph': { 607 'inputs': { 608 'reduceMaxInput': { 609 'data': [32.15625], 610 'descriptor': {shape: [], dataType: 'float16'}, 611 'constant': true 612 } 613 }, 614 'operators': [{ 615 'name': 'reduceMax', 616 'arguments': [{'input': 'reduceMaxInput'}], 617 'outputs': 'reduceMaxOutput' 618 }], 619 'expectedOutputs': { 620 'reduceMaxOutput': 621 {'data': [32.15625], 'descriptor': {shape: [], dataType: 'float16'}} 622 } 623 } 624 }, 625 { 626 'name': 'reduceMax float16 0D tensor default options', 627 'graph': { 628 'inputs': { 629 'reduceMaxInput': { 630 'data': [32.15625], 631 'descriptor': {shape: [], dataType: 'float16'}, 632 'constant': false 633 } 634 }, 635 'operators': [{ 636 'name': 'reduceMax', 637 'arguments': [{'input': 'reduceMaxInput'}], 638 'outputs': 'reduceMaxOutput' 639 }], 640 'expectedOutputs': { 641 'reduceMaxOutput': 642 {'data': [32.15625], 'descriptor': {shape: [], dataType: 'float16'}} 643 } 644 } 645 }, 646 { 647 'name': 'reduceMax float16 0D constant tensor empty axes', 648 'graph': { 649 'inputs': { 650 'reduceMaxInput': { 651 'data': [32.15625], 652 'descriptor': {shape: [], dataType: 'float16'}, 653 'constant': true 654 } 655 }, 656 'operators': [{ 657 'name': 'reduceMax', 658 'arguments': [{'input': 'reduceMaxInput'}, {'options': {'axes': []}}], 659 'outputs': 'reduceMaxOutput' 660 }], 661 'expectedOutputs': { 662 'reduceMaxOutput': 663 {'data': [32.15625], 'descriptor': {shape: [], dataType: 'float16'}} 664 } 665 } 666 }, 667 { 668 'name': 'reduceMax float16 0D tensor empty axes', 669 'graph': { 670 'inputs': { 671 'reduceMaxInput': { 672 'data': [32.15625], 673 'descriptor': {shape: [], dataType: 'float16'}, 674 'constant': false 675 } 676 }, 677 'operators': [{ 678 'name': 'reduceMax', 679 'arguments': [{'input': 'reduceMaxInput'}, {'options': {'axes': []}}], 680 'outputs': 'reduceMaxOutput' 681 }], 682 'expectedOutputs': { 683 'reduceMaxOutput': 684 {'data': [32.15625], 'descriptor': {shape: [], dataType: 'float16'}} 685 } 686 } 687 }, 688 { 689 'name': 'reduceMax float16 1D constant tensor default options', 690 'graph': { 691 'inputs': { 692 'reduceMaxInput': { 693 'data': [ 694 32.15625, 90.4375, -26.34375, -7.1484375, 75.875, 695 -48.21875, -53.09375, 66.6875, -96.1875, -88.3125, 696 95, 37.28125, -42.21875, 96.5625, 0.880859375, 697 62.5, 36.65625, 99.75, -72.875, -46.03125, 698 20.25, -21.5625, -51.28125, -42.59375 699 ], 700 'descriptor': {shape: [24], dataType: 'float16'}, 701 'constant': true 702 } 703 }, 704 'operators': [{ 705 'name': 'reduceMax', 706 'arguments': [{'input': 'reduceMaxInput'}], 707 'outputs': 'reduceMaxOutput' 708 }], 709 'expectedOutputs': { 710 'reduceMaxOutput': 711 {'data': [99.75], 'descriptor': {shape: [], dataType: 'float16'}} 712 } 713 } 714 }, 715 { 716 'name': 'reduceMax float16 1D tensor default options', 717 'graph': { 718 'inputs': { 719 'reduceMaxInput': { 720 'data': [ 721 32.15625, 90.4375, -26.34375, -7.1484375, 75.875, 722 -48.21875, -53.09375, 66.6875, -96.1875, -88.3125, 723 95, 37.28125, -42.21875, 96.5625, 0.880859375, 724 62.5, 36.65625, 99.75, -72.875, -46.03125, 725 20.25, -21.5625, -51.28125, -42.59375 726 ], 727 'descriptor': {shape: [24], dataType: 'float16'} 728 } 729 }, 730 'operators': [{ 731 'name': 'reduceMax', 732 'arguments': [{'input': 'reduceMaxInput'}], 733 'outputs': 'reduceMaxOutput' 734 }], 735 'expectedOutputs': { 736 'reduceMaxOutput': 737 {'data': [99.75], 'descriptor': {shape: [], dataType: 'float16'}} 738 } 739 } 740 }, 741 { 742 'name': 'reduceMax float16 2D tensor default options', 743 'graph': { 744 'inputs': { 745 'reduceMaxInput': { 746 'data': [ 747 32.15625, 90.4375, -26.34375, -7.1484375, 75.875, 748 -48.21875, -53.09375, 66.6875, -96.1875, -88.3125, 749 95, 37.28125, -42.21875, 96.5625, 0.880859375, 750 62.5, 36.65625, 99.75, -72.875, -46.03125, 751 20.25, -21.5625, -51.28125, -42.59375 752 ], 753 'descriptor': {shape: [4, 6], dataType: 'float16'} 754 } 755 }, 756 'operators': [{ 757 'name': 'reduceMax', 758 'arguments': [{'input': 'reduceMaxInput'}], 759 'outputs': 'reduceMaxOutput' 760 }], 761 'expectedOutputs': { 762 'reduceMaxOutput': 763 {'data': [99.75], 'descriptor': {shape: [], dataType: 'float16'}} 764 } 765 } 766 }, 767 { 768 'name': 'reduceMax float16 3D tensor default options', 769 'graph': { 770 'inputs': { 771 'reduceMaxInput': { 772 'data': [ 773 32.15625, 90.4375, -26.34375, -7.1484375, 75.875, 774 -48.21875, -53.09375, 66.6875, -96.1875, -88.3125, 775 95, 37.28125, -42.21875, 96.5625, 0.880859375, 776 62.5, 36.65625, 99.75, -72.875, -46.03125, 777 20.25, -21.5625, -51.28125, -42.59375 778 ], 779 'descriptor': {shape: [2, 3, 4], dataType: 'float16'} 780 } 781 }, 782 'operators': [{ 783 'name': 'reduceMax', 784 'arguments': [{'input': 'reduceMaxInput'}], 785 'outputs': 'reduceMaxOutput' 786 }], 787 'expectedOutputs': { 788 'reduceMaxOutput': 789 {'data': [99.75], 'descriptor': {shape: [], dataType: 'float16'}} 790 } 791 } 792 }, 793 { 794 'name': 'reduceMax float16 4D tensor default options', 795 'graph': { 796 'inputs': { 797 'reduceMaxInput': { 798 'data': [ 799 32.15625, 90.4375, -26.34375, -7.1484375, 75.875, 800 -48.21875, -53.09375, 66.6875, -96.1875, -88.3125, 801 95, 37.28125, -42.21875, 96.5625, 0.880859375, 802 62.5, 36.65625, 99.75, -72.875, -46.03125, 803 20.25, -21.5625, -51.28125, -42.59375 804 ], 805 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 806 } 807 }, 808 'operators': [{ 809 'name': 'reduceMax', 810 'arguments': [{'input': 'reduceMaxInput'}], 811 'outputs': 'reduceMaxOutput' 812 }], 813 'expectedOutputs': { 814 'reduceMaxOutput': 815 {'data': [99.75], 'descriptor': {shape: [], dataType: 'float16'}} 816 } 817 } 818 }, 819 { 820 'name': 'reduceMax float16 5D tensor default options', 821 'graph': { 822 'inputs': { 823 'reduceMaxInput': { 824 'data': [ 825 32.15625, 90.4375, -26.34375, -7.1484375, 75.875, 826 -48.21875, -53.09375, 66.6875, -96.1875, -88.3125, 827 95, 37.28125, -42.21875, 96.5625, 0.880859375, 828 62.5, 36.65625, 99.75, -72.875, -46.03125, 829 20.25, -21.5625, -51.28125, -42.59375 830 ], 831 'descriptor': {shape: [2, 1, 4, 1, 3], dataType: 'float16'} 832 } 833 }, 834 'operators': [{ 835 'name': 'reduceMax', 836 'arguments': [{'input': 'reduceMaxInput'}], 837 'outputs': 'reduceMaxOutput' 838 }], 839 'expectedOutputs': { 840 'reduceMaxOutput': 841 {'data': [99.75], 'descriptor': {shape: [], dataType: 'float16'}} 842 } 843 } 844 }, 845 { 846 'name': 'reduceMax float16 3D tensor options.axes', 847 'graph': { 848 'inputs': { 849 'reduceMaxInput': { 850 'data': [ 851 32.15625, 90.4375, -26.34375, -7.1484375, 75.875, 852 -48.21875, -53.09375, 66.6875, -96.1875, -88.3125, 853 95, 37.28125, -42.21875, 96.5625, 0.880859375, 854 62.5, 36.65625, 99.75, -72.875, -46.03125, 855 20.25, -21.5625, -51.28125, -42.59375 856 ], 857 'descriptor': {shape: [2, 3, 4], dataType: 'float16'} 858 } 859 }, 860 'operators': [{ 861 'name': 'reduceMax', 862 'arguments': [{'input': 'reduceMaxInput'}, {'options': {'axes': [2]}}], 863 'outputs': 'reduceMaxOutput' 864 }], 865 'expectedOutputs': { 866 'reduceMaxOutput': { 867 'data': [90.4375, 75.875, 95, 96.5625, 99.75, 20.25], 868 'descriptor': {shape: [2, 3], dataType: 'float16'} 869 } 870 } 871 } 872 }, 873 { 874 'name': 'reduceMax float16 4D tensor options.axes', 875 'graph': { 876 'inputs': { 877 'reduceMaxInput': { 878 'data': [ 879 32.15625, 90.4375, -26.34375, -7.1484375, 75.875, 880 -48.21875, -53.09375, 66.6875, -96.1875, -88.3125, 881 95, 37.28125, -42.21875, 96.5625, 0.880859375, 882 62.5, 36.65625, 99.75, -72.875, -46.03125, 883 20.25, -21.5625, -51.28125, -42.59375 884 ], 885 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 886 } 887 }, 888 'operators': [{ 889 'name': 'reduceMax', 890 'arguments': 891 [{'input': 'reduceMaxInput'}, {'options': {'axes': [0, 2]}}], 892 'outputs': 'reduceMaxOutput' 893 }], 894 'expectedOutputs': { 895 'reduceMaxOutput': { 896 'data': [62.5, 96.5625, 99.75, -21.5625, 95, 37.28125], 897 'descriptor': {shape: [2, 3], dataType: 'float16'} 898 } 899 } 900 } 901 }, 902 { 903 'name': 'reduceMax float16 3D tensor options.keepDimensions=false', 904 'graph': { 905 'inputs': { 906 'reduceMaxInput': { 907 'data': [ 908 32.15625, 90.4375, -26.34375, -7.1484375, 75.875, 909 -48.21875, -53.09375, 66.6875, -96.1875, -88.3125, 910 95, 37.28125, -42.21875, 96.5625, 0.880859375, 911 62.5, 36.65625, 99.75, -72.875, -46.03125, 912 20.25, -21.5625, -51.28125, -42.59375 913 ], 914 'descriptor': {shape: [2, 3, 4], dataType: 'float16'} 915 } 916 }, 917 'operators': [{ 918 'name': 'reduceMax', 919 'arguments': [ 920 {'input': 'reduceMaxInput'}, {'options': {'keepDimensions': false}} 921 ], 922 'outputs': 'reduceMaxOutput' 923 }], 924 'expectedOutputs': { 925 'reduceMaxOutput': 926 {'data': [99.75], 'descriptor': {shape: [], dataType: 'float16'}} 927 } 928 } 929 }, 930 { 931 'name': 'reduceMax float16 3D tensor options.keepDimensions=true', 932 'graph': { 933 'inputs': { 934 'reduceMaxInput': { 935 'data': [ 936 32.15625, 90.4375, -26.34375, -7.1484375, 75.875, 937 -48.21875, -53.09375, 66.6875, -96.1875, -88.3125, 938 95, 37.28125, -42.21875, 96.5625, 0.880859375, 939 62.5, 36.65625, 99.75, -72.875, -46.03125, 940 20.25, -21.5625, -51.28125, -42.59375 941 ], 942 'descriptor': {shape: [2, 3, 4], dataType: 'float16'} 943 } 944 }, 945 'operators': [{ 946 'name': 'reduceMax', 947 'arguments': [ 948 {'input': 'reduceMaxInput'}, {'options': {'keepDimensions': true}} 949 ], 950 'outputs': 'reduceMaxOutput' 951 }], 952 'expectedOutputs': { 953 'reduceMaxOutput': { 954 'data': [99.75], 955 'descriptor': {shape: [1, 1, 1], dataType: 'float16'} 956 } 957 } 958 } 959 }, 960 { 961 'name': 'reduceMax float16 4D tensor options.keepDimensions=false', 962 'graph': { 963 'inputs': { 964 'reduceMaxInput': { 965 'data': [ 966 32.15625, 90.4375, -26.34375, -7.1484375, 75.875, 967 -48.21875, -53.09375, 66.6875, -96.1875, -88.3125, 968 95, 37.28125, -42.21875, 96.5625, 0.880859375, 969 62.5, 36.65625, 99.75, -72.875, -46.03125, 970 20.25, -21.5625, -51.28125, -42.59375 971 ], 972 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 973 } 974 }, 975 'operators': [{ 976 'name': 'reduceMax', 977 'arguments': [ 978 {'input': 'reduceMaxInput'}, {'options': {'keepDimensions': false}} 979 ], 980 'outputs': 'reduceMaxOutput' 981 }], 982 'expectedOutputs': { 983 'reduceMaxOutput': 984 {'data': [99.75], 'descriptor': {shape: [], dataType: 'float16'}} 985 } 986 } 987 }, 988 { 989 'name': 'reduceMax float16 4D tensor options.keepDimensions=true', 990 'graph': { 991 'inputs': { 992 'reduceMaxInput': { 993 'data': [ 994 32.15625, 90.4375, -26.34375, -7.1484375, 75.875, 995 -48.21875, -53.09375, 66.6875, -96.1875, -88.3125, 996 95, 37.28125, -42.21875, 96.5625, 0.880859375, 997 62.5, 36.65625, 99.75, -72.875, -46.03125, 998 20.25, -21.5625, -51.28125, -42.59375 999 ], 1000 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 1001 } 1002 }, 1003 'operators': [{ 1004 'name': 'reduceMax', 1005 'arguments': [ 1006 {'input': 'reduceMaxInput'}, {'options': {'keepDimensions': true}} 1007 ], 1008 'outputs': 'reduceMaxOutput' 1009 }], 1010 'expectedOutputs': { 1011 'reduceMaxOutput': { 1012 'data': [99.75], 1013 'descriptor': {shape: [1, 1, 1, 1], dataType: 'float16'} 1014 } 1015 } 1016 } 1017 }, 1018 { 1019 'name': 1020 'reduceMax float16 4D tensor options.axes with options.keepDimensions=false', 1021 'graph': { 1022 'inputs': { 1023 'reduceMaxInput': { 1024 'data': [ 1025 32.15625, 90.4375, -26.34375, -7.1484375, 75.875, 1026 -48.21875, -53.09375, 66.6875, -96.1875, -88.3125, 1027 95, 37.28125, -42.21875, 96.5625, 0.880859375, 1028 62.5, 36.65625, 99.75, -72.875, -46.03125, 1029 20.25, -21.5625, -51.28125, -42.59375 1030 ], 1031 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 1032 } 1033 }, 1034 'operators': [{ 1035 'name': 'reduceMax', 1036 'arguments': [ 1037 {'input': 'reduceMaxInput'}, 1038 {'options': {'axes': [1, 3], 'keepDimensions': false}} 1039 ], 1040 'outputs': 'reduceMaxOutput' 1041 }], 1042 'expectedOutputs': { 1043 'reduceMaxOutput': { 1044 'data': [90.4375, 95, 96.5625, 99.75], 1045 'descriptor': {shape: [2, 2], dataType: 'float16'} 1046 } 1047 } 1048 } 1049 }, 1050 { 1051 'name': 1052 'reduceMax float16 4D tensor options.axes with options.keepDimensions=true', 1053 'graph': { 1054 'inputs': { 1055 'reduceMaxInput': { 1056 'data': [ 1057 32.15625, 90.4375, -26.34375, -7.1484375, 75.875, 1058 -48.21875, -53.09375, 66.6875, -96.1875, -88.3125, 1059 95, 37.28125, -42.21875, 96.5625, 0.880859375, 1060 62.5, 36.65625, 99.75, -72.875, -46.03125, 1061 20.25, -21.5625, -51.28125, -42.59375 1062 ], 1063 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 1064 } 1065 }, 1066 'operators': [{ 1067 'name': 'reduceMax', 1068 'arguments': [ 1069 {'input': 'reduceMaxInput'}, 1070 {'options': {'axes': [1, 3], 'keepDimensions': true}} 1071 ], 1072 'outputs': 'reduceMaxOutput' 1073 }], 1074 'expectedOutputs': { 1075 'reduceMaxOutput': { 1076 'data': [90.4375, 95, 96.5625, 99.75], 1077 'descriptor': {shape: [2, 1, 2, 1], dataType: 'float16'} 1078 } 1079 } 1080 } 1081 } 1082 ]; 1083 1084 webnn_conformance_test( 1085 reduceMaxTests, buildAndExecuteGraph, getPrecisionTolerance);