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