greater.https.any.js (35686B)
1 // META: title=test WebNN API element-wise greater 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-logical 12 // Compare if the values of the first input tensor is greater, element-wise. 13 // 14 // MLOperand greater(MLOperand a, MLOperand b); 15 16 const greaterTests = [ 17 { 18 'name': 'greater float32 0D scalar', 19 'graph': { 20 'inputs': { 21 'inputA': { 22 'data': [3.6851015090942383], 23 'descriptor': {shape: [], dataType: 'float32'} 24 }, 25 'inputB': { 26 'data': [1.723199725151062], 27 'descriptor': {shape: [], dataType: 'float32'} 28 } 29 }, 30 'operators': [{ 31 'name': 'greater', 32 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 33 'outputs': 'output' 34 }], 35 'expectedOutputs': { 36 'output': {'data': [1], 'descriptor': {shape: [], dataType: 'uint8'}} 37 } 38 } 39 }, 40 { 41 'name': 'greater float32 1D constant tensors', 42 'graph': { 43 'inputs': { 44 'inputA': { 45 'data': [ 46 -5.394711494445801, -7.189248561859131, -3.1081764698028564, 47 4.977657318115234, 5.111654281616211, -1.5386580228805542, 48 1.414366364479065, -0.9362112283706665, -6.029961585998535, 49 -3.0134198665618896, 0.170855313539505, 7.395327091217041, 50 7.178691864013672, -4.826237678527832, -2.020440101623535, 51 -3.267888069152832, 8.944384574890137, -5.932100772857666, 52 0.7069857120513916, 2.7764203548431396, 0.978833794593811, 53 -6.254901885986328, 4.409034729003906, -6.775286674499512 54 ], 55 'descriptor': {shape: [24], dataType: 'float32'}, 56 'constant': true 57 }, 58 'inputB': { 59 'data': [ 60 -6.155234336853027, -4.023341178894043, 5.9525980949401855, 61 2.306623697280884, -2.7692291736602783, -0.9711201190948486, 62 1.222206711769104, 4.590261459350586, 9.101232528686523, 63 -4.997007846832275, -4.80729341506958, 8.919360160827637, 64 0.9005027413368225, -2.8414556980133057, -2.8280413150787354, 65 8.47984504699707, -7.84067964553833, 9.213960647583008, 66 4.982365131378174, -2.507319211959839, -4.518013954162598, 67 8.351094245910645, -6.161073207855225, 0.7364829182624817 68 ], 69 'descriptor': {shape: [24], dataType: 'float32'}, 70 'constant': true 71 } 72 }, 73 'operators': [{ 74 'name': 'greater', 75 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 76 'outputs': 'output' 77 }], 78 'expectedOutputs': { 79 'output': { 80 'data': [ 81 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 82 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0 83 ], 84 'descriptor': {shape: [24], dataType: 'uint8'} 85 } 86 } 87 } 88 }, 89 { 90 'name': 'greater float32 1D tensors', 91 'graph': { 92 'inputs': { 93 'inputA': { 94 'data': [ 95 -5.394711494445801, -7.189248561859131, -3.1081764698028564, 96 4.977657318115234, 5.111654281616211, -1.5386580228805542, 97 1.414366364479065, -0.9362112283706665, -6.029961585998535, 98 -3.0134198665618896, 0.170855313539505, 7.395327091217041, 99 7.178691864013672, -4.826237678527832, -2.020440101623535, 100 -3.267888069152832, 8.944384574890137, -5.932100772857666, 101 0.7069857120513916, 2.7764203548431396, 0.978833794593811, 102 -6.254901885986328, 4.409034729003906, -6.775286674499512 103 ], 104 'descriptor': {shape: [24], dataType: 'float32'} 105 }, 106 'inputB': { 107 'data': [ 108 -6.155234336853027, -4.023341178894043, 5.9525980949401855, 109 2.306623697280884, -2.7692291736602783, -0.9711201190948486, 110 1.222206711769104, 4.590261459350586, 9.101232528686523, 111 -4.997007846832275, -4.80729341506958, 8.919360160827637, 112 0.9005027413368225, -2.8414556980133057, -2.8280413150787354, 113 8.47984504699707, -7.84067964553833, 9.213960647583008, 114 4.982365131378174, -2.507319211959839, -4.518013954162598, 115 8.351094245910645, -6.161073207855225, 0.7364829182624817 116 ], 117 'descriptor': {shape: [24], dataType: 'float32'} 118 } 119 }, 120 'operators': [{ 121 'name': 'greater', 122 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 123 'outputs': 'output' 124 }], 125 'expectedOutputs': { 126 'output': { 127 'data': [ 128 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 129 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0 130 ], 131 'descriptor': {shape: [24], dataType: 'uint8'} 132 } 133 } 134 } 135 }, 136 { 137 'name': 'greater float32 2D tensors', 138 'graph': { 139 'inputs': { 140 'inputA': { 141 'data': [ 142 -5.394711494445801, -7.189248561859131, -3.1081764698028564, 143 4.977657318115234, 5.111654281616211, -1.5386580228805542, 144 1.414366364479065, -0.9362112283706665, -6.029961585998535, 145 -3.0134198665618896, 0.170855313539505, 7.395327091217041, 146 7.178691864013672, -4.826237678527832, -2.020440101623535, 147 -3.267888069152832, 8.944384574890137, -5.932100772857666, 148 0.7069857120513916, 2.7764203548431396, 0.978833794593811, 149 -6.254901885986328, 4.409034729003906, -6.775286674499512 150 ], 151 'descriptor': {shape: [4, 6], dataType: 'float32'} 152 }, 153 'inputB': { 154 'data': [ 155 -6.155234336853027, -4.023341178894043, 5.9525980949401855, 156 2.306623697280884, -2.7692291736602783, -0.9711201190948486, 157 1.222206711769104, 4.590261459350586, 9.101232528686523, 158 -4.997007846832275, -4.80729341506958, 8.919360160827637, 159 0.9005027413368225, -2.8414556980133057, -2.8280413150787354, 160 8.47984504699707, -7.84067964553833, 9.213960647583008, 161 4.982365131378174, -2.507319211959839, -4.518013954162598, 162 8.351094245910645, -6.161073207855225, 0.7364829182624817 163 ], 164 'descriptor': {shape: [4, 6], dataType: 'float32'} 165 } 166 }, 167 'operators': [{ 168 'name': 'greater', 169 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 170 'outputs': 'output' 171 }], 172 'expectedOutputs': { 173 'output': { 174 'data': [ 175 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 176 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0 177 ], 178 'descriptor': {shape: [4, 6], dataType: 'uint8'} 179 } 180 } 181 } 182 }, 183 { 184 'name': 'greater float32 3D tensors', 185 'graph': { 186 'inputs': { 187 'inputA': { 188 'data': [ 189 -5.394711494445801, -7.189248561859131, -3.1081764698028564, 190 4.977657318115234, 5.111654281616211, -1.5386580228805542, 191 1.414366364479065, -0.9362112283706665, -6.029961585998535, 192 -3.0134198665618896, 0.170855313539505, 7.395327091217041, 193 7.178691864013672, -4.826237678527832, -2.020440101623535, 194 -3.267888069152832, 8.944384574890137, -5.932100772857666, 195 0.7069857120513916, 2.7764203548431396, 0.978833794593811, 196 -6.254901885986328, 4.409034729003906, -6.775286674499512 197 ], 198 'descriptor': {shape: [2, 3, 4], dataType: 'float32'} 199 }, 200 'inputB': { 201 'data': [ 202 -6.155234336853027, -4.023341178894043, 5.9525980949401855, 203 2.306623697280884, -2.7692291736602783, -0.9711201190948486, 204 1.222206711769104, 4.590261459350586, 9.101232528686523, 205 -4.997007846832275, -4.80729341506958, 8.919360160827637, 206 0.9005027413368225, -2.8414556980133057, -2.8280413150787354, 207 8.47984504699707, -7.84067964553833, 9.213960647583008, 208 4.982365131378174, -2.507319211959839, -4.518013954162598, 209 8.351094245910645, -6.161073207855225, 0.7364829182624817 210 ], 211 'descriptor': {shape: [2, 3, 4], dataType: 'float32'} 212 } 213 }, 214 'operators': [{ 215 'name': 'greater', 216 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 217 'outputs': 'output' 218 }], 219 'expectedOutputs': { 220 'output': { 221 'data': [ 222 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 223 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0 224 ], 225 'descriptor': {shape: [2, 3, 4], dataType: 'uint8'} 226 } 227 } 228 } 229 }, 230 { 231 'name': 'greater float32 4D tensors', 232 'graph': { 233 'inputs': { 234 'inputA': { 235 'data': [ 236 -5.394711494445801, -7.189248561859131, -3.1081764698028564, 237 4.977657318115234, 5.111654281616211, -1.5386580228805542, 238 1.414366364479065, -0.9362112283706665, -6.029961585998535, 239 -3.0134198665618896, 0.170855313539505, 7.395327091217041, 240 7.178691864013672, -4.826237678527832, -2.020440101623535, 241 -3.267888069152832, 8.944384574890137, -5.932100772857666, 242 0.7069857120513916, 2.7764203548431396, 0.978833794593811, 243 -6.254901885986328, 4.409034729003906, -6.775286674499512 244 ], 245 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 246 }, 247 'inputB': { 248 'data': [ 249 -6.155234336853027, -4.023341178894043, 5.9525980949401855, 250 2.306623697280884, -2.7692291736602783, -0.9711201190948486, 251 1.222206711769104, 4.590261459350586, 9.101232528686523, 252 -4.997007846832275, -4.80729341506958, 8.919360160827637, 253 0.9005027413368225, -2.8414556980133057, -2.8280413150787354, 254 8.47984504699707, -7.84067964553833, 9.213960647583008, 255 4.982365131378174, -2.507319211959839, -4.518013954162598, 256 8.351094245910645, -6.161073207855225, 0.7364829182624817 257 ], 258 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 259 } 260 }, 261 'operators': [{ 262 'name': 'greater', 263 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 264 'outputs': 'output' 265 }], 266 'expectedOutputs': { 267 'output': { 268 'data': [ 269 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 270 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0 271 ], 272 'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint8'} 273 } 274 } 275 } 276 }, 277 { 278 'name': 'greater float32 5D tensors', 279 'graph': { 280 'inputs': { 281 'inputA': { 282 'data': [ 283 -5.394711494445801, -7.189248561859131, -3.1081764698028564, 284 4.977657318115234, 5.111654281616211, -1.5386580228805542, 285 1.414366364479065, -0.9362112283706665, -6.029961585998535, 286 -3.0134198665618896, 0.170855313539505, 7.395327091217041, 287 7.178691864013672, -4.826237678527832, -2.020440101623535, 288 -3.267888069152832, 8.944384574890137, -5.932100772857666, 289 0.7069857120513916, 2.7764203548431396, 0.978833794593811, 290 -6.254901885986328, 4.409034729003906, -6.775286674499512 291 ], 292 'descriptor': {shape: [2, 2, 1, 2, 3], dataType: 'float32'} 293 }, 294 'inputB': { 295 'data': [ 296 -6.155234336853027, -4.023341178894043, 5.9525980949401855, 297 2.306623697280884, -2.7692291736602783, -0.9711201190948486, 298 1.222206711769104, 4.590261459350586, 9.101232528686523, 299 -4.997007846832275, -4.80729341506958, 8.919360160827637, 300 0.9005027413368225, -2.8414556980133057, -2.8280413150787354, 301 8.47984504699707, -7.84067964553833, 9.213960647583008, 302 4.982365131378174, -2.507319211959839, -4.518013954162598, 303 8.351094245910645, -6.161073207855225, 0.7364829182624817 304 ], 305 'descriptor': {shape: [2, 2, 1, 2, 3], dataType: 'float32'} 306 } 307 }, 308 'operators': [{ 309 'name': 'greater', 310 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 311 'outputs': 'output' 312 }], 313 'expectedOutputs': { 314 'output': { 315 'data': [ 316 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 317 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0 318 ], 319 'descriptor': {shape: [2, 2, 1, 2, 3], dataType: 'uint8'} 320 } 321 } 322 } 323 }, 324 { 325 'name': 'greater float32 broadcast 0D to 4D', 326 'graph': { 327 'inputs': { 328 'inputA': { 329 'data': [6.2216410636901855], 330 'descriptor': {shape: [], dataType: 'float32'} 331 }, 332 'inputB': { 333 'data': [ 334 -5.394711494445801, -7.189248561859131, -3.1081764698028564, 335 4.977657318115234, 5.111654281616211, -1.5386580228805542, 336 1.414366364479065, -0.9362112283706665, -6.029961585998535, 337 -3.0134198665618896, 0.170855313539505, 7.395327091217041, 338 7.178691864013672, -4.826237678527832, -2.020440101623535, 339 -3.267888069152832, 8.944384574890137, -5.932100772857666, 340 0.7069857120513916, 2.7764203548431396, 0.978833794593811, 341 -6.254901885986328, 4.409034729003906, -6.775286674499512 342 ], 343 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 344 } 345 }, 346 'operators': [{ 347 'name': 'greater', 348 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 349 'outputs': 'output' 350 }], 351 'expectedOutputs': { 352 'output': { 353 'data': [ 354 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 355 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1 356 ], 357 'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint8'} 358 } 359 } 360 } 361 }, 362 { 363 'name': 'greater float32 broadcast 1D to 4D', 364 'graph': { 365 'inputs': { 366 'inputA': { 367 'data': [6.2216410636901855], 368 'descriptor': {shape: [1], dataType: 'float32'} 369 }, 370 'inputB': { 371 'data': [ 372 -5.394711494445801, -7.189248561859131, -3.1081764698028564, 373 4.977657318115234, 5.111654281616211, -1.5386580228805542, 374 1.414366364479065, -0.9362112283706665, -6.029961585998535, 375 -3.0134198665618896, 0.170855313539505, 7.395327091217041, 376 7.178691864013672, -4.826237678527832, -2.020440101623535, 377 -3.267888069152832, 8.944384574890137, -5.932100772857666, 378 0.7069857120513916, 2.7764203548431396, 0.978833794593811, 379 -6.254901885986328, 4.409034729003906, -6.775286674499512 380 ], 381 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 382 } 383 }, 384 'operators': [{ 385 'name': 'greater', 386 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 387 'outputs': 'output' 388 }], 389 'expectedOutputs': { 390 'output': { 391 'data': [ 392 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 393 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1 394 ], 395 'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint8'} 396 } 397 } 398 } 399 }, 400 { 401 'name': 'greater float32 broadcast 2D to 4D', 402 'graph': { 403 'inputs': { 404 'inputA': { 405 'data': [ 406 -5.394711494445801, -7.189248561859131, -3.1081764698028564, 407 4.977657318115234, 5.111654281616211, -1.5386580228805542, 408 1.414366364479065, -0.9362112283706665, -6.029961585998535, 409 -3.0134198665618896, 0.170855313539505, 7.395327091217041, 410 7.178691864013672, -4.826237678527832, -2.020440101623535, 411 -3.267888069152832, 8.944384574890137, -5.932100772857666, 412 0.7069857120513916, 2.7764203548431396, 0.978833794593811, 413 -6.254901885986328, 4.409034729003906, -6.775286674499512 414 ], 415 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 416 }, 417 'inputB': { 418 'data': [ 419 -2.684664487838745, 6.170023441314697, 9.487744331359863, 420 -2.5556411743164062, -2.0436434745788574, 8.533930778503418 421 ], 422 'descriptor': {shape: [2, 3], dataType: 'float32'} 423 } 424 }, 425 'operators': [{ 426 'name': 'greater', 427 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 428 'outputs': 'output' 429 }], 430 'expectedOutputs': { 431 'output': { 432 'data': [ 433 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 434 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0 435 ], 436 'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint8'} 437 } 438 } 439 } 440 }, 441 { 442 'name': 'greater float32 broadcast 3D to 4D', 443 'graph': { 444 'inputs': { 445 'inputA': { 446 'data': [ 447 -5.394711494445801, -7.189248561859131, -3.1081764698028564, 448 4.977657318115234, 5.111654281616211, -1.5386580228805542, 449 1.414366364479065, -0.9362112283706665, -6.029961585998535, 450 -3.0134198665618896, 0.170855313539505, 7.395327091217041, 451 7.178691864013672, -4.826237678527832, -2.020440101623535, 452 -3.267888069152832, 8.944384574890137, -5.932100772857666, 453 0.7069857120513916, 2.7764203548431396, 0.978833794593811, 454 -6.254901885986328, 4.409034729003906, -6.775286674499512 455 ], 456 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 457 }, 458 'inputB': { 459 'data': [ 460 -7.099076271057129, -7.781408309936523, 8.782817840576172, 461 -8.948624610900879 462 ], 463 'descriptor': {shape: [2, 2, 1], dataType: 'float32'} 464 } 465 }, 466 'operators': [{ 467 'name': 'greater', 468 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 469 'outputs': 'output' 470 }], 471 'expectedOutputs': { 472 'output': { 473 'data': [ 474 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 475 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1 476 ], 477 'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint8'} 478 } 479 } 480 } 481 }, 482 { 483 'name': 'greater float32 broadcast 4D to 4D', 484 'graph': { 485 'inputs': { 486 'inputA': { 487 'data': [6.2216410636901855], 488 'descriptor': {shape: [1, 1, 1, 1], dataType: 'float32'} 489 }, 490 'inputB': { 491 'data': [ 492 -5.394711494445801, -7.189248561859131, -3.1081764698028564, 493 4.977657318115234, 5.111654281616211, -1.5386580228805542, 494 1.414366364479065, -0.9362112283706665, -6.029961585998535, 495 -3.0134198665618896, 0.170855313539505, 7.395327091217041, 496 7.178691864013672, -4.826237678527832, -2.020440101623535, 497 -3.267888069152832, 8.944384574890137, -5.932100772857666, 498 0.7069857120513916, 2.7764203548431396, 0.978833794593811, 499 -6.254901885986328, 4.409034729003906, -6.775286674499512 500 ], 501 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'} 502 } 503 }, 504 'operators': [{ 505 'name': 'greater', 506 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 507 'outputs': 'output' 508 }], 509 'expectedOutputs': { 510 'output': { 511 'data': [ 512 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 513 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1 514 ], 515 'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint8'} 516 } 517 } 518 } 519 }, 520 521 // float16 tests 522 { 523 'name': 'greater float16 0D scalar', 524 'graph': { 525 'inputs': { 526 'inputA': { 527 'data': [3.685546875], 528 'descriptor': {shape: [], dataType: 'float16'} 529 }, 530 'inputB': { 531 'data': [1.7236328125], 532 'descriptor': {shape: [], dataType: 'float16'} 533 } 534 }, 535 'operators': [{ 536 'name': 'greater', 537 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 538 'outputs': 'output' 539 }], 540 'expectedOutputs': { 541 'output': {'data': [1], 'descriptor': {shape: [], dataType: 'uint8'}} 542 } 543 } 544 }, 545 { 546 'name': 'greater float16 1D constant tensors', 547 'graph': { 548 'inputs': { 549 'inputA': { 550 'data': [ 551 -5.39453125, -7.1875, -3.107421875, 4.9765625, 552 5.11328125, -1.5390625, 1.4140625, -0.93603515625, 553 -6.03125, -3.013671875, 0.1708984375, 7.39453125, 554 7.1796875, -4.828125, -2.01953125, -3.267578125, 555 8.9453125, -5.93359375, 0.70703125, 2.77734375, 556 0.97900390625, -6.25390625, 4.41015625, -6.7734375 557 ], 558 'descriptor': {shape: [24], dataType: 'float16'}, 559 'constant': true 560 }, 561 'inputB': { 562 'data': [ 563 -6.15625, -4.0234375, 5.953125, 2.306640625, -2.76953125, 564 -0.97119140625, 1.22265625, 4.58984375, 9.1015625, -4.99609375, 565 -4.80859375, 8.921875, 0.900390625, -2.841796875, -2.828125, 566 8.4765625, -7.83984375, 9.2109375, 4.98046875, -2.5078125, 567 -4.51953125, 8.3515625, -6.16015625, 0.736328125 568 ], 569 'descriptor': {shape: [24], dataType: 'float16'}, 570 'constant': true 571 } 572 }, 573 'operators': [{ 574 'name': 'greater', 575 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 576 'outputs': 'output' 577 }], 578 'expectedOutputs': { 579 'output': { 580 'data': [ 581 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 582 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0 583 ], 584 'descriptor': {shape: [24], dataType: 'uint8'} 585 } 586 } 587 } 588 }, 589 { 590 'name': 'greater float16 1D tensors', 591 'graph': { 592 'inputs': { 593 'inputA': { 594 'data': [ 595 -5.39453125, -7.1875, -3.107421875, 4.9765625, 596 5.11328125, -1.5390625, 1.4140625, -0.93603515625, 597 -6.03125, -3.013671875, 0.1708984375, 7.39453125, 598 7.1796875, -4.828125, -2.01953125, -3.267578125, 599 8.9453125, -5.93359375, 0.70703125, 2.77734375, 600 0.97900390625, -6.25390625, 4.41015625, -6.7734375 601 ], 602 'descriptor': {shape: [24], dataType: 'float16'} 603 }, 604 'inputB': { 605 'data': [ 606 -6.15625, -4.0234375, 5.953125, 2.306640625, -2.76953125, 607 -0.97119140625, 1.22265625, 4.58984375, 9.1015625, -4.99609375, 608 -4.80859375, 8.921875, 0.900390625, -2.841796875, -2.828125, 609 8.4765625, -7.83984375, 9.2109375, 4.98046875, -2.5078125, 610 -4.51953125, 8.3515625, -6.16015625, 0.736328125 611 ], 612 'descriptor': {shape: [24], dataType: 'float16'} 613 } 614 }, 615 'operators': [{ 616 'name': 'greater', 617 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 618 'outputs': 'output' 619 }], 620 'expectedOutputs': { 621 'output': { 622 'data': [ 623 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 624 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0 625 ], 626 'descriptor': {shape: [24], dataType: 'uint8'} 627 } 628 } 629 } 630 }, 631 { 632 'name': 'greater float16 2D tensors', 633 'graph': { 634 'inputs': { 635 'inputA': { 636 'data': [ 637 -5.39453125, -7.1875, -3.107421875, 4.9765625, 638 5.11328125, -1.5390625, 1.4140625, -0.93603515625, 639 -6.03125, -3.013671875, 0.1708984375, 7.39453125, 640 7.1796875, -4.828125, -2.01953125, -3.267578125, 641 8.9453125, -5.93359375, 0.70703125, 2.77734375, 642 0.97900390625, -6.25390625, 4.41015625, -6.7734375 643 ], 644 'descriptor': {shape: [4, 6], dataType: 'float16'} 645 }, 646 'inputB': { 647 'data': [ 648 -6.15625, -4.0234375, 5.953125, 2.306640625, -2.76953125, 649 -0.97119140625, 1.22265625, 4.58984375, 9.1015625, -4.99609375, 650 -4.80859375, 8.921875, 0.900390625, -2.841796875, -2.828125, 651 8.4765625, -7.83984375, 9.2109375, 4.98046875, -2.5078125, 652 -4.51953125, 8.3515625, -6.16015625, 0.736328125 653 ], 654 'descriptor': {shape: [4, 6], dataType: 'float16'} 655 } 656 }, 657 'operators': [{ 658 'name': 'greater', 659 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 660 'outputs': 'output' 661 }], 662 'expectedOutputs': { 663 'output': { 664 'data': [ 665 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 666 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0 667 ], 668 'descriptor': {shape: [4, 6], dataType: 'uint8'} 669 } 670 } 671 } 672 }, 673 { 674 'name': 'greater float16 3D tensors', 675 'graph': { 676 'inputs': { 677 'inputA': { 678 'data': [ 679 -5.39453125, -7.1875, -3.107421875, 4.9765625, 680 5.11328125, -1.5390625, 1.4140625, -0.93603515625, 681 -6.03125, -3.013671875, 0.1708984375, 7.39453125, 682 7.1796875, -4.828125, -2.01953125, -3.267578125, 683 8.9453125, -5.93359375, 0.70703125, 2.77734375, 684 0.97900390625, -6.25390625, 4.41015625, -6.7734375 685 ], 686 'descriptor': {shape: [2, 3, 4], dataType: 'float16'} 687 }, 688 'inputB': { 689 'data': [ 690 -6.15625, -4.0234375, 5.953125, 2.306640625, -2.76953125, 691 -0.97119140625, 1.22265625, 4.58984375, 9.1015625, -4.99609375, 692 -4.80859375, 8.921875, 0.900390625, -2.841796875, -2.828125, 693 8.4765625, -7.83984375, 9.2109375, 4.98046875, -2.5078125, 694 -4.51953125, 8.3515625, -6.16015625, 0.736328125 695 ], 696 'descriptor': {shape: [2, 3, 4], dataType: 'float16'} 697 } 698 }, 699 'operators': [{ 700 'name': 'greater', 701 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 702 'outputs': 'output' 703 }], 704 'expectedOutputs': { 705 'output': { 706 'data': [ 707 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 708 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0 709 ], 710 'descriptor': {shape: [2, 3, 4], dataType: 'uint8'} 711 } 712 } 713 } 714 }, 715 { 716 'name': 'greater float16 4D tensors', 717 'graph': { 718 'inputs': { 719 'inputA': { 720 'data': [ 721 -5.39453125, -7.1875, -3.107421875, 4.9765625, 722 5.11328125, -1.5390625, 1.4140625, -0.93603515625, 723 -6.03125, -3.013671875, 0.1708984375, 7.39453125, 724 7.1796875, -4.828125, -2.01953125, -3.267578125, 725 8.9453125, -5.93359375, 0.70703125, 2.77734375, 726 0.97900390625, -6.25390625, 4.41015625, -6.7734375 727 ], 728 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 729 }, 730 'inputB': { 731 'data': [ 732 -6.15625, -4.0234375, 5.953125, 2.306640625, -2.76953125, 733 -0.97119140625, 1.22265625, 4.58984375, 9.1015625, -4.99609375, 734 -4.80859375, 8.921875, 0.900390625, -2.841796875, -2.828125, 735 8.4765625, -7.83984375, 9.2109375, 4.98046875, -2.5078125, 736 -4.51953125, 8.3515625, -6.16015625, 0.736328125 737 ], 738 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 739 } 740 }, 741 'operators': [{ 742 'name': 'greater', 743 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 744 'outputs': 'output' 745 }], 746 'expectedOutputs': { 747 'output': { 748 'data': [ 749 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 750 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0 751 ], 752 'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint8'} 753 } 754 } 755 } 756 }, 757 { 758 'name': 'greater float16 5D tensors', 759 'graph': { 760 'inputs': { 761 'inputA': { 762 'data': [ 763 -5.39453125, -7.1875, -3.107421875, 4.9765625, 764 5.11328125, -1.5390625, 1.4140625, -0.93603515625, 765 -6.03125, -3.013671875, 0.1708984375, 7.39453125, 766 7.1796875, -4.828125, -2.01953125, -3.267578125, 767 8.9453125, -5.93359375, 0.70703125, 2.77734375, 768 0.97900390625, -6.25390625, 4.41015625, -6.7734375 769 ], 770 'descriptor': {shape: [2, 2, 1, 2, 3], dataType: 'float16'} 771 }, 772 'inputB': { 773 'data': [ 774 -6.15625, -4.0234375, 5.953125, 2.306640625, -2.76953125, 775 -0.97119140625, 1.22265625, 4.58984375, 9.1015625, -4.99609375, 776 -4.80859375, 8.921875, 0.900390625, -2.841796875, -2.828125, 777 8.4765625, -7.83984375, 9.2109375, 4.98046875, -2.5078125, 778 -4.51953125, 8.3515625, -6.16015625, 0.736328125 779 ], 780 'descriptor': {shape: [2, 2, 1, 2, 3], dataType: 'float16'} 781 } 782 }, 783 'operators': [{ 784 'name': 'greater', 785 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 786 'outputs': 'output' 787 }], 788 'expectedOutputs': { 789 'output': { 790 'data': [ 791 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 792 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0 793 ], 794 'descriptor': {shape: [2, 2, 1, 2, 3], dataType: 'uint8'} 795 } 796 } 797 } 798 }, 799 { 800 'name': 'greater float16 broadcast 0D to 4D', 801 'graph': { 802 'inputs': { 803 'inputA': { 804 'data': [6.22265625], 805 'descriptor': {shape: [], dataType: 'float16'} 806 }, 807 'inputB': { 808 'data': [ 809 -5.39453125, -7.1875, -3.107421875, 4.9765625, 810 5.11328125, -1.5390625, 1.4140625, -0.93603515625, 811 -6.03125, -3.013671875, 0.1708984375, 7.39453125, 812 7.1796875, -4.828125, -2.01953125, -3.267578125, 813 8.9453125, -5.93359375, 0.70703125, 2.77734375, 814 0.97900390625, -6.25390625, 4.41015625, -6.7734375 815 ], 816 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 817 } 818 }, 819 'operators': [{ 820 'name': 'greater', 821 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 822 'outputs': 'output' 823 }], 824 'expectedOutputs': { 825 'output': { 826 'data': [ 827 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 828 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1 829 ], 830 'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint8'} 831 } 832 } 833 } 834 }, 835 { 836 'name': 'greater float16 broadcast 1D to 4D', 837 'graph': { 838 'inputs': { 839 'inputA': { 840 'data': [6.22265625], 841 'descriptor': {shape: [1], dataType: 'float16'} 842 }, 843 'inputB': { 844 'data': [ 845 -5.39453125, -7.1875, -3.107421875, 4.9765625, 846 5.11328125, -1.5390625, 1.4140625, -0.93603515625, 847 -6.03125, -3.013671875, 0.1708984375, 7.39453125, 848 7.1796875, -4.828125, -2.01953125, -3.267578125, 849 8.9453125, -5.93359375, 0.70703125, 2.77734375, 850 0.97900390625, -6.25390625, 4.41015625, -6.7734375 851 ], 852 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 853 } 854 }, 855 'operators': [{ 856 'name': 'greater', 857 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 858 'outputs': 'output' 859 }], 860 'expectedOutputs': { 861 'output': { 862 'data': [ 863 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 864 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1 865 ], 866 'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint8'} 867 } 868 } 869 } 870 }, 871 { 872 'name': 'greater float16 broadcast 2D to 4D', 873 'graph': { 874 'inputs': { 875 'inputA': { 876 'data': [ 877 -5.39453125, -7.1875, -3.107421875, 4.9765625, 878 5.11328125, -1.5390625, 1.4140625, -0.93603515625, 879 -6.03125, -3.013671875, 0.1708984375, 7.39453125, 880 7.1796875, -4.828125, -2.01953125, -3.267578125, 881 8.9453125, -5.93359375, 0.70703125, 2.77734375, 882 0.97900390625, -6.25390625, 4.41015625, -6.7734375 883 ], 884 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 885 }, 886 'inputB': { 887 'data': [ 888 -2.685546875, 6.171875, 9.484375, -2.5546875, -2.04296875, 8.53125 889 ], 890 'descriptor': {shape: [2, 3], dataType: 'float16'} 891 } 892 }, 893 'operators': [{ 894 'name': 'greater', 895 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 896 'outputs': 'output' 897 }], 898 'expectedOutputs': { 899 'output': { 900 'data': [ 901 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 902 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0 903 ], 904 'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint8'} 905 } 906 } 907 } 908 }, 909 { 910 'name': 'greater float16 broadcast 3D to 4D', 911 'graph': { 912 'inputs': { 913 'inputA': { 914 'data': [ 915 -5.39453125, -7.1875, -3.107421875, 4.9765625, 916 5.11328125, -1.5390625, 1.4140625, -0.93603515625, 917 -6.03125, -3.013671875, 0.1708984375, 7.39453125, 918 7.1796875, -4.828125, -2.01953125, -3.267578125, 919 8.9453125, -5.93359375, 0.70703125, 2.77734375, 920 0.97900390625, -6.25390625, 4.41015625, -6.7734375 921 ], 922 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 923 }, 924 'inputB': { 925 'data': [-7.09765625, -7.78125, 8.78125, -8.9453125], 926 'descriptor': {shape: [2, 2, 1], dataType: 'float16'} 927 } 928 }, 929 'operators': [{ 930 'name': 'greater', 931 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 932 'outputs': 'output' 933 }], 934 'expectedOutputs': { 935 'output': { 936 'data': [ 937 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 938 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1 939 ], 940 'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint8'} 941 } 942 } 943 } 944 }, 945 { 946 'name': 'greater float16 broadcast 4D to 4D', 947 'graph': { 948 'inputs': { 949 'inputA': { 950 'data': [6.22265625], 951 'descriptor': {shape: [1, 1, 1, 1], dataType: 'float16'} 952 }, 953 'inputB': { 954 'data': [ 955 -5.39453125, -7.1875, -3.107421875, 4.9765625, 956 5.11328125, -1.5390625, 1.4140625, -0.93603515625, 957 -6.03125, -3.013671875, 0.1708984375, 7.39453125, 958 7.1796875, -4.828125, -2.01953125, -3.267578125, 959 8.9453125, -5.93359375, 0.70703125, 2.77734375, 960 0.97900390625, -6.25390625, 4.41015625, -6.7734375 961 ], 962 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} 963 } 964 }, 965 'operators': [{ 966 'name': 'greater', 967 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], 968 'outputs': 'output' 969 }], 970 'expectedOutputs': { 971 'output': { 972 'data': [ 973 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 974 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1 975 ], 976 'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint8'} 977 } 978 } 979 } 980 } 981 ]; 982 983 webnn_conformance_test(greaterTests, buildAndExecuteGraph, getZeroULPTolerance);