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