lstm.https.any.js (67954B)
1 // META: title=test WebNN API lstm 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-lstm 12 // Long Short-Term Memory [LSTM] recurrent network uses an input, output, 13 // forget, and cell gate to compute the output state that rolls into the output 14 // across the temporal sequence of the network. 15 // enum MLRecurrentNetworkDirection { 16 // "forward", 17 // "backward", 18 // "both" 19 // }; 20 // 21 // enum MLRecurrentNetworkActivation { 22 // "relu", 23 // "sigmoid", 24 // "tanh" 25 // }; 26 // 27 // enum MLLstmWeightLayout { 28 // "iofg", // input-output-forget-cell gate ordering 29 // "ifgo" // input-forget-cell-output gate ordering 30 // }; 31 // 32 // dictionary MLLstmOptions { 33 // MLOperand bias; 34 // MLOperand recurrentBias; 35 // MLOperand peepholeWeight; 36 // MLOperand initialHiddenState; 37 // MLOperand initialCellState; 38 // boolean returnSequence = false; 39 // MLRecurrentNetworkDirection direction = "forward"; 40 // MLLstmWeightLayout layout = "iofg"; 41 // sequence<MLRecurrentNetworkActivation> activations; 42 // }; 43 // 44 // sequence<MLOperand> lstm(MLOperand input, 45 // MLOperand weight, 46 // MLOperand recurrentWeight, 47 // [EnforceRange] unsigned long steps, 48 // [EnforceRange] unsigned long hiddenSize, 49 // optional MLLstmOptions options = {}); 50 51 52 const getLstmPrecisionTolerance = (graphResources) => { 53 const toleranceValueDict = {float32: 3, float16: 10}; 54 const expectedDataType = 55 graphResources 56 .expectedOutputs[Object.keys(graphResources.expectedOutputs)[0]] 57 .descriptor.dataType; 58 return {metricType: 'ULP', value: toleranceValueDict[expectedDataType]}; 59 }; 60 61 const lstmTests = [ 62 { 63 'name': 64 "lstm float32 tensors steps=1 with options.bias, options.recurrentBias and options.activations=['relu', 'relu', 'relu']", 65 'graph': { 66 'inputs': { 67 'lstmInput': { 68 'data': [1, 2, 2, 1], 69 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 70 }, 71 'lstmWeight': { 72 'data': [1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2], 73 'descriptor': {shape: [1, 8, 2], dataType: 'float32'}, 74 'constant': true 75 }, 76 'lstmRecurrentWeight': { 77 'data': [ 78 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 79 0.1, 0.1, 0.1 80 ], 81 'descriptor': {shape: [1, 8, 2], dataType: 'float32'}, 82 'constant': true 83 }, 84 'lstmBias': { 85 'data': [1, 2, 1, 2, 1, 2, 1, 2], 86 'descriptor': {shape: [1, 8], dataType: 'float32'}, 87 'constant': true 88 }, 89 'lstmRecurrentBias': { 90 'data': [1, 2, 1, 2, 1, 2, 1, 2], 91 'descriptor': {shape: [1, 8], dataType: 'float32'}, 92 'constant': true 93 } 94 }, 95 'operators': [{ 96 'name': 'lstm', 97 'arguments': [ 98 {'input': 'lstmInput'}, {'weight': 'lstmWeight'}, 99 {'recurrentWeight': 'lstmRecurrentWeight'}, {'steps': 1}, 100 {'hiddenSize': 2}, { 101 'options': { 102 'bias': 'lstmBias', 103 'recurrentBias': 'lstmRecurrentBias', 104 'activations': ['relu', 'relu', 'relu'] 105 } 106 } 107 ], 108 'outputs': ['lstmOutput1', 'lstmOutput2'] 109 }], 110 'expectedOutputs': { 111 'lstmOutput1': { 112 'data': [1, 8, 27, 216], 113 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 114 }, 115 'lstmOutput2': { 116 'data': [1, 4, 9, 36], 117 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 118 } 119 } 120 } 121 }, 122 { 123 'name': 124 "lstm float32 tensors steps=1 with options.bias, options.recurrentBias, options.activations=['relu', 'relu', 'relu'] and options.peepholeWeight", 125 'graph': { 126 'inputs': { 127 'lstmInput': { 128 'data': [1, 2, 2, 1], 129 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 130 }, 131 'lstmWeight': { 132 'data': [1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2], 133 'descriptor': {shape: [1, 8, 2], dataType: 'float32'}, 134 'constant': true 135 }, 136 'lstmRecurrentWeight': { 137 'data': [ 138 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 139 0.1, 0.1, 0.1 140 ], 141 'descriptor': {shape: [1, 8, 2], dataType: 'float32'}, 142 'constant': true 143 }, 144 'lstmBias': { 145 'data': [1, 2, 1, 2, 1, 2, 1, 2], 146 'descriptor': {shape: [1, 8], dataType: 'float32'}, 147 'constant': true 148 }, 149 'lstmRecurrentBias': { 150 'data': [1, 2, 1, 2, 1, 2, 1, 2], 151 'descriptor': {shape: [1, 8], dataType: 'float32'}, 152 'constant': true 153 }, 154 'lstmPeepholeWeight': { 155 'data': [0, 0, 0, 0, 0, 0], 156 'descriptor': {shape: [1, 6], dataType: 'float32'}, 157 'constant': true 158 } 159 }, 160 'operators': [{ 161 'name': 'lstm', 162 'arguments': [ 163 {'input': 'lstmInput'}, {'weight': 'lstmWeight'}, 164 {'recurrentWeight': 'lstmRecurrentWeight'}, {'steps': 1}, 165 {'hiddenSize': 2}, { 166 'options': { 167 'bias': 'lstmBias', 168 'recurrentBias': 'lstmRecurrentBias', 169 'peepholeWeight': 'lstmPeepholeWeight', 170 'activations': ['relu', 'relu', 'relu'] 171 } 172 } 173 ], 174 'outputs': ['lstmOutput1', 'lstmOutput2'] 175 }], 176 'expectedOutputs': { 177 'lstmOutput1': { 178 'data': [1, 8, 27, 216], 179 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 180 }, 181 'lstmOutput2': { 182 'data': [1, 4, 9, 36], 183 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 184 } 185 } 186 } 187 }, 188 { 189 'name': 190 "lstm float32 tensors steps=1 with options.bias, options.recurrentBias, options.activations=['relu', 'relu', 'relu'] and options.initialHiddenState", 191 'graph': { 192 'inputs': { 193 'lstmInput': { 194 'data': [1, 2, 2, 1], 195 'descriptor': {shape: [1, 2, 2], dataType: 'float32'}, 196 'constant': true 197 }, 198 'lstmWeight': { 199 'data': [1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2], 200 'descriptor': {shape: [1, 8, 2], dataType: 'float32'}, 201 'constant': true 202 }, 203 'lstmRecurrentWeight': { 204 'data': [ 205 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 206 0.1, 0.1, 0.1 207 ], 208 'descriptor': {shape: [1, 8, 2], dataType: 'float32'}, 209 'constant': true 210 }, 211 'lstmBias': { 212 'data': [1, 2, 1, 2, 1, 2, 1, 2], 213 'descriptor': {shape: [1, 8], dataType: 'float32'}, 214 'constant': true 215 }, 216 'lstmRecurrentBias': { 217 'data': [1, 2, 1, 2, 1, 2, 1, 2], 218 'descriptor': {shape: [1, 8], dataType: 'float32'}, 219 'constant': true 220 }, 221 'lstmInitialHiddenState': { 222 'data': [0, 0, 0, 0], 223 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 224 } 225 }, 226 'operators': [{ 227 'name': 'lstm', 228 'arguments': [ 229 {'input': 'lstmInput'}, {'weight': 'lstmWeight'}, 230 {'recurrentWeight': 'lstmRecurrentWeight'}, {'steps': 1}, 231 {'hiddenSize': 2}, { 232 'options': { 233 'bias': 'lstmBias', 234 'recurrentBias': 'lstmRecurrentBias', 235 'initialHiddenState': 'lstmInitialHiddenState', 236 'activations': ['relu', 'relu', 'relu'] 237 } 238 } 239 ], 240 'outputs': ['lstmOutput1', 'lstmOutput2'] 241 }], 242 'expectedOutputs': { 243 'lstmOutput1': { 244 'data': [1, 8, 27, 216], 245 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 246 }, 247 'lstmOutput2': { 248 'data': [1, 4, 9, 36], 249 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 250 } 251 } 252 } 253 }, 254 { 255 'name': 256 "lstm float32 tensors steps=1 with options.bias, options.recurrentBias, options.activations=['relu', 'relu', 'relu'] and options.initialCellState", 257 'graph': { 258 'inputs': { 259 'lstmInput': { 260 'data': [1, 2, 2, 1], 261 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 262 }, 263 'lstmWeight': { 264 'data': [1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2], 265 'descriptor': {shape: [1, 8, 2], dataType: 'float32'}, 266 'constant': true 267 }, 268 'lstmRecurrentWeight': { 269 'data': [ 270 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 271 0.1, 0.1, 0.1 272 ], 273 'descriptor': {shape: [1, 8, 2], dataType: 'float32'}, 274 'constant': true 275 }, 276 'lstmBias': { 277 'data': [1, 2, 1, 2, 1, 2, 1, 2], 278 'descriptor': {shape: [1, 8], dataType: 'float32'}, 279 'constant': true 280 }, 281 'lstmRecurrentBias': { 282 'data': [1, 2, 1, 2, 1, 2, 1, 2], 283 'descriptor': {shape: [1, 8], dataType: 'float32'}, 284 'constant': true 285 }, 286 'lstmInitialCellState': { 287 'data': [0, 0, 0, 0], 288 'descriptor': {shape: [1, 2, 2], dataType: 'float32'}, 289 'constant': true 290 } 291 }, 292 'operators': [{ 293 'name': 'lstm', 294 'arguments': [ 295 {'input': 'lstmInput'}, {'weight': 'lstmWeight'}, 296 {'recurrentWeight': 'lstmRecurrentWeight'}, {'steps': 1}, 297 {'hiddenSize': 2}, { 298 'options': { 299 'bias': 'lstmBias', 300 'recurrentBias': 'lstmRecurrentBias', 301 'initialCellState': 'lstmInitialCellState', 302 'activations': ['relu', 'relu', 'relu'] 303 } 304 } 305 ], 306 'outputs': ['lstmOutput1', 'lstmOutput2'] 307 }], 308 'expectedOutputs': { 309 'lstmOutput1': { 310 'data': [1, 8, 27, 216], 311 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 312 }, 313 'lstmOutput2': { 314 'data': [1, 4, 9, 36], 315 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 316 } 317 } 318 } 319 }, 320 { 321 'name': 322 "lstm float32 tensors steps=1 with options.bias, options.recurrentBias, options.activations=['relu', 'relu', 'relu'] and explicit options.returnSequence=false", 323 'graph': { 324 'inputs': { 325 'lstmInput': { 326 'data': [1, 2, 2, 1], 327 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 328 }, 329 'lstmWeight': { 330 'data': [1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2], 331 'descriptor': {shape: [1, 8, 2], dataType: 'float32'}, 332 'constant': true 333 }, 334 'lstmRecurrentWeight': { 335 'data': [ 336 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 337 0.1, 0.1, 0.1 338 ], 339 'descriptor': {shape: [1, 8, 2], dataType: 'float32'}, 340 'constant': true 341 }, 342 'lstmBias': { 343 'data': [1, 2, 1, 2, 1, 2, 1, 2], 344 'descriptor': {shape: [1, 8], dataType: 'float32'}, 345 'constant': true 346 }, 347 'lstmRecurrentBias': { 348 'data': [1, 2, 1, 2, 1, 2, 1, 2], 349 'descriptor': {shape: [1, 8], dataType: 'float32'}, 350 'constant': true 351 } 352 }, 353 'operators': [{ 354 'name': 'lstm', 355 'arguments': [ 356 {'input': 'lstmInput'}, {'weight': 'lstmWeight'}, 357 {'recurrentWeight': 'lstmRecurrentWeight'}, {'steps': 1}, 358 {'hiddenSize': 2}, { 359 'options': { 360 'bias': 'lstmBias', 361 'recurrentBias': 'lstmRecurrentBias', 362 'returnSequence': false, 363 'activations': ['relu', 'relu', 'relu'] 364 } 365 } 366 ], 367 'outputs': ['lstmOutput1', 'lstmOutput2'] 368 }], 369 'expectedOutputs': { 370 'lstmOutput1': { 371 'data': [1, 8, 27, 216], 372 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 373 }, 374 'lstmOutput2': { 375 'data': [1, 4, 9, 36], 376 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 377 } 378 } 379 } 380 }, 381 { 382 'name': 383 "lstm float32 tensors steps=1 with options.bias, options.recurrentBias, options.activations=['relu', 'relu', 'relu'] and options.returnSequence=true", 384 'graph': { 385 'inputs': { 386 'lstmInput': { 387 'data': [1, 2, 2, 1], 388 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 389 }, 390 'lstmWeight': { 391 'data': [1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2], 392 'descriptor': {shape: [1, 8, 2], dataType: 'float32'}, 393 'constant': true 394 }, 395 'lstmRecurrentWeight': { 396 'data': [ 397 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 398 0.1, 0.1, 0.1 399 ], 400 'descriptor': {shape: [1, 8, 2], dataType: 'float32'}, 401 'constant': true 402 }, 403 'lstmBias': { 404 'data': [1, 2, 1, 2, 1, 2, 1, 2], 405 'descriptor': {shape: [1, 8], dataType: 'float32'}, 406 'constant': true 407 }, 408 'lstmRecurrentBias': { 409 'data': [1, 2, 1, 2, 1, 2, 1, 2], 410 'descriptor': {shape: [1, 8], dataType: 'float32'}, 411 'constant': true 412 } 413 }, 414 'operators': [{ 415 'name': 'lstm', 416 'arguments': [ 417 {'input': 'lstmInput'}, {'weight': 'lstmWeight'}, 418 {'recurrentWeight': 'lstmRecurrentWeight'}, {'steps': 1}, 419 {'hiddenSize': 2}, { 420 'options': { 421 'bias': 'lstmBias', 422 'recurrentBias': 'lstmRecurrentBias', 423 'returnSequence': true, 424 'activations': ['relu', 'relu', 'relu'] 425 } 426 } 427 ], 428 'outputs': ['lstmOutput1', 'lstmOutput2', 'lstmOutput3'] 429 }], 430 'expectedOutputs': { 431 'lstmOutput1': { 432 'data': [1, 8, 27, 216], 433 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 434 }, 435 'lstmOutput2': { 436 'data': [1, 4, 9, 36], 437 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 438 }, 439 'lstmOutput3': { 440 'data': [1, 8, 27, 216], 441 'descriptor': {shape: [1, 1, 2, 2], dataType: 'float32'} 442 } 443 } 444 } 445 }, 446 { 447 'name': 448 "lstm float32 tensors steps=1 with options.bias, options.recurrentBias, options.activations=['relu', 'relu', 'relu'] and explicit options.direction='forward'", 449 'graph': { 450 'inputs': { 451 'lstmInput': { 452 'data': [1, 2, 2, 1], 453 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 454 }, 455 'lstmWeight': { 456 'data': [1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2], 457 'descriptor': {shape: [1, 8, 2], dataType: 'float32'}, 458 'constant': true 459 }, 460 'lstmRecurrentWeight': { 461 'data': [ 462 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 463 0.1, 0.1, 0.1 464 ], 465 'descriptor': {shape: [1, 8, 2], dataType: 'float32'}, 466 'constant': true 467 }, 468 'lstmBias': { 469 'data': [1, 2, 1, 2, 1, 2, 1, 2], 470 'descriptor': {shape: [1, 8], dataType: 'float32'}, 471 'constant': true 472 }, 473 'lstmRecurrentBias': { 474 'data': [1, 2, 1, 2, 1, 2, 1, 2], 475 'descriptor': {shape: [1, 8], dataType: 'float32'}, 476 'constant': true 477 } 478 }, 479 'operators': [{ 480 'name': 'lstm', 481 'arguments': [ 482 {'input': 'lstmInput'}, {'weight': 'lstmWeight'}, 483 {'recurrentWeight': 'lstmRecurrentWeight'}, {'steps': 1}, 484 {'hiddenSize': 2}, { 485 'options': { 486 'bias': 'lstmBias', 487 'recurrentBias': 'lstmRecurrentBias', 488 'direction': 'forward', 489 'activations': ['relu', 'relu', 'relu'] 490 } 491 } 492 ], 493 'outputs': ['lstmOutput1', 'lstmOutput2'] 494 }], 495 'expectedOutputs': { 496 'lstmOutput1': { 497 'data': [1, 8, 27, 216], 498 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 499 }, 500 'lstmOutput2': { 501 'data': [1, 4, 9, 36], 502 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 503 } 504 } 505 } 506 }, 507 { 508 'name': 509 "lstm float32 tensors steps=1 with options.bias, options.recurrentBias, options.activations=['relu', 'relu', 'relu'] and explicit options.layout='iofg'", 510 'graph': { 511 'inputs': { 512 'lstmInput': { 513 'data': [1, 2, 2, 1], 514 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 515 }, 516 'lstmWeight': { 517 'data': [1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2], 518 'descriptor': {shape: [1, 8, 2], dataType: 'float32'}, 519 'constant': true 520 }, 521 'lstmRecurrentWeight': { 522 'data': [ 523 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 524 0.1, 0.1, 0.1 525 ], 526 'descriptor': {shape: [1, 8, 2], dataType: 'float32'}, 527 'constant': true 528 }, 529 'lstmBias': { 530 'data': [1, 2, 1, 2, 1, 2, 1, 2], 531 'descriptor': {shape: [1, 8], dataType: 'float32'}, 532 'constant': true 533 }, 534 'lstmRecurrentBias': { 535 'data': [1, 2, 1, 2, 1, 2, 1, 2], 536 'descriptor': {shape: [1, 8], dataType: 'float32'}, 537 'constant': true 538 } 539 }, 540 'operators': [{ 541 'name': 'lstm', 542 'arguments': [ 543 {'input': 'lstmInput'}, {'weight': 'lstmWeight'}, 544 {'recurrentWeight': 'lstmRecurrentWeight'}, {'steps': 1}, 545 {'hiddenSize': 2}, { 546 'options': { 547 'bias': 'lstmBias', 548 'recurrentBias': 'lstmRecurrentBias', 549 'layout': 'iofg', 550 'activations': ['relu', 'relu', 'relu'] 551 } 552 } 553 ], 554 'outputs': ['lstmOutput1', 'lstmOutput2'] 555 }], 556 'expectedOutputs': { 557 'lstmOutput1': { 558 'data': [1, 8, 27, 216], 559 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 560 }, 561 'lstmOutput2': { 562 'data': [1, 4, 9, 36], 563 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 564 } 565 } 566 } 567 }, 568 { 569 'name': 570 "lstm float32 tensors steps=1 with options.bias, options.recurrentBias, options.activations=['relu', 'relu', 'relu'] and options.layout='ifgo'", 571 'graph': { 572 'inputs': { 573 'lstmInput': { 574 'data': [1, 2, 2, 1], 575 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 576 }, 577 'lstmWeight': { 578 'data': [1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2], 579 'descriptor': {shape: [1, 8, 2], dataType: 'float32'}, 580 'constant': true 581 }, 582 'lstmRecurrentWeight': { 583 'data': [ 584 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 585 0.1, 0.1, 0.1 586 ], 587 'descriptor': {shape: [1, 8, 2], dataType: 'float32'}, 588 'constant': true 589 }, 590 'lstmBias': { 591 'data': [1, 2, 1, 2, 1, 2, 1, 2], 592 'descriptor': {shape: [1, 8], dataType: 'float32'}, 593 'constant': true 594 }, 595 'lstmRecurrentBias': { 596 'data': [1, 2, 1, 2, 1, 2, 1, 2], 597 'descriptor': {shape: [1, 8], dataType: 'float32'}, 598 'constant': true 599 } 600 }, 601 'operators': [{ 602 'name': 'lstm', 603 'arguments': [ 604 {'input': 'lstmInput'}, {'weight': 'lstmWeight'}, 605 {'recurrentWeight': 'lstmRecurrentWeight'}, {'steps': 1}, 606 {'hiddenSize': 2}, { 607 'options': { 608 'bias': 'lstmBias', 609 'recurrentBias': 'lstmRecurrentBias', 610 'layout': 'ifgo', 611 'activations': ['relu', 'relu', 'relu'] 612 } 613 } 614 ], 615 'outputs': ['lstmOutput1', 'lstmOutput2'] 616 }], 617 'expectedOutputs': { 618 'lstmOutput1': { 619 'data': [1, 8, 27, 216], 620 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 621 }, 622 'lstmOutput2': { 623 'data': [1, 4, 9, 36], 624 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 625 } 626 } 627 } 628 }, 629 { 630 'name': 'lstm float32 tensors steps=1 with all options', 631 'graph': { 632 'inputs': { 633 'lstmInput': { 634 'data': [1, 2, 2, 1], 635 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 636 }, 637 'lstmWeight': { 638 'data': [1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2], 639 'descriptor': {shape: [1, 8, 2], dataType: 'float32'}, 640 'constant': true 641 }, 642 'lstmRecurrentWeight': { 643 'data': [ 644 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 645 0.1, 0.1, 0.1 646 ], 647 'descriptor': {shape: [1, 8, 2], dataType: 'float32'}, 648 'constant': true 649 }, 650 'lstmBias': { 651 'data': [1, 2, 1, 2, 1, 2, 1, 2], 652 'descriptor': {shape: [1, 8], dataType: 'float32'}, 653 'constant': true 654 }, 655 'lstmRecurrentBias': { 656 'data': [1, 2, 1, 2, 1, 2, 1, 2], 657 'descriptor': {shape: [1, 8], dataType: 'float32'}, 658 'constant': true 659 }, 660 'lstmPeepholeWeight': { 661 'data': [0, 0, 0, 0, 0, 0], 662 'descriptor': {shape: [1, 6], dataType: 'float32'}, 663 'constant': true 664 }, 665 'lstmInitialHiddenState': { 666 'data': [0, 0, 0, 0], 667 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 668 }, 669 'lstmInitialCellState': { 670 'data': [0, 0, 0, 0], 671 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 672 } 673 }, 674 'operators': [{ 675 'name': 'lstm', 676 'arguments': [ 677 {'input': 'lstmInput'}, {'weight': 'lstmWeight'}, 678 {'recurrentWeight': 'lstmRecurrentWeight'}, {'steps': 1}, 679 {'hiddenSize': 2}, { 680 'options': { 681 'bias': 'lstmBias', 682 'recurrentBias': 'lstmRecurrentBias', 683 'peepholeWeight': 'lstmPeepholeWeight', 684 'initialHiddenState': 'lstmInitialHiddenState', 685 'initialCellState': 'lstmInitialCellState', 686 'returnSequence': true, 687 'direction': 'forward', 688 'layout': 'iofg', 689 'activations': ['relu', 'relu', 'relu'] 690 } 691 } 692 ], 693 'outputs': ['lstmOutput1', 'lstmOutput2', 'lstmOutput3'] 694 }], 695 'expectedOutputs': { 696 'lstmOutput1': { 697 'data': [1, 8, 27, 216], 698 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 699 }, 700 'lstmOutput2': { 701 'data': [1, 4, 9, 36], 702 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 703 }, 704 'lstmOutput3': { 705 'data': [1, 8, 27, 216], 706 'descriptor': {shape: [1, 1, 2, 2], dataType: 'float32'} 707 } 708 } 709 } 710 }, 711 { 712 'name': 713 "lstm float32 tensors steps=2 with options.bias, options.recurrentBias, options.activations=['relu', 'relu', 'relu'] and options.direction='backward'", 714 'graph': { 715 'inputs': { 716 'lstmInput': { 717 'data': [1, 2, 2, 1, 3, 4, 1, 2], 718 'descriptor': {shape: [2, 2, 2], dataType: 'float32'} 719 }, 720 'lstmWeight': { 721 'data': [1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2], 722 'descriptor': {shape: [1, 8, 2], dataType: 'float32'}, 723 'constant': true 724 }, 725 'lstmRecurrentWeight': { 726 'data': [ 727 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 728 0.1, 0.1, 0.1 729 ], 730 'descriptor': {shape: [1, 8, 2], dataType: 'float32'}, 731 'constant': true 732 }, 733 'lstmBias': { 734 'data': [1, 2, 1, 2, 1, 2, 1, 2], 735 'descriptor': {shape: [1, 8], dataType: 'float32'}, 736 'constant': true 737 }, 738 'lstmRecurrentBias': { 739 'data': [1, 2, 1, 2, 1, 2, 1, 2], 740 'descriptor': {shape: [1, 8], dataType: 'float32'}, 741 'constant': true 742 } 743 }, 744 'operators': [{ 745 'name': 'lstm', 746 'arguments': [ 747 {'input': 'lstmInput'}, {'weight': 'lstmWeight'}, 748 {'recurrentWeight': 'lstmRecurrentWeight'}, {'steps': 2}, 749 {'hiddenSize': 2}, { 750 'options': { 751 'bias': 'lstmBias', 752 'recurrentBias': 'lstmRecurrentBias', 753 'direction': 'backward', 754 'activations': ['relu', 'relu', 'relu'] 755 } 756 } 757 ], 758 'outputs': ['lstmOutput1', 'lstmOutput2'] 759 }], 760 'expectedOutputs': { 761 'lstmOutput1': { 762 'data': [ 763 10.469000816345215, 58.02900695800781, 74.52900695800781, 764 518.948974609375 765 ], 766 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 767 }, 768 'lstmOutput2': { 769 'data': [ 770 5.510000228881836, 20.01000213623047, 19.110000610351564, 771 75.20999908447266 772 ], 773 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 774 } 775 } 776 } 777 }, 778 { 779 'name': 780 "lstm float32 tensors steps=2, batchSize=1 with options.bias, options.recurrentBias, options.activations=['relu', 'relu', 'relu'] and options.direction='backward'", 781 'graph': { 782 'inputs': { 783 'lstmInput': { 784 'data': [1, 2, 2, 1], 785 'descriptor': {shape: [2, 1, 2], dataType: 'float32'} 786 }, 787 'lstmWeight': { 788 'data': [1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2], 789 'descriptor': {shape: [1, 8, 2], dataType: 'float32'}, 790 'constant': true 791 }, 792 'lstmRecurrentWeight': { 793 'data': [ 794 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 795 0.1, 0.1, 0.1 796 ], 797 'descriptor': {shape: [1, 8, 2], dataType: 'float32'}, 798 'constant': true 799 }, 800 'lstmBias': { 801 'data': [1, 2, 1, 2, 1, 2, 1, 2], 802 'descriptor': {shape: [1, 8], dataType: 'float32'}, 803 'constant': true 804 }, 805 'lstmRecurrentBias': { 806 'data': [1, 2, 1, 2, 1, 2, 1, 2], 807 'descriptor': {shape: [1, 8], dataType: 'float32'}, 808 'constant': true 809 } 810 }, 811 'operators': [{ 812 'name': 'lstm', 813 'arguments': [ 814 {'input': 'lstmInput'}, {'weight': 'lstmWeight'}, 815 {'recurrentWeight': 'lstmRecurrentWeight'}, {'steps': 2}, 816 {'hiddenSize': 2}, { 817 'options': { 818 'bias': 'lstmBias', 819 'recurrentBias': 'lstmRecurrentBias', 820 'direction': 'backward', 821 'activations': ['relu', 'relu', 'relu'] 822 } 823 } 824 ], 825 'outputs': ['lstmOutput1', 'lstmOutput2'] 826 }], 827 'expectedOutputs': { 828 'lstmOutput1': { 829 'data': [ 830 21955.08984375, 43092.29296875 831 ], 832 'descriptor': {shape: [1, 1, 2], dataType: 'float32'} 833 }, 834 'lstmOutput2': { 835 'data': [ 836 867.7901000976562, 1638.4901123046875 837 ], 838 'descriptor': {shape: [1, 1, 2], dataType: 'float32'} 839 } 840 } 841 } 842 }, 843 { 844 'name': 'lstm float32 tensors steps=2 with all options', 845 'graph': { 846 'inputs': { 847 'lstmInput': { 848 'data': [1, 2, 2, 1, 3, 4, 1, 2], 849 'descriptor': {shape: [2, 2, 2], dataType: 'float32'} 850 }, 851 'lstmWeight': { 852 'data': [1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2], 853 'descriptor': {shape: [1, 8, 2], dataType: 'float32'}, 854 'constant': true 855 }, 856 'lstmRecurrentWeight': { 857 'data': [ 858 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 859 0.1, 0.1, 0.1 860 ], 861 'descriptor': {shape: [1, 8, 2], dataType: 'float32'}, 862 'constant': true 863 }, 864 'lstmBias': { 865 'data': [1, 2, 1, 2, 1, 2, 1, 2], 866 'descriptor': {shape: [1, 8], dataType: 'float32'}, 867 'constant': true 868 }, 869 'lstmRecurrentBias': { 870 'data': [1, 2, 1, 2, 1, 2, 1, 2], 871 'descriptor': {shape: [1, 8], dataType: 'float32'}, 872 'constant': true 873 }, 874 'lstmPeepholeWeight': { 875 'data': [0, 0, 0, 0, 0, 0], 876 'descriptor': {shape: [1, 6], dataType: 'float32'}, 877 'constant': true 878 }, 879 'lstmInitialHiddenState': { 880 'data': [0, 0, 0, 0], 881 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 882 }, 883 'lstmInitialCellState': { 884 'data': [0, 0, 0, 0], 885 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 886 } 887 }, 888 'operators': [{ 889 'name': 'lstm', 890 'arguments': [ 891 {'input': 'lstmInput'}, {'weight': 'lstmWeight'}, 892 {'recurrentWeight': 'lstmRecurrentWeight'}, {'steps': 2}, 893 {'hiddenSize': 2}, { 894 'options': { 895 'bias': 'lstmBias', 896 'recurrentBias': 'lstmRecurrentBias', 897 'peepholeWeight': 'lstmPeepholeWeight', 898 'initialHiddenState': 'lstmInitialHiddenState', 899 'initialCellState': 'lstmInitialCellState', 900 'returnSequence': true, 901 'direction': 'backward', 902 'layout': 'iofg', 903 'activations': ['relu', 'relu', 'relu'] 904 } 905 } 906 ], 907 'outputs': ['lstmOutput1', 'lstmOutput2', 'lstmOutput3'] 908 }], 909 'expectedOutputs': { 910 'lstmOutput1': { 911 'data': [ 912 10.469000816345215, 58.02900695800781, 74.52900695800781, 913 518.948974609375 914 ], 915 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 916 }, 917 'lstmOutput2': { 918 'data': [ 919 5.510000228881836, 20.01000213623047, 19.110000610351564, 920 75.20999908447266 921 ], 922 'descriptor': {shape: [1, 2, 2], dataType: 'float32'} 923 }, 924 'lstmOutput3': { 925 'data': [ 926 10.469000816345215, 58.02900695800781, 74.52900695800781, 927 518.948974609375, 1, 8, 1, 8 928 ], 929 'descriptor': {shape: [2, 1, 2, 2], dataType: 'float32'} 930 } 931 } 932 } 933 }, 934 { 935 'name': 'lstm float32 tensors steps=2 with bidirections', 936 'graph': { 937 'inputs': { 938 'lstmInput': { 939 'data': [1, 2, 2, 1, 3, 4, 1, 2], 940 'descriptor': {shape: [2, 2, 2], dataType: 'float32'} 941 }, 942 'lstmWeight': { 943 'data': [ 944 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 945 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2 946 ], 947 'descriptor': {shape: [2, 8, 2], dataType: 'float32'}, 948 'constant': true 949 }, 950 'lstmRecurrentWeight': { 951 'data': [ 952 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 953 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 954 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 955 ], 956 'descriptor': {shape: [2, 8, 2], dataType: 'float32'}, 957 'constant': true 958 }, 959 'lstmBias': { 960 'data': [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2], 961 'descriptor': {shape: [2, 8], dataType: 'float32'}, 962 'constant': true 963 }, 964 'lstmRecurrentBias': { 965 'data': [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2], 966 'descriptor': {shape: [2, 8], dataType: 'float32'}, 967 'constant': true 968 } 969 }, 970 'operators': [{ 971 'name': 'lstm', 972 'arguments': [ 973 {'input': 'lstmInput'}, {'weight': 'lstmWeight'}, 974 {'recurrentWeight': 'lstmRecurrentWeight'}, {'steps': 2}, 975 {'hiddenSize': 2}, { 976 'options': { 977 'bias': 'lstmBias', 978 'recurrentBias': 'lstmRecurrentBias', 979 'returnSequence': true, 980 'direction': 'both', 981 'layout': 'iofg' 982 } 983 } 984 ], 985 'outputs': ['lstmOutput1', 'lstmOutput2', 'lstmOutput3'] 986 }], 987 'expectedOutputs': { 988 'lstmOutput1': { 989 'data': [ 990 0.5764073133468628, 0.8236227035522461, 0.6612355709075928, 991 0.8442635536193848, 0.5764073133468628, 0.8236227035522461, 992 0.8635294437408447, 0.9491351246833801 993 ], 994 'descriptor': {shape: [2, 2, 2], dataType: 'float32'} 995 }, 996 'lstmOutput2': { 997 'data': [ 998 1.0171456336975098, 1.6205494403839111, 1.3388464450836182, 999 1.7642604112625122, 1.0171456336975098, 1.6205494403839111, 1000 1.4856269359588623, 1.8449554443359375 1001 ], 1002 'descriptor': {shape: [2, 2, 2], dataType: 'float32'} 1003 }, 1004 'lstmOutput3': { 1005 'data': [ 1006 0.3696063756942749, 0.6082833409309387, 0.7037754058837891, 1007 0.7586681246757507, 0.5764073133468628, 0.8236227035522461, 1008 0.8635294437408447, 0.9491351246833801, 0.5764073133468628, 1009 0.8236227035522461, 0.6612355709075928, 0.8442635536193848, 1010 0.3696063756942749, 0.6082833409309387, 0.3696063756942749, 1011 0.6082833409309387 1012 ], 1013 'descriptor': {shape: [2, 2, 2, 2], dataType: 'float32'} 1014 } 1015 } 1016 } 1017 }, 1018 1019 // float16 tests 1020 { 1021 'name': 1022 'lstm float16 tensors steps=1 with options.bias, options.recurrentBias', 1023 'graph': { 1024 'inputs': { 1025 'lstmInput': { 1026 'data': [1, 2, 2, 1], 1027 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1028 }, 1029 'lstmWeight': { 1030 'data': [1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2], 1031 'descriptor': {shape: [1, 8, 2], dataType: 'float16'}, 1032 'constant': true 1033 }, 1034 'lstmRecurrentWeight': { 1035 'data': [ 1036 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 1037 0.1, 0.1, 0.1 1038 ], 1039 'descriptor': {shape: [1, 8, 2], dataType: 'float16'}, 1040 'constant': true 1041 }, 1042 'lstmBias': { 1043 'data': [1, 2, 1, 2, 1, 2, 1, 2], 1044 'descriptor': {shape: [1, 8], dataType: 'float16'}, 1045 'constant': true 1046 }, 1047 'lstmRecurrentBias': { 1048 'data': [1, 2, 1, 2, 1, 2, 1, 2], 1049 'descriptor': {shape: [1, 8], dataType: 'float16'}, 1050 'constant': true 1051 } 1052 }, 1053 'operators': [{ 1054 'name': 'lstm', 1055 'arguments': [ 1056 {'input': 'lstmInput'}, {'weight': 'lstmWeight'}, 1057 {'recurrentWeight': 'lstmRecurrentWeight'}, {'steps': 1}, 1058 {'hiddenSize': 2}, { 1059 'options': { 1060 'bias': 'lstmBias', 1061 'recurrentBias': 'lstmRecurrentBias', 1062 'returnSequence': false, 1063 'activations': ['relu', 'relu', 'relu'] 1064 } 1065 } 1066 ], 1067 'outputs': ['lstmOutput1', 'lstmOutput2'] 1068 }], 1069 'expectedOutputs': { 1070 'lstmOutput1': { 1071 'data': [1, 8, 27, 216], 1072 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1073 }, 1074 'lstmOutput2': { 1075 'data': [1, 4, 9, 36], 1076 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1077 } 1078 } 1079 } 1080 }, 1081 { 1082 'name': 1083 "lstm float16 tensors steps=1 with options.bias, options.recurrentBias and options.activations=['relu', 'relu', 'relu']", 1084 'graph': { 1085 'inputs': { 1086 'lstmInput': { 1087 'data': [1, 2, 2, 1], 1088 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1089 }, 1090 'lstmWeight': { 1091 'data': [1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2], 1092 'descriptor': {shape: [1, 8, 2], dataType: 'float16'}, 1093 'constant': true 1094 }, 1095 'lstmRecurrentWeight': { 1096 'data': [ 1097 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1098 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1099 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1100 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375 1101 ], 1102 'descriptor': {shape: [1, 8, 2], dataType: 'float16'}, 1103 'constant': true 1104 }, 1105 'lstmBias': { 1106 'data': [1, 2, 1, 2, 1, 2, 1, 2], 1107 'descriptor': {shape: [1, 8], dataType: 'float16'}, 1108 'constant': true 1109 }, 1110 'lstmRecurrentBias': { 1111 'data': [1, 2, 1, 2, 1, 2, 1, 2], 1112 'descriptor': {shape: [1, 8], dataType: 'float16'}, 1113 'constant': true 1114 } 1115 }, 1116 'operators': [{ 1117 'name': 'lstm', 1118 'arguments': [ 1119 {'input': 'lstmInput'}, {'weight': 'lstmWeight'}, 1120 {'recurrentWeight': 'lstmRecurrentWeight'}, {'steps': 1}, 1121 {'hiddenSize': 2}, { 1122 'options': { 1123 'bias': 'lstmBias', 1124 'recurrentBias': 'lstmRecurrentBias', 1125 'activations': ['relu', 'relu', 'relu'] 1126 } 1127 } 1128 ], 1129 'outputs': ['lstmOutput1', 'lstmOutput2'] 1130 }], 1131 'expectedOutputs': { 1132 'lstmOutput1': { 1133 'data': [1, 8, 27, 216], 1134 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1135 }, 1136 'lstmOutput2': { 1137 'data': [1, 4, 9, 36], 1138 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1139 } 1140 } 1141 } 1142 }, 1143 { 1144 'name': 1145 "lstm float16 tensors steps=1 with options.bias, options.recurrentBias, options.activations=['relu', 'relu', 'relu'] and options.peepholeWeight", 1146 'graph': { 1147 'inputs': { 1148 'lstmInput': { 1149 'data': [1, 2, 2, 1], 1150 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1151 }, 1152 'lstmWeight': { 1153 'data': [1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2], 1154 'descriptor': {shape: [1, 8, 2], dataType: 'float16'}, 1155 'constant': true 1156 }, 1157 'lstmRecurrentWeight': { 1158 'data': [ 1159 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1160 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1161 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1162 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375 1163 ], 1164 'descriptor': {shape: [1, 8, 2], dataType: 'float16'}, 1165 'constant': true 1166 }, 1167 'lstmBias': { 1168 'data': [1, 2, 1, 2, 1, 2, 1, 2], 1169 'descriptor': {shape: [1, 8], dataType: 'float16'}, 1170 'constant': true 1171 }, 1172 'lstmRecurrentBias': { 1173 'data': [1, 2, 1, 2, 1, 2, 1, 2], 1174 'descriptor': {shape: [1, 8], dataType: 'float16'}, 1175 'constant': true 1176 }, 1177 'lstmPeepholeWeight': { 1178 'data': [0, 0, 0, 0, 0, 0], 1179 'descriptor': {shape: [1, 6], dataType: 'float16'}, 1180 'constant': true 1181 } 1182 }, 1183 'operators': [{ 1184 'name': 'lstm', 1185 'arguments': [ 1186 {'input': 'lstmInput'}, {'weight': 'lstmWeight'}, 1187 {'recurrentWeight': 'lstmRecurrentWeight'}, {'steps': 1}, 1188 {'hiddenSize': 2}, { 1189 'options': { 1190 'bias': 'lstmBias', 1191 'recurrentBias': 'lstmRecurrentBias', 1192 'peepholeWeight': 'lstmPeepholeWeight', 1193 'activations': ['relu', 'relu', 'relu'] 1194 } 1195 } 1196 ], 1197 'outputs': ['lstmOutput1', 'lstmOutput2'] 1198 }], 1199 'expectedOutputs': { 1200 'lstmOutput1': { 1201 'data': [1, 8, 27, 216], 1202 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1203 }, 1204 'lstmOutput2': { 1205 'data': [1, 4, 9, 36], 1206 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1207 } 1208 } 1209 } 1210 }, 1211 { 1212 'name': 1213 "lstm float16 tensors steps=1 with options.bias, options.recurrentBias, options.activations=['relu', 'relu', 'relu'] and options.initialHiddenState", 1214 'graph': { 1215 'inputs': { 1216 'lstmInput': { 1217 'data': [1, 2, 2, 1], 1218 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1219 }, 1220 'lstmWeight': { 1221 'data': [1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2], 1222 'descriptor': {shape: [1, 8, 2], dataType: 'float16'}, 1223 'constant': true 1224 }, 1225 'lstmRecurrentWeight': { 1226 'data': [ 1227 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1228 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1229 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1230 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375 1231 ], 1232 'descriptor': {shape: [1, 8, 2], dataType: 'float16'}, 1233 'constant': true 1234 }, 1235 'lstmBias': { 1236 'data': [1, 2, 1, 2, 1, 2, 1, 2], 1237 'descriptor': {shape: [1, 8], dataType: 'float16'}, 1238 'constant': true 1239 }, 1240 'lstmRecurrentBias': { 1241 'data': [1, 2, 1, 2, 1, 2, 1, 2], 1242 'descriptor': {shape: [1, 8], dataType: 'float16'}, 1243 'constant': true 1244 }, 1245 'lstmInitialHiddenState': { 1246 'data': [0, 0, 0, 0], 1247 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1248 } 1249 }, 1250 'operators': [{ 1251 'name': 'lstm', 1252 'arguments': [ 1253 {'input': 'lstmInput'}, {'weight': 'lstmWeight'}, 1254 {'recurrentWeight': 'lstmRecurrentWeight'}, {'steps': 1}, 1255 {'hiddenSize': 2}, { 1256 'options': { 1257 'bias': 'lstmBias', 1258 'recurrentBias': 'lstmRecurrentBias', 1259 'initialHiddenState': 'lstmInitialHiddenState', 1260 'activations': ['relu', 'relu', 'relu'] 1261 } 1262 } 1263 ], 1264 'outputs': ['lstmOutput1', 'lstmOutput2'] 1265 }], 1266 'expectedOutputs': { 1267 'lstmOutput1': { 1268 'data': [1, 8, 27, 216], 1269 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1270 }, 1271 'lstmOutput2': { 1272 'data': [1, 4, 9, 36], 1273 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1274 } 1275 } 1276 } 1277 }, 1278 { 1279 'name': 1280 "lstm float16 tensors steps=1 with options.bias, options.recurrentBias, options.activations=['relu', 'relu', 'relu'] and options.initialCellState", 1281 'graph': { 1282 'inputs': { 1283 'lstmInput': { 1284 'data': [1, 2, 2, 1], 1285 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1286 }, 1287 'lstmWeight': { 1288 'data': [1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2], 1289 'descriptor': {shape: [1, 8, 2], dataType: 'float16'}, 1290 'constant': true 1291 }, 1292 'lstmRecurrentWeight': { 1293 'data': [ 1294 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1295 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1296 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1297 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375 1298 ], 1299 'descriptor': {shape: [1, 8, 2], dataType: 'float16'}, 1300 'constant': true 1301 }, 1302 'lstmBias': { 1303 'data': [1, 2, 1, 2, 1, 2, 1, 2], 1304 'descriptor': {shape: [1, 8], dataType: 'float16'}, 1305 'constant': true 1306 }, 1307 'lstmRecurrentBias': { 1308 'data': [1, 2, 1, 2, 1, 2, 1, 2], 1309 'descriptor': {shape: [1, 8], dataType: 'float16'}, 1310 'constant': true 1311 }, 1312 'lstmInitialCellState': { 1313 'data': [0, 0, 0, 0], 1314 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1315 } 1316 }, 1317 'operators': [{ 1318 'name': 'lstm', 1319 'arguments': [ 1320 {'input': 'lstmInput'}, {'weight': 'lstmWeight'}, 1321 {'recurrentWeight': 'lstmRecurrentWeight'}, {'steps': 1}, 1322 {'hiddenSize': 2}, { 1323 'options': { 1324 'bias': 'lstmBias', 1325 'recurrentBias': 'lstmRecurrentBias', 1326 'initialCellState': 'lstmInitialCellState', 1327 'activations': ['relu', 'relu', 'relu'] 1328 } 1329 } 1330 ], 1331 'outputs': ['lstmOutput1', 'lstmOutput2'] 1332 }], 1333 'expectedOutputs': { 1334 'lstmOutput1': { 1335 'data': [1, 8, 27, 216], 1336 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1337 }, 1338 'lstmOutput2': { 1339 'data': [1, 4, 9, 36], 1340 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1341 } 1342 } 1343 } 1344 }, 1345 { 1346 'name': 1347 "lstm float16 tensors steps=1 with options.bias, options.recurrentBias, options.activations=['relu', 'relu', 'relu'] and explicit options.returnSequence=false", 1348 'graph': { 1349 'inputs': { 1350 'lstmInput': { 1351 'data': [1, 2, 2, 1], 1352 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1353 }, 1354 'lstmWeight': { 1355 'data': [1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2], 1356 'descriptor': {shape: [1, 8, 2], dataType: 'float16'}, 1357 'constant': true 1358 }, 1359 'lstmRecurrentWeight': { 1360 'data': [ 1361 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1362 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1363 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1364 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375 1365 ], 1366 'descriptor': {shape: [1, 8, 2], dataType: 'float16'}, 1367 'constant': true 1368 }, 1369 'lstmBias': { 1370 'data': [1, 2, 1, 2, 1, 2, 1, 2], 1371 'descriptor': {shape: [1, 8], dataType: 'float16'}, 1372 'constant': true 1373 }, 1374 'lstmRecurrentBias': { 1375 'data': [1, 2, 1, 2, 1, 2, 1, 2], 1376 'descriptor': {shape: [1, 8], dataType: 'float16'}, 1377 'constant': true 1378 } 1379 }, 1380 'operators': [{ 1381 'name': 'lstm', 1382 'arguments': [ 1383 {'input': 'lstmInput'}, {'weight': 'lstmWeight'}, 1384 {'recurrentWeight': 'lstmRecurrentWeight'}, {'steps': 1}, 1385 {'hiddenSize': 2}, { 1386 'options': { 1387 'bias': 'lstmBias', 1388 'recurrentBias': 'lstmRecurrentBias', 1389 'returnSequence': false, 1390 'activations': ['relu', 'relu', 'relu'] 1391 } 1392 } 1393 ], 1394 'outputs': ['lstmOutput1', 'lstmOutput2'] 1395 }], 1396 'expectedOutputs': { 1397 'lstmOutput1': { 1398 'data': [1, 8, 27, 216], 1399 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1400 }, 1401 'lstmOutput2': { 1402 'data': [1, 4, 9, 36], 1403 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1404 } 1405 } 1406 } 1407 }, 1408 { 1409 'name': 1410 "lstm float16 tensors steps=1 with options.bias, options.recurrentBias, options.activations=['relu', 'relu', 'relu'] and options.returnSequence=true", 1411 'graph': { 1412 'inputs': { 1413 'lstmInput': { 1414 'data': [1, 2, 2, 1], 1415 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1416 }, 1417 'lstmWeight': { 1418 'data': [1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2], 1419 'descriptor': {shape: [1, 8, 2], dataType: 'float16'}, 1420 'constant': true 1421 }, 1422 'lstmRecurrentWeight': { 1423 'data': [ 1424 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1425 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1426 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1427 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375 1428 ], 1429 'descriptor': {shape: [1, 8, 2], dataType: 'float16'}, 1430 'constant': true 1431 }, 1432 'lstmBias': { 1433 'data': [1, 2, 1, 2, 1, 2, 1, 2], 1434 'descriptor': {shape: [1, 8], dataType: 'float16'}, 1435 'constant': true 1436 }, 1437 'lstmRecurrentBias': { 1438 'data': [1, 2, 1, 2, 1, 2, 1, 2], 1439 'descriptor': {shape: [1, 8], dataType: 'float16'}, 1440 'constant': true 1441 } 1442 }, 1443 'operators': [{ 1444 'name': 'lstm', 1445 'arguments': [ 1446 {'input': 'lstmInput'}, {'weight': 'lstmWeight'}, 1447 {'recurrentWeight': 'lstmRecurrentWeight'}, {'steps': 1}, 1448 {'hiddenSize': 2}, { 1449 'options': { 1450 'bias': 'lstmBias', 1451 'recurrentBias': 'lstmRecurrentBias', 1452 'returnSequence': true, 1453 'activations': ['relu', 'relu', 'relu'] 1454 } 1455 } 1456 ], 1457 'outputs': ['lstmOutput1', 'lstmOutput2', 'lstmOutput3'] 1458 }], 1459 'expectedOutputs': { 1460 'lstmOutput1': { 1461 'data': [1, 8, 27, 216], 1462 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1463 }, 1464 'lstmOutput2': { 1465 'data': [1, 4, 9, 36], 1466 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1467 }, 1468 'lstmOutput3': { 1469 'data': [1, 8, 27, 216], 1470 'descriptor': {shape: [1, 1, 2, 2], dataType: 'float16'} 1471 } 1472 } 1473 } 1474 }, 1475 { 1476 'name': 1477 "lstm float16 tensors steps=1 with options.bias, options.recurrentBias, options.activations=['relu', 'relu', 'relu'] and explicit options.direction='forward'", 1478 'graph': { 1479 'inputs': { 1480 'lstmInput': { 1481 'data': [1, 2, 2, 1], 1482 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1483 }, 1484 'lstmWeight': { 1485 'data': [1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2], 1486 'descriptor': {shape: [1, 8, 2], dataType: 'float16'}, 1487 'constant': true 1488 }, 1489 'lstmRecurrentWeight': { 1490 'data': [ 1491 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1492 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1493 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1494 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375 1495 ], 1496 'descriptor': {shape: [1, 8, 2], dataType: 'float16'}, 1497 'constant': true 1498 }, 1499 'lstmBias': { 1500 'data': [1, 2, 1, 2, 1, 2, 1, 2], 1501 'descriptor': {shape: [1, 8], dataType: 'float16'}, 1502 'constant': true 1503 }, 1504 'lstmRecurrentBias': { 1505 'data': [1, 2, 1, 2, 1, 2, 1, 2], 1506 'descriptor': {shape: [1, 8], dataType: 'float16'}, 1507 'constant': true 1508 } 1509 }, 1510 'operators': [{ 1511 'name': 'lstm', 1512 'arguments': [ 1513 {'input': 'lstmInput'}, {'weight': 'lstmWeight'}, 1514 {'recurrentWeight': 'lstmRecurrentWeight'}, {'steps': 1}, 1515 {'hiddenSize': 2}, { 1516 'options': { 1517 'bias': 'lstmBias', 1518 'recurrentBias': 'lstmRecurrentBias', 1519 'direction': 'forward', 1520 'activations': ['relu', 'relu', 'relu'] 1521 } 1522 } 1523 ], 1524 'outputs': ['lstmOutput1', 'lstmOutput2'] 1525 }], 1526 'expectedOutputs': { 1527 'lstmOutput1': { 1528 'data': [1, 8, 27, 216], 1529 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1530 }, 1531 'lstmOutput2': { 1532 'data': [1, 4, 9, 36], 1533 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1534 } 1535 } 1536 } 1537 }, 1538 { 1539 'name': 1540 "lstm float16 tensors steps=1 with options.bias, options.recurrentBias, options.activations=['relu', 'relu', 'relu'] and explicit options.layout='iofg'", 1541 'graph': { 1542 'inputs': { 1543 'lstmInput': { 1544 'data': [1, 2, 2, 1], 1545 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1546 }, 1547 'lstmWeight': { 1548 'data': [1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2], 1549 'descriptor': {shape: [1, 8, 2], dataType: 'float16'}, 1550 'constant': true 1551 }, 1552 'lstmRecurrentWeight': { 1553 'data': [ 1554 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1555 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1556 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1557 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375 1558 ], 1559 'descriptor': {shape: [1, 8, 2], dataType: 'float16'}, 1560 'constant': true 1561 }, 1562 'lstmBias': { 1563 'data': [1, 2, 1, 2, 1, 2, 1, 2], 1564 'descriptor': {shape: [1, 8], dataType: 'float16'}, 1565 'constant': true 1566 }, 1567 'lstmRecurrentBias': { 1568 'data': [1, 2, 1, 2, 1, 2, 1, 2], 1569 'descriptor': {shape: [1, 8], dataType: 'float16'}, 1570 'constant': true 1571 } 1572 }, 1573 'operators': [{ 1574 'name': 'lstm', 1575 'arguments': [ 1576 {'input': 'lstmInput'}, {'weight': 'lstmWeight'}, 1577 {'recurrentWeight': 'lstmRecurrentWeight'}, {'steps': 1}, 1578 {'hiddenSize': 2}, { 1579 'options': { 1580 'bias': 'lstmBias', 1581 'recurrentBias': 'lstmRecurrentBias', 1582 'layout': 'iofg', 1583 'activations': ['relu', 'relu', 'relu'] 1584 } 1585 } 1586 ], 1587 'outputs': ['lstmOutput1', 'lstmOutput2'] 1588 }], 1589 'expectedOutputs': { 1590 'lstmOutput1': { 1591 'data': [1, 8, 27, 216], 1592 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1593 }, 1594 'lstmOutput2': { 1595 'data': [1, 4, 9, 36], 1596 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1597 } 1598 } 1599 } 1600 }, 1601 { 1602 'name': 1603 "lstm float16 tensors steps=1 with options.bias, options.recurrentBias, options.activations=['relu', 'relu', 'relu'] and options.layout='ifgo'", 1604 'graph': { 1605 'inputs': { 1606 'lstmInput': { 1607 'data': [1, 2, 2, 1], 1608 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1609 }, 1610 'lstmWeight': { 1611 'data': [1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2], 1612 'descriptor': {shape: [1, 8, 2], dataType: 'float16'}, 1613 'constant': true 1614 }, 1615 'lstmRecurrentWeight': { 1616 'data': [ 1617 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1618 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1619 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1620 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375 1621 ], 1622 'descriptor': {shape: [1, 8, 2], dataType: 'float16'}, 1623 'constant': true 1624 }, 1625 'lstmBias': { 1626 'data': [1, 2, 1, 2, 1, 2, 1, 2], 1627 'descriptor': {shape: [1, 8], dataType: 'float16'}, 1628 'constant': true 1629 }, 1630 'lstmRecurrentBias': { 1631 'data': [1, 2, 1, 2, 1, 2, 1, 2], 1632 'descriptor': {shape: [1, 8], dataType: 'float16'}, 1633 'constant': true 1634 } 1635 }, 1636 'operators': [{ 1637 'name': 'lstm', 1638 'arguments': [ 1639 {'input': 'lstmInput'}, {'weight': 'lstmWeight'}, 1640 {'recurrentWeight': 'lstmRecurrentWeight'}, {'steps': 1}, 1641 {'hiddenSize': 2}, { 1642 'options': { 1643 'bias': 'lstmBias', 1644 'recurrentBias': 'lstmRecurrentBias', 1645 'layout': 'ifgo', 1646 'activations': ['relu', 'relu', 'relu'] 1647 } 1648 } 1649 ], 1650 'outputs': ['lstmOutput1', 'lstmOutput2'] 1651 }], 1652 'expectedOutputs': { 1653 'lstmOutput1': { 1654 'data': [1, 8, 27, 216], 1655 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1656 }, 1657 'lstmOutput2': { 1658 'data': [1, 4, 9, 36], 1659 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1660 } 1661 } 1662 } 1663 }, 1664 { 1665 'name': 'lstm float16 tensors steps=1 with all options', 1666 'graph': { 1667 'inputs': { 1668 'lstmInput': { 1669 'data': [1, 2, 2, 1], 1670 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1671 }, 1672 'lstmWeight': { 1673 'data': [1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2], 1674 'descriptor': {shape: [1, 8, 2], dataType: 'float16'}, 1675 'constant': true 1676 }, 1677 'lstmRecurrentWeight': { 1678 'data': [ 1679 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1680 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1681 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1682 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375 1683 ], 1684 'descriptor': {shape: [1, 8, 2], dataType: 'float16'}, 1685 'constant': true 1686 }, 1687 'lstmBias': { 1688 'data': [1, 2, 1, 2, 1, 2, 1, 2], 1689 'descriptor': {shape: [1, 8], dataType: 'float16'}, 1690 'constant': true 1691 }, 1692 'lstmRecurrentBias': { 1693 'data': [1, 2, 1, 2, 1, 2, 1, 2], 1694 'descriptor': {shape: [1, 8], dataType: 'float16'}, 1695 'constant': true 1696 }, 1697 'lstmPeepholeWeight': { 1698 'data': [0, 0, 0, 0, 0, 0], 1699 'descriptor': {shape: [1, 6], dataType: 'float16'}, 1700 'constant': true 1701 }, 1702 'lstmInitialHiddenState': { 1703 'data': [0, 0, 0, 0], 1704 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1705 }, 1706 'lstmInitialCellState': { 1707 'data': [0, 0, 0, 0], 1708 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1709 } 1710 }, 1711 'operators': [{ 1712 'name': 'lstm', 1713 'arguments': [ 1714 {'input': 'lstmInput'}, {'weight': 'lstmWeight'}, 1715 {'recurrentWeight': 'lstmRecurrentWeight'}, {'steps': 1}, 1716 {'hiddenSize': 2}, { 1717 'options': { 1718 'bias': 'lstmBias', 1719 'recurrentBias': 'lstmRecurrentBias', 1720 'peepholeWeight': 'lstmPeepholeWeight', 1721 'initialHiddenState': 'lstmInitialHiddenState', 1722 'initialCellState': 'lstmInitialCellState', 1723 'returnSequence': true, 1724 'direction': 'forward', 1725 'layout': 'iofg', 1726 'activations': ['relu', 'relu', 'relu'] 1727 } 1728 } 1729 ], 1730 'outputs': ['lstmOutput1', 'lstmOutput2', 'lstmOutput3'] 1731 }], 1732 'expectedOutputs': { 1733 'lstmOutput1': { 1734 'data': [1, 8, 27, 216], 1735 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1736 }, 1737 'lstmOutput2': { 1738 'data': [1, 4, 9, 36], 1739 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1740 }, 1741 'lstmOutput3': { 1742 'data': [1, 8, 27, 216], 1743 'descriptor': {shape: [1, 1, 2, 2], dataType: 'float16'} 1744 } 1745 } 1746 } 1747 }, 1748 { 1749 'name': 1750 "lstm float16 tensors steps=2 with options.bias, options.recurrentBias, options.activations=['relu', 'relu', 'relu'] and options.direction='backward'", 1751 'graph': { 1752 'inputs': { 1753 'lstmInput': { 1754 'data': [1, 2, 2, 1, 3, 4, 1, 2], 1755 'descriptor': {shape: [2, 2, 2], dataType: 'float16'} 1756 }, 1757 'lstmWeight': { 1758 'data': [1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2], 1759 'descriptor': {shape: [1, 8, 2], dataType: 'float16'}, 1760 'constant': true 1761 }, 1762 'lstmRecurrentWeight': { 1763 'data': [ 1764 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1765 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1766 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1767 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375 1768 ], 1769 'descriptor': {shape: [1, 8, 2], dataType: 'float16'}, 1770 'constant': true 1771 }, 1772 'lstmBias': { 1773 'data': [1, 2, 1, 2, 1, 2, 1, 2], 1774 'descriptor': {shape: [1, 8], dataType: 'float16'}, 1775 'constant': true 1776 }, 1777 'lstmRecurrentBias': { 1778 'data': [1, 2, 1, 2, 1, 2, 1, 2], 1779 'descriptor': {shape: [1, 8], dataType: 'float16'}, 1780 'constant': true 1781 } 1782 }, 1783 'operators': [{ 1784 'name': 'lstm', 1785 'arguments': [ 1786 {'input': 'lstmInput'}, {'weight': 'lstmWeight'}, 1787 {'recurrentWeight': 'lstmRecurrentWeight'}, {'steps': 2}, 1788 {'hiddenSize': 2}, { 1789 'options': { 1790 'bias': 'lstmBias', 1791 'recurrentBias': 'lstmRecurrentBias', 1792 'direction': 'backward', 1793 'activations': ['relu', 'relu', 'relu'] 1794 } 1795 } 1796 ], 1797 'outputs': ['lstmOutput1', 'lstmOutput2'] 1798 }], 1799 'expectedOutputs': { 1800 'lstmOutput1': { 1801 'data': [10.46875, 58.03125, 74.5, 519], 1802 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1803 }, 1804 'lstmOutput2': { 1805 'data': [5.5078125, 20.015625, 19.109375, 75.1875], 1806 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1807 } 1808 } 1809 } 1810 }, 1811 { 1812 'name': 'lstm float16 tensors steps=2 with all options', 1813 'graph': { 1814 'inputs': { 1815 'lstmInput': { 1816 'data': [1, 2, 2, 1, 3, 4, 1, 2], 1817 'descriptor': {shape: [2, 2, 2], dataType: 'float16'} 1818 }, 1819 'lstmWeight': { 1820 'data': [1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2], 1821 'descriptor': {shape: [1, 8, 2], dataType: 'float16'}, 1822 'constant': true 1823 }, 1824 'lstmRecurrentWeight': { 1825 'data': [ 1826 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1827 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1828 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1829 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375 1830 ], 1831 'descriptor': {shape: [1, 8, 2], dataType: 'float16'}, 1832 'constant': true 1833 }, 1834 'lstmBias': { 1835 'data': [1, 2, 1, 2, 1, 2, 1, 2], 1836 'descriptor': {shape: [1, 8], dataType: 'float16'}, 1837 'constant': true 1838 }, 1839 'lstmRecurrentBias': { 1840 'data': [1, 2, 1, 2, 1, 2, 1, 2], 1841 'descriptor': {shape: [1, 8], dataType: 'float16'}, 1842 'constant': true 1843 }, 1844 'lstmPeepholeWeight': { 1845 'data': [0, 0, 0, 0, 0, 0], 1846 'descriptor': {shape: [1, 6], dataType: 'float16'}, 1847 'constant': true 1848 }, 1849 'lstmInitialHiddenState': { 1850 'data': [0, 0, 0, 0], 1851 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1852 }, 1853 'lstmInitialCellState': { 1854 'data': [0, 0, 0, 0], 1855 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1856 } 1857 }, 1858 'operators': [{ 1859 'name': 'lstm', 1860 'arguments': [ 1861 {'input': 'lstmInput'}, {'weight': 'lstmWeight'}, 1862 {'recurrentWeight': 'lstmRecurrentWeight'}, {'steps': 2}, 1863 {'hiddenSize': 2}, { 1864 'options': { 1865 'bias': 'lstmBias', 1866 'recurrentBias': 'lstmRecurrentBias', 1867 'peepholeWeight': 'lstmPeepholeWeight', 1868 'initialHiddenState': 'lstmInitialHiddenState', 1869 'initialCellState': 'lstmInitialCellState', 1870 'returnSequence': true, 1871 'direction': 'backward', 1872 'layout': 'iofg', 1873 'activations': ['relu', 'relu', 'relu'] 1874 } 1875 } 1876 ], 1877 'outputs': ['lstmOutput1', 'lstmOutput2', 'lstmOutput3'] 1878 }], 1879 'expectedOutputs': { 1880 'lstmOutput1': { 1881 'data': [10.46875, 58.03125, 74.5, 519], 1882 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1883 }, 1884 'lstmOutput2': { 1885 'data': [5.5078125, 20.015625, 19.109375, 75.1875], 1886 'descriptor': {shape: [1, 2, 2], dataType: 'float16'} 1887 }, 1888 'lstmOutput3': { 1889 'data': [10.46875, 58.03125, 74.5, 519, 1, 8, 1, 8], 1890 'descriptor': {shape: [2, 1, 2, 2], dataType: 'float16'} 1891 } 1892 } 1893 } 1894 }, 1895 { 1896 'name': 'lstm float16 tensors steps=2 with bidirections', 1897 'graph': { 1898 'inputs': { 1899 'lstmInput': { 1900 'data': [1, 2, 2, 1, 3, 4, 1, 2], 1901 'descriptor': {shape: [2, 2, 2], dataType: 'float16'} 1902 }, 1903 'lstmWeight': { 1904 'data': [ 1905 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 1906 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2 1907 ], 1908 'descriptor': {shape: [2, 8, 2], dataType: 'float16'}, 1909 'constant': true 1910 }, 1911 'lstmRecurrentWeight': { 1912 'data': [ 1913 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1914 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1915 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1916 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1917 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1918 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1919 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375, 1920 0.0999755859375, 0.0999755859375, 0.0999755859375, 0.0999755859375 1921 ], 1922 'descriptor': {shape: [2, 8, 2], dataType: 'float16'}, 1923 'constant': true 1924 }, 1925 'lstmBias': { 1926 'data': [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2], 1927 'descriptor': {shape: [2, 8], dataType: 'float16'}, 1928 'constant': true 1929 }, 1930 'lstmRecurrentBias': { 1931 'data': [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2], 1932 'descriptor': {shape: [2, 8], dataType: 'float16'}, 1933 'constant': true 1934 } 1935 }, 1936 'operators': [{ 1937 'name': 'lstm', 1938 'arguments': [ 1939 {'input': 'lstmInput'}, {'weight': 'lstmWeight'}, 1940 {'recurrentWeight': 'lstmRecurrentWeight'}, {'steps': 2}, 1941 {'hiddenSize': 2}, { 1942 'options': { 1943 'bias': 'lstmBias', 1944 'recurrentBias': 'lstmRecurrentBias', 1945 'returnSequence': true, 1946 'direction': 'both', 1947 'layout': 'iofg' 1948 } 1949 } 1950 ], 1951 'outputs': ['lstmOutput1', 'lstmOutput2', 'lstmOutput3'] 1952 }], 1953 'expectedOutputs': { 1954 'lstmOutput1': { 1955 'data': [ 1956 0.576171875, 0.82373046875, 0.6611328125, 0.84423828125, 1957 0.576171875, 0.82373046875, 0.86376953125, 0.94921875 1958 ], 1959 'descriptor': {shape: [2, 2, 2], dataType: 'float16'} 1960 }, 1961 'lstmOutput2': { 1962 'data': [ 1963 1.017578125, 1.6201171875, 1.3388671875, 1.7646484375, 1.017578125, 1964 1.6201171875, 1.4853515625, 1.8447265625 1965 ], 1966 'descriptor': {shape: [2, 2, 2], dataType: 'float16'} 1967 }, 1968 'lstmOutput3': { 1969 'data': [ 1970 0.36962890625, 0.6083984375, 0.70361328125, 0.7587890625, 1971 0.576171875, 0.82373046875, 0.86376953125, 0.94921875, 0.576171875, 1972 0.82373046875, 0.6611328125, 0.84423828125, 0.36962890625, 1973 0.6083984375, 0.36962890625, 0.6083984375 1974 ], 1975 'descriptor': {shape: [2, 2, 2, 2], dataType: 'float16'} 1976 } 1977 } 1978 } 1979 } 1980 ]; 1981 1982 webnn_conformance_test( 1983 lstmTests, buildAndExecuteGraph, getLstmPrecisionTolerance);