max.https.any.js (37648B)
1 // META: title=test WebNN API element-wise max operation 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/#api-mlgraphbuilder-binary 12 // Compute the element-wise binary maximum of the two input tensors. 13 // MLOperand max(MLOperand a, MLOperand b); 14 15 const maxTests = [ 16 { 17 'name': 'max float32 1D constant tensors', 18 'graph': { 19 'inputs': { 20 'inputA': { 21 'data': [ 22 17.72909164428711, 88.1480712890625, -12.794827461242676, 23 11.817361831665039, 19.51302146911621, -62.87843704223633, 24 50.771915435791016, -56.91352081298828, 50.57254409790039, 25 -96.00484466552734, 50.21434020996094, 20.59501075744629, 26 -60.699546813964844, -96.84203338623047, 57.25886917114258, 27 -56.29146194458008, 73.71659851074219, 21.347652435302734, 28 79.85667419433594, -22.918458938598633, 1.2300019264221191, 29 65.67964935302734, 99.89971160888672, -62.321685791015625 30 ], 31 'descriptor': {shape: [24], dataType: 'float32'}, 32 'constant': true 33 }, 34 'inputB': { 35 'data': [ 36 -34.50435256958008, 85.73471069335938, 25.818017959594727, 37 -91.37040710449219, 87.01370239257812, 0.17744044959545135, 38 74.8826675415039, -4.1699137687683105, -73.76497650146484, 39 55.388797760009766, -58.69169616699219, -67.62332916259766, 40 -89.83531188964844, -8.275739669799805, 97.59577178955078, 41 -48.968868255615234, 95.34497833251953, -97.36360168457031, 42 -59.90718078613281, 97.15335083007812, -40.226924896240234, 43 -61.5142707824707, 33.363243103027344, 12.693191528320312 44 ], 45 'descriptor': {shape: [24], dataType: 'float32'}, 46 'constant': true 47 } 48 }, 49 'operators': [{ 50 'name': 'max', 51 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 52 'outputs': 'output' 53 }], 54 'expectedOutputs': { 55 'output': { 56 'data': [ 57 17.72909164428711, 88.1480712890625, 25.818017959594727, 58 11.817361831665039, 87.01370239257812, 0.17744044959545135, 59 74.8826675415039, -4.1699137687683105, 50.57254409790039, 60 55.388797760009766, 50.21434020996094, 20.59501075744629, 61 -60.699546813964844, -8.275739669799805, 97.59577178955078, 62 -48.968868255615234, 95.34497833251953, 21.347652435302734, 63 79.85667419433594, 97.15335083007812, 1.2300019264221191, 64 65.67964935302734, 99.89971160888672, 12.693191528320312 65 ], 66 'descriptor': {shape: [24], dataType: 'float32'} 67 } 68 } 69 } 70 }, 71 { 72 'name': 'max float32 1D tensors', 73 'graph': { 74 'inputs': { 75 'inputA': { 76 'data': [ 77 17.72909164428711, 88.1480712890625, -12.794827461242676, 78 11.817361831665039, 19.51302146911621, -62.87843704223633, 79 50.771915435791016, -56.91352081298828, 50.57254409790039, 80 -96.00484466552734, 50.21434020996094, 20.59501075744629, 81 -60.699546813964844, -96.84203338623047, 57.25886917114258, 82 -56.29146194458008, 73.71659851074219, 21.347652435302734, 83 79.85667419433594, -22.918458938598633, 1.2300019264221191, 84 65.67964935302734, 99.89971160888672, -62.321685791015625 85 ], 86 'descriptor': {shape: [24], dataType: 'float32'} 87 }, 88 'inputB': { 89 'data': [ 90 -34.50435256958008, 85.73471069335938, 25.818017959594727, 91 -91.37040710449219, 87.01370239257812, 0.17744044959545135, 92 74.8826675415039, -4.1699137687683105, -73.76497650146484, 93 55.388797760009766, -58.69169616699219, -67.62332916259766, 94 -89.83531188964844, -8.275739669799805, 97.59577178955078, 95 -48.968868255615234, 95.34497833251953, -97.36360168457031, 96 -59.90718078613281, 97.15335083007812, -40.226924896240234, 97 -61.5142707824707, 33.363243103027344, 12.693191528320312 98 ], 99 'descriptor': {shape: [24], dataType: 'float32'} 100 } 101 }, 102 'operators': [{ 103 'name': 'max', 104 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 105 'outputs': 'output' 106 }], 107 'expectedOutputs': { 108 'output': { 109 'data': [ 110 17.72909164428711, 88.1480712890625, 25.818017959594727, 111 11.817361831665039, 87.01370239257812, 0.17744044959545135, 112 74.8826675415039, -4.1699137687683105, 50.57254409790039, 113 55.388797760009766, 50.21434020996094, 20.59501075744629, 114 -60.699546813964844, -8.275739669799805, 97.59577178955078, 115 -48.968868255615234, 95.34497833251953, 21.347652435302734, 116 79.85667419433594, 97.15335083007812, 1.2300019264221191, 117 65.67964935302734, 99.89971160888672, 12.693191528320312 118 ], 119 'descriptor': {shape: [24], dataType: 'float32'} 120 } 121 } 122 } 123 }, 124 { 125 'name': 'max float32 2D tensors', 126 'graph': { 127 'inputs': { 128 'inputA': { 129 'data': [ 130 17.72909164428711, 88.1480712890625, -12.794827461242676, 131 11.817361831665039, 19.51302146911621, -62.87843704223633, 132 50.771915435791016, -56.91352081298828, 50.57254409790039, 133 -96.00484466552734, 50.21434020996094, 20.59501075744629, 134 -60.699546813964844, -96.84203338623047, 57.25886917114258, 135 -56.29146194458008, 73.71659851074219, 21.347652435302734, 136 79.85667419433594, -22.918458938598633, 1.2300019264221191, 137 65.67964935302734, 99.89971160888672, -62.321685791015625 138 ], 139 'descriptor': {shape: [4, 6], dataType: 'float32'} 140 }, 141 'inputB': { 142 'data': [ 143 -34.50435256958008, 85.73471069335938, 25.818017959594727, 144 -91.37040710449219, 87.01370239257812, 0.17744044959545135, 145 74.8826675415039, -4.1699137687683105, -73.76497650146484, 146 55.388797760009766, -58.69169616699219, -67.62332916259766, 147 -89.83531188964844, -8.275739669799805, 97.59577178955078, 148 -48.968868255615234, 95.34497833251953, -97.36360168457031, 149 -59.90718078613281, 97.15335083007812, -40.226924896240234, 150 -61.5142707824707, 33.363243103027344, 12.693191528320312 151 ], 152 'descriptor': {shape: [4, 6], dataType: 'float32'} 153 } 154 }, 155 'operators': [{ 156 'name': 'max', 157 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 158 'outputs': 'output' 159 }], 160 'expectedOutputs': { 161 'output': { 162 'data': [ 163 17.72909164428711, 88.1480712890625, 25.818017959594727, 164 11.817361831665039, 87.01370239257812, 0.17744044959545135, 165 74.8826675415039, -4.1699137687683105, 50.57254409790039, 166 55.388797760009766, 50.21434020996094, 20.59501075744629, 167 -60.699546813964844, -8.275739669799805, 97.59577178955078, 168 -48.968868255615234, 95.34497833251953, 21.347652435302734, 169 79.85667419433594, 97.15335083007812, 1.2300019264221191, 170 65.67964935302734, 99.89971160888672, 12.693191528320312 171 ], 172 'descriptor': {shape: [4, 6], dataType: 'float32'} 173 } 174 } 175 } 176 }, 177 { 178 'name': 'max float32 3D tensors', 179 'graph': { 180 'inputs': { 181 'inputA': { 182 'data': [ 183 17.72909164428711, 88.1480712890625, -12.794827461242676, 184 11.817361831665039, 19.51302146911621, -62.87843704223633, 185 50.771915435791016, -56.91352081298828, 50.57254409790039, 186 -96.00484466552734, 50.21434020996094, 20.59501075744629, 187 -60.699546813964844, -96.84203338623047, 57.25886917114258, 188 -56.29146194458008, 73.71659851074219, 21.347652435302734, 189 79.85667419433594, -22.918458938598633, 1.2300019264221191, 190 65.67964935302734, 99.89971160888672, -62.321685791015625 191 ], 192 'descriptor': {shape: [2, 3, 4], dataType: 'float32'} 193 }, 194 'inputB': { 195 'data': [ 196 -34.50435256958008, 85.73471069335938, 25.818017959594727, 197 -91.37040710449219, 87.01370239257812, 0.17744044959545135, 198 74.8826675415039, -4.1699137687683105, -73.76497650146484, 199 55.388797760009766, -58.69169616699219, -67.62332916259766, 200 -89.83531188964844, -8.275739669799805, 97.59577178955078, 201 -48.968868255615234, 95.34497833251953, -97.36360168457031, 202 -59.90718078613281, 97.15335083007812, -40.226924896240234, 203 -61.5142707824707, 33.363243103027344, 12.693191528320312 204 ], 205 'descriptor': {shape: [2, 3, 4], dataType: 'float32'} 206 } 207 }, 208 'operators': [{ 209 'name': 'max', 210 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 211 'outputs': 'output' 212 }], 213 'expectedOutputs': { 214 'output': { 215 'data': [ 216 17.72909164428711, 88.1480712890625, 25.818017959594727, 217 11.817361831665039, 87.01370239257812, 0.17744044959545135, 218 74.8826675415039, -4.1699137687683105, 50.57254409790039, 219 55.388797760009766, 50.21434020996094, 20.59501075744629, 220 -60.699546813964844, -8.275739669799805, 97.59577178955078, 221 -48.968868255615234, 95.34497833251953, 21.347652435302734, 222 79.85667419433594, 97.15335083007812, 1.2300019264221191, 223 65.67964935302734, 99.89971160888672, 12.693191528320312 224 ], 225 'descriptor': {shape: [2, 3, 4], dataType: 'float32'} 226 } 227 } 228 } 229 }, 230 { 231 'name': 'max float32 4D tensors', 232 'graph': { 233 'inputs': { 234 'inputA': { 235 'data': [ 236 17.72909164428711, 88.1480712890625, -12.794827461242676, 237 11.817361831665039, 19.51302146911621, -62.87843704223633, 238 50.771915435791016, -56.91352081298828, 50.57254409790039, 239 -96.00484466552734, 50.21434020996094, 20.59501075744629, 240 -60.699546813964844, -96.84203338623047, 57.25886917114258, 241 -56.29146194458008, 73.71659851074219, 21.347652435302734, 242 79.85667419433594, -22.918458938598633, 1.2300019264221191, 243 65.67964935302734, 99.89971160888672, -62.321685791015625 244 ], 245 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 246 }, 247 'inputB': { 248 'data': [ 249 -34.50435256958008, 85.73471069335938, 25.818017959594727, 250 -91.37040710449219, 87.01370239257812, 0.17744044959545135, 251 74.8826675415039, -4.1699137687683105, -73.76497650146484, 252 55.388797760009766, -58.69169616699219, -67.62332916259766, 253 -89.83531188964844, -8.275739669799805, 97.59577178955078, 254 -48.968868255615234, 95.34497833251953, -97.36360168457031, 255 -59.90718078613281, 97.15335083007812, -40.226924896240234, 256 -61.5142707824707, 33.363243103027344, 12.693191528320312 257 ], 258 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 259 } 260 }, 261 'operators': [{ 262 'name': 'max', 263 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 264 'outputs': 'output' 265 }], 266 'expectedOutputs': { 267 'output': { 268 'data': [ 269 17.72909164428711, 88.1480712890625, 25.818017959594727, 270 11.817361831665039, 87.01370239257812, 0.17744044959545135, 271 74.8826675415039, -4.1699137687683105, 50.57254409790039, 272 55.388797760009766, 50.21434020996094, 20.59501075744629, 273 -60.699546813964844, -8.275739669799805, 97.59577178955078, 274 -48.968868255615234, 95.34497833251953, 21.347652435302734, 275 79.85667419433594, 97.15335083007812, 1.2300019264221191, 276 65.67964935302734, 99.89971160888672, 12.693191528320312 277 ], 278 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 279 } 280 } 281 } 282 }, 283 { 284 'name': 'max float32 5D tensors', 285 'graph': { 286 'inputs': { 287 'inputA': { 288 'data': [ 289 17.72909164428711, 88.1480712890625, -12.794827461242676, 290 11.817361831665039, 19.51302146911621, -62.87843704223633, 291 50.771915435791016, -56.91352081298828, 50.57254409790039, 292 -96.00484466552734, 50.21434020996094, 20.59501075744629, 293 -60.699546813964844, -96.84203338623047, 57.25886917114258, 294 -56.29146194458008, 73.71659851074219, 21.347652435302734, 295 79.85667419433594, -22.918458938598633, 1.2300019264221191, 296 65.67964935302734, 99.89971160888672, -62.321685791015625 297 ], 298 'descriptor': {shape: [2, 2, 1, 2, 3], dataType: 'float32'} 299 }, 300 'inputB': { 301 'data': [ 302 -34.50435256958008, 85.73471069335938, 25.818017959594727, 303 -91.37040710449219, 87.01370239257812, 0.17744044959545135, 304 74.8826675415039, -4.1699137687683105, -73.76497650146484, 305 55.388797760009766, -58.69169616699219, -67.62332916259766, 306 -89.83531188964844, -8.275739669799805, 97.59577178955078, 307 -48.968868255615234, 95.34497833251953, -97.36360168457031, 308 -59.90718078613281, 97.15335083007812, -40.226924896240234, 309 -61.5142707824707, 33.363243103027344, 12.693191528320312 310 ], 311 'descriptor': {shape: [2, 2, 1, 2, 3], dataType: 'float32'} 312 } 313 }, 314 'operators': [{ 315 'name': 'max', 316 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 317 'outputs': 'output' 318 }], 319 'expectedOutputs': { 320 'output': { 321 'data': [ 322 17.72909164428711, 88.1480712890625, 25.818017959594727, 323 11.817361831665039, 87.01370239257812, 0.17744044959545135, 324 74.8826675415039, -4.1699137687683105, 50.57254409790039, 325 55.388797760009766, 50.21434020996094, 20.59501075744629, 326 -60.699546813964844, -8.275739669799805, 97.59577178955078, 327 -48.968868255615234, 95.34497833251953, 21.347652435302734, 328 79.85667419433594, 97.15335083007812, 1.2300019264221191, 329 65.67964935302734, 99.89971160888672, 12.693191528320312 330 ], 331 'descriptor': {shape: [2, 2, 1, 2, 3], dataType: 'float32'} 332 } 333 } 334 } 335 }, 336 { 337 'name': 'max float32 broadcast 1D to 4D', 338 'graph': { 339 'inputs': { 340 'inputA': { 341 'data': [48.26115417480469], 342 'descriptor': {shape: [1], dataType: 'float32'} 343 }, 344 'inputB': { 345 'data': [ 346 17.72909164428711, 88.1480712890625, -12.794827461242676, 347 11.817361831665039, 19.51302146911621, -62.87843704223633, 348 50.771915435791016, -56.91352081298828, 50.57254409790039, 349 -96.00484466552734, 50.21434020996094, 20.59501075744629, 350 -60.699546813964844, -96.84203338623047, 57.25886917114258, 351 -56.29146194458008, 73.71659851074219, 21.347652435302734, 352 79.85667419433594, -22.918458938598633, 1.2300019264221191, 353 65.67964935302734, 99.89971160888672, -62.321685791015625 354 ], 355 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 356 } 357 }, 358 'operators': [{ 359 'name': 'max', 360 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 361 'outputs': 'output' 362 }], 363 'expectedOutputs': { 364 'output': { 365 'data': [ 366 48.26115417480469, 88.1480712890625, 48.26115417480469, 367 48.26115417480469, 48.26115417480469, 48.26115417480469, 368 50.771915435791016, 48.26115417480469, 50.57254409790039, 369 48.26115417480469, 50.21434020996094, 48.26115417480469, 370 48.26115417480469, 48.26115417480469, 57.25886917114258, 371 48.26115417480469, 73.71659851074219, 48.26115417480469, 372 79.85667419433594, 48.26115417480469, 48.26115417480469, 373 65.67964935302734, 99.89971160888672, 48.26115417480469 374 ], 375 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 376 } 377 } 378 } 379 }, 380 { 381 'name': 'max float32 broadcast 2D to 4D', 382 'graph': { 383 'inputs': { 384 'inputA': { 385 'data': [ 386 17.72909164428711, 88.1480712890625, -12.794827461242676, 387 11.817361831665039, 19.51302146911621, -62.87843704223633, 388 50.771915435791016, -56.91352081298828, 50.57254409790039, 389 -96.00484466552734, 50.21434020996094, 20.59501075744629, 390 -60.699546813964844, -96.84203338623047, 57.25886917114258, 391 -56.29146194458008, 73.71659851074219, 21.347652435302734, 392 79.85667419433594, -22.918458938598633, 1.2300019264221191, 393 65.67964935302734, 99.89971160888672, -62.321685791015625 394 ], 395 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 396 }, 397 'inputB': { 398 'data': [ 399 49.523128509521484, -61.555763244628906, -6.564808368682861, 400 93.32227325439453, 3.3104186058044434, -98.31839752197266 401 ], 402 'descriptor': {shape: [2, 3], dataType: 'float32'} 403 } 404 }, 405 'operators': [{ 406 'name': 'max', 407 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 408 'outputs': 'output' 409 }], 410 'expectedOutputs': { 411 'output': { 412 'data': [ 413 49.523128509521484, 88.1480712890625, -6.564808368682861, 414 93.32227325439453, 19.51302146911621, -62.87843704223633, 415 50.771915435791016, -56.91352081298828, 50.57254409790039, 416 93.32227325439453, 50.21434020996094, 20.59501075744629, 417 49.523128509521484, -61.555763244628906, 57.25886917114258, 418 93.32227325439453, 73.71659851074219, 21.347652435302734, 419 79.85667419433594, -22.918458938598633, 1.2300019264221191, 420 93.32227325439453, 99.89971160888672, -62.321685791015625 421 ], 422 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 423 } 424 } 425 } 426 }, 427 { 428 'name': 'max float32 broadcast 3D to 4D', 429 'graph': { 430 'inputs': { 431 'inputA': { 432 'data': [ 433 17.72909164428711, 88.1480712890625, -12.794827461242676, 434 11.817361831665039, 19.51302146911621, -62.87843704223633, 435 50.771915435791016, -56.91352081298828, 50.57254409790039, 436 -96.00484466552734, 50.21434020996094, 20.59501075744629, 437 -60.699546813964844, -96.84203338623047, 57.25886917114258, 438 -56.29146194458008, 73.71659851074219, 21.347652435302734, 439 79.85667419433594, -22.918458938598633, 1.2300019264221191, 440 65.67964935302734, 99.89971160888672, -62.321685791015625 441 ], 442 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 443 }, 444 'inputB': { 445 'data': [ 446 39.32178497314453, 44.523738861083984, 58.046287536621094, 447 84.13702392578125 448 ], 449 'descriptor': {shape: [2, 2, 1], dataType: 'float32'} 450 } 451 }, 452 'operators': [{ 453 'name': 'max', 454 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 455 'outputs': 'output' 456 }], 457 'expectedOutputs': { 458 'output': { 459 'data': [ 460 39.32178497314453, 88.1480712890625, 39.32178497314453, 461 44.523738861083984, 44.523738861083984, 44.523738861083984, 462 58.046287536621094, 58.046287536621094, 58.046287536621094, 463 84.13702392578125, 84.13702392578125, 84.13702392578125, 464 39.32178497314453, 39.32178497314453, 57.25886917114258, 465 44.523738861083984, 73.71659851074219, 44.523738861083984, 466 79.85667419433594, 58.046287536621094, 58.046287536621094, 467 84.13702392578125, 99.89971160888672, 84.13702392578125 468 ], 469 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 470 } 471 } 472 } 473 }, 474 { 475 'name': 'max float32 broadcast 4D to 4D', 476 'graph': { 477 'inputs': { 478 'inputA': { 479 'data': [48.26115417480469], 480 'descriptor': {shape: [1, 1, 1, 1], dataType: 'float32'} 481 }, 482 'inputB': { 483 'data': [ 484 17.72909164428711, 88.1480712890625, -12.794827461242676, 485 11.817361831665039, 19.51302146911621, -62.87843704223633, 486 50.771915435791016, -56.91352081298828, 50.57254409790039, 487 -96.00484466552734, 50.21434020996094, 20.59501075744629, 488 -60.699546813964844, -96.84203338623047, 57.25886917114258, 489 -56.29146194458008, 73.71659851074219, 21.347652435302734, 490 79.85667419433594, -22.918458938598633, 1.2300019264221191, 491 65.67964935302734, 99.89971160888672, -62.321685791015625 492 ], 493 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 494 } 495 }, 496 'operators': [{ 497 'name': 'max', 498 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 499 'outputs': 'output' 500 }], 501 'expectedOutputs': { 502 'output': { 503 'data': [ 504 48.26115417480469, 88.1480712890625, 48.26115417480469, 505 48.26115417480469, 48.26115417480469, 48.26115417480469, 506 50.771915435791016, 48.26115417480469, 50.57254409790039, 507 48.26115417480469, 50.21434020996094, 48.26115417480469, 508 48.26115417480469, 48.26115417480469, 57.25886917114258, 509 48.26115417480469, 73.71659851074219, 48.26115417480469, 510 79.85667419433594, 48.26115417480469, 48.26115417480469, 511 65.67964935302734, 99.89971160888672, 48.26115417480469 512 ], 513 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 514 } 515 } 516 } 517 }, 518 519 // float16 tests 520 { 521 'name': 'max float16 1D constant tensors', 522 'graph': { 523 'inputs': { 524 'inputA': { 525 'data': [ 526 17.734375, 88.125, -12.796875, 11.8203125, 19.515625, -62.875, 527 50.78125, -56.90625, 50.5625, -96, 50.21875, 20.59375, 528 -60.6875, -96.8125, 57.25, -56.28125, 73.6875, 21.34375, 529 79.875, -22.921875, 1.23046875, 65.6875, 99.875, -62.3125 530 ], 531 'descriptor': {shape: [24], dataType: 'float16'}, 532 'constant': true 533 }, 534 'inputB': { 535 'data': [ 536 -34.5, 85.75, 25.8125, -91.375, 87, 537 0.177490234375, 74.875, -4.16796875, -73.75, 55.375, 538 -58.6875, -67.625, -89.8125, -8.2734375, 97.625, 539 -48.96875, 95.375, -97.375, -59.90625, 97.125, 540 -40.21875, -61.5, 33.375, 12.6953125 541 ], 542 'descriptor': {shape: [24], dataType: 'float16'}, 543 'constant': true 544 } 545 }, 546 'operators': [{ 547 'name': 'max', 548 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 549 'outputs': 'output' 550 }], 551 'expectedOutputs': { 552 'output': { 553 'data': [ 554 17.734375, 88.125, 25.8125, 11.8203125, 87, 555 0.177490234375, 74.875, -4.16796875, 50.5625, 55.375, 556 50.21875, 20.59375, -60.6875, -8.2734375, 97.625, 557 -48.96875, 95.375, 21.34375, 79.875, 97.125, 558 1.23046875, 65.6875, 99.875, 12.6953125 559 ], 560 'descriptor': {shape: [24], dataType: 'float16'} 561 } 562 } 563 } 564 }, 565 { 566 'name': 'max float16 1D tensors', 567 'graph': { 568 'inputs': { 569 'inputA': { 570 'data': [ 571 17.734375, 88.125, -12.796875, 11.8203125, 19.515625, -62.875, 572 50.78125, -56.90625, 50.5625, -96, 50.21875, 20.59375, 573 -60.6875, -96.8125, 57.25, -56.28125, 73.6875, 21.34375, 574 79.875, -22.921875, 1.23046875, 65.6875, 99.875, -62.3125 575 ], 576 'descriptor': {shape: [24], dataType: 'float16'} 577 }, 578 'inputB': { 579 'data': [ 580 -34.5, 85.75, 25.8125, -91.375, 87, 581 0.177490234375, 74.875, -4.16796875, -73.75, 55.375, 582 -58.6875, -67.625, -89.8125, -8.2734375, 97.625, 583 -48.96875, 95.375, -97.375, -59.90625, 97.125, 584 -40.21875, -61.5, 33.375, 12.6953125 585 ], 586 'descriptor': {shape: [24], dataType: 'float16'} 587 } 588 }, 589 'operators': [{ 590 'name': 'max', 591 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 592 'outputs': 'output' 593 }], 594 'expectedOutputs': { 595 'output': { 596 'data': [ 597 17.734375, 88.125, 25.8125, 11.8203125, 87, 598 0.177490234375, 74.875, -4.16796875, 50.5625, 55.375, 599 50.21875, 20.59375, -60.6875, -8.2734375, 97.625, 600 -48.96875, 95.375, 21.34375, 79.875, 97.125, 601 1.23046875, 65.6875, 99.875, 12.6953125 602 ], 603 'descriptor': {shape: [24], dataType: 'float16'} 604 } 605 } 606 } 607 }, 608 { 609 'name': 'max float16 2D tensors', 610 'graph': { 611 'inputs': { 612 'inputA': { 613 'data': [ 614 17.734375, 88.125, -12.796875, 11.8203125, 19.515625, -62.875, 615 50.78125, -56.90625, 50.5625, -96, 50.21875, 20.59375, 616 -60.6875, -96.8125, 57.25, -56.28125, 73.6875, 21.34375, 617 79.875, -22.921875, 1.23046875, 65.6875, 99.875, -62.3125 618 ], 619 'descriptor': {shape: [4, 6], dataType: 'float16'} 620 }, 621 'inputB': { 622 'data': [ 623 -34.5, 85.75, 25.8125, -91.375, 87, 624 0.177490234375, 74.875, -4.16796875, -73.75, 55.375, 625 -58.6875, -67.625, -89.8125, -8.2734375, 97.625, 626 -48.96875, 95.375, -97.375, -59.90625, 97.125, 627 -40.21875, -61.5, 33.375, 12.6953125 628 ], 629 'descriptor': {shape: [4, 6], dataType: 'float16'} 630 } 631 }, 632 'operators': [{ 633 'name': 'max', 634 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 635 'outputs': 'output' 636 }], 637 'expectedOutputs': { 638 'output': { 639 'data': [ 640 17.734375, 88.125, 25.8125, 11.8203125, 87, 641 0.177490234375, 74.875, -4.16796875, 50.5625, 55.375, 642 50.21875, 20.59375, -60.6875, -8.2734375, 97.625, 643 -48.96875, 95.375, 21.34375, 79.875, 97.125, 644 1.23046875, 65.6875, 99.875, 12.6953125 645 ], 646 'descriptor': {shape: [4, 6], dataType: 'float16'} 647 } 648 } 649 } 650 }, 651 { 652 'name': 'max float16 3D tensors', 653 'graph': { 654 'inputs': { 655 'inputA': { 656 'data': [ 657 17.734375, 88.125, -12.796875, 11.8203125, 19.515625, -62.875, 658 50.78125, -56.90625, 50.5625, -96, 50.21875, 20.59375, 659 -60.6875, -96.8125, 57.25, -56.28125, 73.6875, 21.34375, 660 79.875, -22.921875, 1.23046875, 65.6875, 99.875, -62.3125 661 ], 662 'descriptor': {shape: [2, 3, 4], dataType: 'float16'} 663 }, 664 'inputB': { 665 'data': [ 666 -34.5, 85.75, 25.8125, -91.375, 87, 667 0.177490234375, 74.875, -4.16796875, -73.75, 55.375, 668 -58.6875, -67.625, -89.8125, -8.2734375, 97.625, 669 -48.96875, 95.375, -97.375, -59.90625, 97.125, 670 -40.21875, -61.5, 33.375, 12.6953125 671 ], 672 'descriptor': {shape: [2, 3, 4], dataType: 'float16'} 673 } 674 }, 675 'operators': [{ 676 'name': 'max', 677 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 678 'outputs': 'output' 679 }], 680 'expectedOutputs': { 681 'output': { 682 'data': [ 683 17.734375, 88.125, 25.8125, 11.8203125, 87, 684 0.177490234375, 74.875, -4.16796875, 50.5625, 55.375, 685 50.21875, 20.59375, -60.6875, -8.2734375, 97.625, 686 -48.96875, 95.375, 21.34375, 79.875, 97.125, 687 1.23046875, 65.6875, 99.875, 12.6953125 688 ], 689 'descriptor': {shape: [2, 3, 4], dataType: 'float16'} 690 } 691 } 692 } 693 }, 694 { 695 'name': 'max float16 4D tensors', 696 'graph': { 697 'inputs': { 698 'inputA': { 699 'data': [ 700 17.734375, 88.125, -12.796875, 11.8203125, 19.515625, -62.875, 701 50.78125, -56.90625, 50.5625, -96, 50.21875, 20.59375, 702 -60.6875, -96.8125, 57.25, -56.28125, 73.6875, 21.34375, 703 79.875, -22.921875, 1.23046875, 65.6875, 99.875, -62.3125 704 ], 705 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 706 }, 707 'inputB': { 708 'data': [ 709 -34.5, 85.75, 25.8125, -91.375, 87, 710 0.177490234375, 74.875, -4.16796875, -73.75, 55.375, 711 -58.6875, -67.625, -89.8125, -8.2734375, 97.625, 712 -48.96875, 95.375, -97.375, -59.90625, 97.125, 713 -40.21875, -61.5, 33.375, 12.6953125 714 ], 715 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 716 } 717 }, 718 'operators': [{ 719 'name': 'max', 720 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 721 'outputs': 'output' 722 }], 723 'expectedOutputs': { 724 'output': { 725 'data': [ 726 17.734375, 88.125, 25.8125, 11.8203125, 87, 727 0.177490234375, 74.875, -4.16796875, 50.5625, 55.375, 728 50.21875, 20.59375, -60.6875, -8.2734375, 97.625, 729 -48.96875, 95.375, 21.34375, 79.875, 97.125, 730 1.23046875, 65.6875, 99.875, 12.6953125 731 ], 732 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 733 } 734 } 735 } 736 }, 737 { 738 'name': 'max float16 5D tensors', 739 'graph': { 740 'inputs': { 741 'inputA': { 742 'data': [ 743 17.734375, 88.125, -12.796875, 11.8203125, 19.515625, -62.875, 744 50.78125, -56.90625, 50.5625, -96, 50.21875, 20.59375, 745 -60.6875, -96.8125, 57.25, -56.28125, 73.6875, 21.34375, 746 79.875, -22.921875, 1.23046875, 65.6875, 99.875, -62.3125 747 ], 748 'descriptor': {shape: [2, 2, 1, 2, 3], dataType: 'float16'} 749 }, 750 'inputB': { 751 'data': [ 752 -34.5, 85.75, 25.8125, -91.375, 87, 753 0.177490234375, 74.875, -4.16796875, -73.75, 55.375, 754 -58.6875, -67.625, -89.8125, -8.2734375, 97.625, 755 -48.96875, 95.375, -97.375, -59.90625, 97.125, 756 -40.21875, -61.5, 33.375, 12.6953125 757 ], 758 'descriptor': {shape: [2, 2, 1, 2, 3], dataType: 'float16'} 759 } 760 }, 761 'operators': [{ 762 'name': 'max', 763 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 764 'outputs': 'output' 765 }], 766 'expectedOutputs': { 767 'output': { 768 'data': [ 769 17.734375, 88.125, 25.8125, 11.8203125, 87, 770 0.177490234375, 74.875, -4.16796875, 50.5625, 55.375, 771 50.21875, 20.59375, -60.6875, -8.2734375, 97.625, 772 -48.96875, 95.375, 21.34375, 79.875, 97.125, 773 1.23046875, 65.6875, 99.875, 12.6953125 774 ], 775 'descriptor': {shape: [2, 2, 1, 2, 3], dataType: 'float16'} 776 } 777 } 778 } 779 }, 780 { 781 'name': 'max float16 broadcast 1D to 4D', 782 'graph': { 783 'inputs': { 784 'inputA': 785 {'data': [48.25], 'descriptor': {shape: [1], dataType: 'float16'}}, 786 'inputB': { 787 'data': [ 788 17.734375, 88.125, -12.796875, 11.8203125, 19.515625, -62.875, 789 50.78125, -56.90625, 50.5625, -96, 50.21875, 20.59375, 790 -60.6875, -96.8125, 57.25, -56.28125, 73.6875, 21.34375, 791 79.875, -22.921875, 1.23046875, 65.6875, 99.875, -62.3125 792 ], 793 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 794 } 795 }, 796 'operators': [{ 797 'name': 'max', 798 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 799 'outputs': 'output' 800 }], 801 'expectedOutputs': { 802 'output': { 803 'data': [ 804 48.25, 88.125, 48.25, 48.25, 48.25, 48.25, 50.78125, 48.25, 805 50.5625, 48.25, 50.21875, 48.25, 48.25, 48.25, 57.25, 48.25, 806 73.6875, 48.25, 79.875, 48.25, 48.25, 65.6875, 99.875, 48.25 807 ], 808 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 809 } 810 } 811 } 812 }, 813 { 814 'name': 'max float16 broadcast 2D to 4D', 815 'graph': { 816 'inputs': { 817 'inputA': { 818 'data': [ 819 17.734375, 88.125, -12.796875, 11.8203125, 19.515625, -62.875, 820 50.78125, -56.90625, 50.5625, -96, 50.21875, 20.59375, 821 -60.6875, -96.8125, 57.25, -56.28125, 73.6875, 21.34375, 822 79.875, -22.921875, 1.23046875, 65.6875, 99.875, -62.3125 823 ], 824 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 825 }, 826 'inputB': { 827 'data': 828 [49.53125, -61.5625, -6.56640625, 93.3125, 3.310546875, -98.3125], 829 'descriptor': {shape: [2, 3], dataType: 'float16'} 830 } 831 }, 832 'operators': [{ 833 'name': 'max', 834 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 835 'outputs': 'output' 836 }], 837 'expectedOutputs': { 838 'output': { 839 'data': [ 840 49.53125, 88.125, -6.56640625, 93.3125, 19.515625, -62.875, 841 50.78125, -56.90625, 50.5625, 93.3125, 50.21875, 20.59375, 842 49.53125, -61.5625, 57.25, 93.3125, 73.6875, 21.34375, 843 79.875, -22.921875, 1.23046875, 93.3125, 99.875, -62.3125 844 ], 845 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 846 } 847 } 848 } 849 }, 850 { 851 'name': 'max float16 broadcast 3D to 4D', 852 'graph': { 853 'inputs': { 854 'inputA': { 855 'data': [ 856 17.734375, 88.125, -12.796875, 11.8203125, 19.515625, -62.875, 857 50.78125, -56.90625, 50.5625, -96, 50.21875, 20.59375, 858 -60.6875, -96.8125, 57.25, -56.28125, 73.6875, 21.34375, 859 79.875, -22.921875, 1.23046875, 65.6875, 99.875, -62.3125 860 ], 861 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 862 }, 863 'inputB': { 864 'data': [39.3125, 44.53125, 58.03125, 84.125], 865 'descriptor': {shape: [2, 2, 1], dataType: 'float16'} 866 } 867 }, 868 'operators': [{ 869 'name': 'max', 870 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 871 'outputs': 'output' 872 }], 873 'expectedOutputs': { 874 'output': { 875 'data': [ 876 39.3125, 88.125, 39.3125, 44.53125, 44.53125, 44.53125, 877 58.03125, 58.03125, 58.03125, 84.125, 84.125, 84.125, 878 39.3125, 39.3125, 57.25, 44.53125, 73.6875, 44.53125, 879 79.875, 58.03125, 58.03125, 84.125, 99.875, 84.125 880 ], 881 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 882 } 883 } 884 } 885 }, 886 { 887 'name': 'max float16 broadcast 4D to 4D', 888 'graph': { 889 'inputs': { 890 'inputA': { 891 'data': [48.25], 892 'descriptor': {shape: [1, 1, 1, 1], dataType: 'float16'} 893 }, 894 'inputB': { 895 'data': [ 896 17.734375, 88.125, -12.796875, 11.8203125, 19.515625, -62.875, 897 50.78125, -56.90625, 50.5625, -96, 50.21875, 20.59375, 898 -60.6875, -96.8125, 57.25, -56.28125, 73.6875, 21.34375, 899 79.875, -22.921875, 1.23046875, 65.6875, 99.875, -62.3125 900 ], 901 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 902 } 903 }, 904 'operators': [{ 905 'name': 'max', 906 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 907 'outputs': 'output' 908 }], 909 'expectedOutputs': { 910 'output': { 911 'data': [ 912 48.25, 88.125, 48.25, 48.25, 48.25, 48.25, 50.78125, 48.25, 913 50.5625, 48.25, 50.21875, 48.25, 48.25, 48.25, 57.25, 48.25, 914 73.6875, 48.25, 79.875, 48.25, 48.25, 65.6875, 99.875, 48.25 915 ], 916 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 917 } 918 } 919 } 920 } 921 ]; 922 923 webnn_conformance_test(maxTests, buildAndExecuteGraph, getPrecisionTolerance);