webnn.idl (31569B)
1 // GENERATED CONTENT - DO NOT EDIT 2 // Content was automatically extracted by Reffy into webref 3 // (https://github.com/w3c/webref) 4 // Source: Web Neural Network API (https://webmachinelearning.github.io/webnn/) 5 6 interface mixin NavigatorML { 7 [SecureContext, SameObject] readonly attribute ML ml; 8 }; 9 Navigator includes NavigatorML; 10 WorkerNavigator includes NavigatorML; 11 12 enum MLPowerPreference { 13 "default", 14 "high-performance", 15 "low-power" 16 }; 17 18 dictionary MLContextOptions { 19 MLPowerPreference powerPreference = "default"; 20 boolean accelerated = true; 21 }; 22 23 [SecureContext, Exposed=(Window, Worker)] 24 interface ML { 25 Promise<MLContext> createContext(optional MLContextOptions options = {}); 26 Promise<MLContext> createContext(GPUDevice gpuDevice); 27 }; 28 29 typedef record<USVString, MLTensor> MLNamedTensors; 30 31 dictionary MLContextLostInfo { 32 DOMString message; 33 }; 34 35 [SecureContext, Exposed=(Window, Worker)] 36 interface MLContext { 37 undefined dispatch(MLGraph graph, MLNamedTensors inputs, MLNamedTensors outputs); 38 39 Promise<MLTensor> createTensor(MLTensorDescriptor descriptor); 40 Promise<MLTensor> createConstantTensor( 41 MLOperandDescriptor descriptor, AllowSharedBufferSource inputData); 42 43 Promise<ArrayBuffer> readTensor(MLTensor tensor); 44 Promise<undefined> readTensor(MLTensor tensor, AllowSharedBufferSource outputData); 45 46 undefined writeTensor(MLTensor tensor, AllowSharedBufferSource inputData); 47 48 MLOpSupportLimits opSupportLimits(); 49 50 undefined destroy(); 51 52 readonly attribute boolean accelerated; 53 readonly attribute Promise<MLContextLostInfo> lost; 54 }; 55 56 dictionary MLOpSupportLimits { 57 MLInputOperandLayout preferredInputLayout; 58 [EnforceRange] unsigned long long maxTensorByteLength; 59 MLTensorLimits input; 60 MLTensorLimits constant; 61 MLTensorLimits output; 62 }; 63 64 dictionary MLRankRange { 65 unsigned long min; 66 unsigned long max; 67 }; 68 69 typedef sequence<MLOperandDataType> MLDataTypeList; 70 71 dictionary MLTensorLimits { 72 MLDataTypeList dataTypes; 73 MLRankRange rankRange; 74 }; 75 76 dictionary MLBinarySupportLimits { 77 MLTensorLimits a; 78 MLTensorLimits b; 79 MLTensorLimits output; 80 }; 81 82 dictionary MLSingleInputSupportLimits { 83 MLTensorLimits input; 84 MLTensorLimits output; 85 }; 86 87 [SecureContext, Exposed=(Window, Worker)] 88 interface MLGraph { 89 undefined destroy(); 90 }; 91 92 enum MLInputOperandLayout { 93 "nchw", 94 "nhwc" 95 }; 96 97 enum MLOperandDataType { 98 "float32", 99 "float16", 100 "int32", 101 "uint32", 102 "int64", 103 "uint64", 104 "int8", 105 "uint8" 106 }; 107 108 dictionary MLOperandDescriptor { 109 required MLOperandDataType dataType; 110 required sequence<[EnforceRange] unsigned long> shape; 111 }; 112 113 [SecureContext, Exposed=(Window, Worker)] 114 interface MLOperand { 115 readonly attribute MLOperandDataType dataType; 116 readonly attribute FrozenArray<unsigned long> shape; 117 }; 118 119 dictionary MLOperatorOptions { 120 USVString label = ""; 121 }; 122 123 typedef (bigint or unrestricted double) MLNumber; 124 125 dictionary MLTensorDescriptor : MLOperandDescriptor { 126 boolean readable = false; 127 boolean writable = false; 128 }; 129 130 [SecureContext, Exposed=(Window, Worker)] 131 interface MLTensor { 132 readonly attribute MLOperandDataType dataType; 133 readonly attribute FrozenArray<unsigned long> shape; 134 readonly attribute boolean readable; 135 readonly attribute boolean writable; 136 readonly attribute boolean constant; 137 138 undefined destroy(); 139 }; 140 141 typedef record<USVString, MLOperand> MLNamedOperands; 142 143 [SecureContext, Exposed=(Window, Worker)] 144 interface MLGraphBuilder { 145 // Construct the graph builder from the context. 146 constructor(MLContext context); 147 148 // Create an operand for a graph input. 149 MLOperand input(USVString name, MLOperandDescriptor descriptor); 150 151 // Create an operand for a graph constant. 152 MLOperand constant(MLOperandDescriptor descriptor, 153 AllowSharedBufferSource buffer); 154 155 // Create a scalar operand from the specified number of the specified type. 156 MLOperand constant(MLOperandDataType dataType, MLNumber value); 157 158 // Create an operand from a specified constant tensor. 159 MLOperand constant(MLTensor tensor); 160 161 // Compile the graph up to the specified output operands asynchronously. 162 Promise<MLGraph> build(MLNamedOperands outputs); 163 }; 164 165 dictionary MLArgMinMaxOptions : MLOperatorOptions { 166 boolean keepDimensions = false; 167 MLOperandDataType outputDataType = "int32"; 168 }; 169 170 partial interface MLGraphBuilder { 171 MLOperand argMin(MLOperand input, [EnforceRange] unsigned long axis, 172 optional MLArgMinMaxOptions options = {}); 173 MLOperand argMax(MLOperand input, [EnforceRange] unsigned long axis, 174 optional MLArgMinMaxOptions options = {}); 175 }; 176 177 partial dictionary MLOpSupportLimits { 178 MLSingleInputSupportLimits argMin; 179 MLSingleInputSupportLimits argMax; 180 }; 181 182 dictionary MLBatchNormalizationOptions : MLOperatorOptions { 183 MLOperand scale; 184 MLOperand bias; 185 [EnforceRange] unsigned long axis = 1; 186 double epsilon = 1e-5; 187 }; 188 189 partial interface MLGraphBuilder { 190 MLOperand batchNormalization(MLOperand input, MLOperand mean, MLOperand variance, 191 optional MLBatchNormalizationOptions options = {}); 192 }; 193 194 dictionary MLBatchNormalizationSupportLimits { 195 MLTensorLimits input; 196 MLTensorLimits mean; 197 MLTensorLimits variance; 198 MLTensorLimits scale; 199 MLTensorLimits bias; 200 MLTensorLimits output; 201 }; 202 203 partial dictionary MLOpSupportLimits { 204 MLBatchNormalizationSupportLimits batchNormalization; 205 }; 206 207 partial interface MLGraphBuilder { 208 MLOperand cast(MLOperand input, 209 MLOperandDataType dataType, 210 optional MLOperatorOptions options = {}); 211 }; 212 213 partial dictionary MLOpSupportLimits { 214 MLSingleInputSupportLimits cast; 215 }; 216 217 dictionary MLClampOptions : MLOperatorOptions { 218 MLNumber minValue; 219 MLNumber maxValue; 220 }; 221 222 partial interface MLGraphBuilder { 223 MLOperand clamp(MLOperand input, optional MLClampOptions options = {}); 224 }; 225 226 partial dictionary MLOpSupportLimits { 227 MLSingleInputSupportLimits clamp; 228 }; 229 230 partial interface MLGraphBuilder { 231 MLOperand concat(sequence<MLOperand> inputs, 232 [EnforceRange] unsigned long axis, 233 optional MLOperatorOptions options = {}); 234 }; 235 236 dictionary MLConcatSupportLimits { 237 MLTensorLimits inputs; 238 MLTensorLimits output; 239 }; 240 241 partial dictionary MLOpSupportLimits { 242 MLConcatSupportLimits concat; 243 }; 244 245 enum MLConv2dFilterOperandLayout { 246 "oihw", 247 "hwio", 248 "ohwi", 249 "ihwo" 250 }; 251 252 dictionary MLConv2dOptions : MLOperatorOptions { 253 sequence<[EnforceRange] unsigned long> padding; 254 sequence<[EnforceRange] unsigned long> strides; 255 sequence<[EnforceRange] unsigned long> dilations; 256 [EnforceRange] unsigned long groups = 1; 257 MLInputOperandLayout inputLayout = "nchw"; 258 MLConv2dFilterOperandLayout filterLayout = "oihw"; 259 MLOperand bias; 260 }; 261 262 partial interface MLGraphBuilder { 263 MLOperand conv2d(MLOperand input, 264 MLOperand filter, 265 optional MLConv2dOptions options = {}); 266 }; 267 268 dictionary MLConv2dSupportLimits { 269 MLTensorLimits input; 270 MLTensorLimits filter; 271 MLTensorLimits bias; 272 MLTensorLimits output; 273 }; 274 275 partial dictionary MLOpSupportLimits { 276 MLConv2dSupportLimits conv2d; 277 }; 278 279 enum MLConvTranspose2dFilterOperandLayout { 280 "iohw", 281 "hwoi", 282 "ohwi" 283 }; 284 285 dictionary MLConvTranspose2dOptions : MLOperatorOptions { 286 sequence<[EnforceRange] unsigned long> padding; 287 sequence<[EnforceRange] unsigned long> strides; 288 sequence<[EnforceRange] unsigned long> dilations; 289 sequence<[EnforceRange] unsigned long> outputPadding; 290 sequence<[EnforceRange] unsigned long> outputSizes; 291 [EnforceRange] unsigned long groups = 1; 292 MLInputOperandLayout inputLayout = "nchw"; 293 MLConvTranspose2dFilterOperandLayout filterLayout = "iohw"; 294 MLOperand bias; 295 }; 296 297 partial interface MLGraphBuilder { 298 MLOperand convTranspose2d(MLOperand input, MLOperand filter, 299 optional MLConvTranspose2dOptions options = {}); 300 }; 301 302 partial dictionary MLOpSupportLimits { 303 MLConv2dSupportLimits convTranspose2d; 304 }; 305 306 dictionary MLCumulativeSumOptions : MLOperatorOptions { 307 boolean exclusive = false; 308 boolean reversed = false; 309 }; 310 311 partial interface MLGraphBuilder { 312 MLOperand cumulativeSum(MLOperand input, 313 unsigned long axis, 314 optional MLCumulativeSumOptions options = {}); 315 }; 316 317 partial dictionary MLOpSupportLimits { 318 MLSingleInputSupportLimits cumulativeSum; 319 }; 320 321 partial interface MLGraphBuilder { 322 MLOperand add(MLOperand a, MLOperand b, optional MLOperatorOptions options = {}); 323 MLOperand sub(MLOperand a, MLOperand b, optional MLOperatorOptions options = {}); 324 MLOperand mul(MLOperand a, MLOperand b, optional MLOperatorOptions options = {}); 325 MLOperand div(MLOperand a, MLOperand b, optional MLOperatorOptions options = {}); 326 MLOperand max(MLOperand a, MLOperand b, optional MLOperatorOptions options = {}); 327 MLOperand min(MLOperand a, MLOperand b, optional MLOperatorOptions options = {}); 328 MLOperand pow(MLOperand a, MLOperand b, optional MLOperatorOptions options = {}); 329 }; 330 331 partial dictionary MLOpSupportLimits { 332 MLBinarySupportLimits add; 333 MLBinarySupportLimits sub; 334 MLBinarySupportLimits mul; 335 MLBinarySupportLimits div; 336 MLBinarySupportLimits max; 337 MLBinarySupportLimits min; 338 MLBinarySupportLimits pow; 339 }; 340 341 partial interface MLGraphBuilder { 342 MLOperand equal(MLOperand a, 343 MLOperand b, 344 optional MLOperatorOptions options = {}); 345 MLOperand notEqual(MLOperand a, 346 MLOperand b, 347 optional MLOperatorOptions options = {}); 348 MLOperand greater(MLOperand a, 349 MLOperand b, 350 optional MLOperatorOptions options = {}); 351 MLOperand greaterOrEqual(MLOperand a, 352 MLOperand b, 353 optional MLOperatorOptions options = {}); 354 MLOperand lesser(MLOperand a, 355 MLOperand b, 356 optional MLOperatorOptions options = {}); 357 MLOperand lesserOrEqual(MLOperand a, 358 MLOperand b, 359 optional MLOperatorOptions options = {}); 360 MLOperand logicalNot(MLOperand a, optional MLOperatorOptions options = {}); 361 MLOperand logicalAnd(MLOperand a, 362 MLOperand b, 363 optional MLOperatorOptions options = {}); 364 MLOperand logicalOr(MLOperand a, 365 MLOperand b, 366 optional MLOperatorOptions options = {}); 367 MLOperand logicalXor(MLOperand a, 368 MLOperand b, 369 optional MLOperatorOptions options = {}); 370 MLOperand isNaN(MLOperand a, optional MLOperatorOptions options = {}); 371 MLOperand isInfinite(MLOperand a, optional MLOperatorOptions options = {}); 372 }; 373 374 dictionary MLLogicalNotSupportLimits { 375 MLTensorLimits a; 376 MLTensorLimits output; 377 }; 378 379 partial dictionary MLOpSupportLimits { 380 MLBinarySupportLimits equal; 381 MLBinarySupportLimits notEqual; 382 MLBinarySupportLimits greater; 383 MLBinarySupportLimits greaterOrEqual; 384 MLBinarySupportLimits lesser; 385 MLBinarySupportLimits lesserOrEqual; 386 MLLogicalNotSupportLimits logicalNot; 387 MLBinarySupportLimits logicalAnd; 388 MLBinarySupportLimits logicalOr; 389 MLBinarySupportLimits logicalXor; 390 MLLogicalNotSupportLimits isNaN; 391 MLLogicalNotSupportLimits isInfinite; 392 }; 393 394 partial interface MLGraphBuilder { 395 MLOperand abs(MLOperand input, optional MLOperatorOptions options = {}); 396 MLOperand ceil(MLOperand input, optional MLOperatorOptions options = {}); 397 MLOperand cos(MLOperand input, optional MLOperatorOptions options = {}); 398 MLOperand erf(MLOperand input, optional MLOperatorOptions options = {}); 399 MLOperand exp(MLOperand input, optional MLOperatorOptions options = {}); 400 MLOperand floor(MLOperand input, optional MLOperatorOptions options = {}); 401 MLOperand identity(MLOperand input, optional MLOperatorOptions options = {}); 402 MLOperand log(MLOperand input, optional MLOperatorOptions options = {}); 403 MLOperand neg(MLOperand input, optional MLOperatorOptions options = {}); 404 MLOperand reciprocal(MLOperand input, optional MLOperatorOptions options = {}); 405 MLOperand roundEven(MLOperand input, optional MLOperatorOptions options = {}); 406 MLOperand sin(MLOperand input, optional MLOperatorOptions options = {}); 407 MLOperand sign(MLOperand input, optional MLOperatorOptions options = {}); 408 MLOperand sqrt(MLOperand input, optional MLOperatorOptions options = {}); 409 MLOperand tan(MLOperand input, optional MLOperatorOptions options = {}); 410 }; 411 412 partial dictionary MLOpSupportLimits { 413 MLSingleInputSupportLimits abs; 414 MLSingleInputSupportLimits ceil; 415 MLSingleInputSupportLimits cos; 416 MLSingleInputSupportLimits erf; 417 MLSingleInputSupportLimits exp; 418 MLSingleInputSupportLimits floor; 419 MLSingleInputSupportLimits identity; 420 MLSingleInputSupportLimits log; 421 MLSingleInputSupportLimits neg; 422 MLSingleInputSupportLimits reciprocal; 423 MLSingleInputSupportLimits roundEven; 424 MLSingleInputSupportLimits sin; 425 MLSingleInputSupportLimits sign; 426 MLSingleInputSupportLimits sqrt; 427 MLSingleInputSupportLimits tan; 428 }; 429 430 partial interface MLGraphBuilder { 431 MLOperand dequantizeLinear(MLOperand input, 432 MLOperand scale, 433 MLOperand zeroPoint, 434 optional MLOperatorOptions options = {}); 435 }; 436 437 dictionary MLQuantizeDequantizeLinearSupportLimits { 438 MLTensorLimits input; 439 MLTensorLimits scale; 440 MLTensorLimits zeroPoint; 441 MLTensorLimits output; 442 }; 443 444 partial dictionary MLOpSupportLimits { 445 MLQuantizeDequantizeLinearSupportLimits dequantizeLinear; 446 }; 447 448 partial interface MLGraphBuilder { 449 MLOperand quantizeLinear(MLOperand input, 450 MLOperand scale, 451 MLOperand zeroPoint, 452 optional MLOperatorOptions options = {}); 453 }; 454 455 partial dictionary MLOpSupportLimits { 456 MLQuantizeDequantizeLinearSupportLimits quantizeLinear; 457 }; 458 459 dictionary MLEluOptions : MLOperatorOptions { 460 double alpha = 1; 461 }; 462 463 partial interface MLGraphBuilder { 464 MLOperand elu(MLOperand input, optional MLEluOptions options = {}); 465 }; 466 467 partial dictionary MLOpSupportLimits { 468 MLSingleInputSupportLimits elu; 469 }; 470 471 partial interface MLGraphBuilder { 472 MLOperand expand(MLOperand input, 473 sequence<[EnforceRange] unsigned long> newShape, 474 optional MLOperatorOptions options = {}); 475 }; 476 477 partial dictionary MLOpSupportLimits { 478 MLSingleInputSupportLimits expand; 479 }; 480 481 dictionary MLGatherOptions : MLOperatorOptions { 482 [EnforceRange] unsigned long axis = 0; 483 }; 484 485 partial interface MLGraphBuilder { 486 MLOperand gather(MLOperand input, 487 MLOperand indices, 488 optional MLGatherOptions options = {}); 489 }; 490 491 dictionary MLGatherSupportLimits { 492 MLTensorLimits input; 493 MLTensorLimits indices; 494 MLTensorLimits output; 495 }; 496 497 partial dictionary MLOpSupportLimits { 498 MLGatherSupportLimits gather; 499 }; 500 501 partial interface MLGraphBuilder { 502 MLOperand gatherElements(MLOperand input, 503 MLOperand indices, 504 optional MLGatherOptions options = {}); 505 }; 506 507 partial dictionary MLOpSupportLimits { 508 MLGatherSupportLimits gatherElements; 509 }; 510 511 partial interface MLGraphBuilder { 512 MLOperand gatherND(MLOperand input, 513 MLOperand indices, 514 optional MLOperatorOptions options = {}); 515 }; 516 517 partial dictionary MLOpSupportLimits { 518 MLGatherSupportLimits gatherND; 519 }; 520 521 partial interface MLGraphBuilder { 522 MLOperand gelu(MLOperand input, optional MLOperatorOptions options = {}); 523 }; 524 525 partial dictionary MLOpSupportLimits { 526 MLSingleInputSupportLimits gelu; 527 }; 528 529 dictionary MLGemmOptions : MLOperatorOptions { 530 MLOperand c; 531 double alpha = 1.0; 532 double beta = 1.0; 533 boolean aTranspose = false; 534 boolean bTranspose = false; 535 }; 536 537 partial interface MLGraphBuilder { 538 MLOperand gemm(MLOperand a, MLOperand b, optional MLGemmOptions options = {}); 539 }; 540 541 dictionary MLGemmSupportLimits { 542 MLTensorLimits a; 543 MLTensorLimits b; 544 MLTensorLimits c; 545 MLTensorLimits output; 546 }; 547 548 partial dictionary MLOpSupportLimits { 549 MLGemmSupportLimits gemm; 550 }; 551 552 enum MLGruWeightLayout { 553 "zrn", // update-reset-new gate ordering 554 "rzn" // reset-update-new gate ordering 555 }; 556 557 enum MLRecurrentNetworkActivation { 558 "relu", 559 "sigmoid", 560 "tanh" 561 }; 562 563 enum MLRecurrentNetworkDirection { 564 "forward", 565 "backward", 566 "both" 567 }; 568 569 dictionary MLGruOptions : MLOperatorOptions { 570 MLOperand bias; 571 MLOperand recurrentBias; 572 MLOperand initialHiddenState; 573 boolean resetAfter = true; 574 boolean returnSequence = false; 575 MLRecurrentNetworkDirection direction = "forward"; 576 MLGruWeightLayout layout = "zrn"; 577 sequence<MLRecurrentNetworkActivation> activations; 578 }; 579 580 partial interface MLGraphBuilder { 581 sequence<MLOperand> gru(MLOperand input, 582 MLOperand weight, 583 MLOperand recurrentWeight, 584 [EnforceRange] unsigned long steps, 585 [EnforceRange] unsigned long hiddenSize, 586 optional MLGruOptions options = {}); 587 }; 588 589 dictionary MLGruSupportLimits { 590 MLTensorLimits input; 591 MLTensorLimits weight; 592 MLTensorLimits recurrentWeight; 593 MLTensorLimits bias; 594 MLTensorLimits recurrentBias; 595 MLTensorLimits initialHiddenState; 596 MLTensorLimits output0; 597 MLTensorLimits output1; 598 }; 599 600 partial dictionary MLOpSupportLimits { 601 MLGruSupportLimits gru; 602 }; 603 604 dictionary MLGruCellOptions : MLOperatorOptions { 605 MLOperand bias; 606 MLOperand recurrentBias; 607 boolean resetAfter = true; 608 MLGruWeightLayout layout = "zrn"; 609 sequence<MLRecurrentNetworkActivation> activations; 610 }; 611 612 partial interface MLGraphBuilder { 613 MLOperand gruCell(MLOperand input, 614 MLOperand weight, 615 MLOperand recurrentWeight, 616 MLOperand hiddenState, 617 [EnforceRange] unsigned long hiddenSize, 618 optional MLGruCellOptions options = {}); 619 }; 620 621 dictionary MLGruCellSupportLimits { 622 MLTensorLimits input; 623 MLTensorLimits weight; 624 MLTensorLimits recurrentWeight; 625 MLTensorLimits hiddenState; 626 MLTensorLimits bias; 627 MLTensorLimits recurrentBias; 628 MLTensorLimits output; 629 }; 630 631 partial dictionary MLOpSupportLimits { 632 MLGruCellSupportLimits gruCell; 633 }; 634 635 dictionary MLHardSigmoidOptions : MLOperatorOptions { 636 double alpha = 0.2; 637 double beta = 0.5; 638 }; 639 640 partial interface MLGraphBuilder { 641 MLOperand hardSigmoid(MLOperand input, optional MLHardSigmoidOptions options = {}); 642 }; 643 644 partial dictionary MLOpSupportLimits { 645 MLSingleInputSupportLimits hardSigmoid; 646 }; 647 648 partial interface MLGraphBuilder { 649 MLOperand hardSwish(MLOperand input, optional MLOperatorOptions options = {}); 650 }; 651 652 partial dictionary MLOpSupportLimits { 653 MLSingleInputSupportLimits hardSwish; 654 }; 655 656 dictionary MLInstanceNormalizationOptions : MLOperatorOptions { 657 MLOperand scale; 658 MLOperand bias; 659 double epsilon = 1e-5; 660 MLInputOperandLayout layout = "nchw"; 661 }; 662 663 partial interface MLGraphBuilder { 664 MLOperand instanceNormalization( 665 MLOperand input, 666 optional MLInstanceNormalizationOptions options = {}); 667 }; 668 669 dictionary MLNormalizationSupportLimits { 670 MLTensorLimits input; 671 MLTensorLimits scale; 672 MLTensorLimits bias; 673 MLTensorLimits output; 674 }; 675 676 partial dictionary MLOpSupportLimits { 677 MLNormalizationSupportLimits instanceNormalization; 678 }; 679 680 dictionary MLLayerNormalizationOptions : MLOperatorOptions { 681 MLOperand scale; 682 MLOperand bias; 683 sequence<[EnforceRange] unsigned long> axes; 684 double epsilon = 1e-5; 685 }; 686 687 partial interface MLGraphBuilder { 688 MLOperand layerNormalization(MLOperand input, 689 optional MLLayerNormalizationOptions options = {}); 690 }; 691 692 partial dictionary MLOpSupportLimits { 693 MLNormalizationSupportLimits layerNormalization; 694 }; 695 696 dictionary MLLeakyReluOptions : MLOperatorOptions { 697 double alpha = 0.01; 698 }; 699 700 partial interface MLGraphBuilder { 701 MLOperand leakyRelu(MLOperand input, optional MLLeakyReluOptions options = {}); 702 }; 703 704 partial dictionary MLOpSupportLimits { 705 MLSingleInputSupportLimits leakyRelu; 706 }; 707 708 dictionary MLLinearOptions : MLOperatorOptions { 709 double alpha = 1; 710 double beta = 0; 711 }; 712 713 partial interface MLGraphBuilder { 714 MLOperand linear(MLOperand input, optional MLLinearOptions options = {}); 715 }; 716 717 partial dictionary MLOpSupportLimits { 718 MLSingleInputSupportLimits linear; 719 }; 720 721 enum MLLstmWeightLayout { 722 "iofg", // input-output-forget-cell gate ordering 723 "ifgo" // input-forget-cell-output gate ordering 724 }; 725 726 dictionary MLLstmOptions : MLOperatorOptions { 727 MLOperand bias; 728 MLOperand recurrentBias; 729 MLOperand peepholeWeight; 730 MLOperand initialHiddenState; 731 MLOperand initialCellState; 732 boolean returnSequence = false; 733 MLRecurrentNetworkDirection direction = "forward"; 734 MLLstmWeightLayout layout = "iofg"; 735 sequence<MLRecurrentNetworkActivation> activations; 736 }; 737 738 partial interface MLGraphBuilder { 739 sequence<MLOperand> lstm(MLOperand input, 740 MLOperand weight, 741 MLOperand recurrentWeight, 742 [EnforceRange] unsigned long steps, 743 [EnforceRange] unsigned long hiddenSize, 744 optional MLLstmOptions options = {}); 745 }; 746 747 dictionary MLLstmSupportLimits { 748 MLTensorLimits input; 749 MLTensorLimits weight; 750 MLTensorLimits recurrentWeight; 751 MLTensorLimits bias; 752 MLTensorLimits recurrentBias; 753 MLTensorLimits peepholeWeight; 754 MLTensorLimits initialHiddenState; 755 MLTensorLimits initialCellState; 756 MLTensorLimits output0; 757 MLTensorLimits output1; 758 MLTensorLimits output2; 759 }; 760 761 partial dictionary MLOpSupportLimits { 762 MLLstmSupportLimits lstm; 763 }; 764 765 dictionary MLLstmCellOptions : MLOperatorOptions { 766 MLOperand bias; 767 MLOperand recurrentBias; 768 MLOperand peepholeWeight; 769 MLLstmWeightLayout layout = "iofg"; 770 sequence<MLRecurrentNetworkActivation> activations; 771 }; 772 773 partial interface MLGraphBuilder { 774 sequence<MLOperand> lstmCell(MLOperand input, 775 MLOperand weight, 776 MLOperand recurrentWeight, 777 MLOperand hiddenState, 778 MLOperand cellState, 779 [EnforceRange] unsigned long hiddenSize, 780 optional MLLstmCellOptions options = {}); 781 }; 782 783 dictionary MLLstmCellSupportLimits { 784 MLTensorLimits input; 785 MLTensorLimits weight; 786 MLTensorLimits recurrentWeight; 787 MLTensorLimits hiddenState; 788 MLTensorLimits cellState; 789 MLTensorLimits bias; 790 MLTensorLimits recurrentBias; 791 MLTensorLimits peepholeWeight; 792 MLTensorLimits output0; 793 MLTensorLimits output1; 794 }; 795 796 partial dictionary MLOpSupportLimits { 797 MLLstmCellSupportLimits lstmCell; 798 }; 799 800 partial interface MLGraphBuilder { 801 MLOperand matmul(MLOperand a, MLOperand b, optional MLOperatorOptions options = {}); 802 }; 803 804 partial dictionary MLOpSupportLimits { 805 MLBinarySupportLimits matmul; 806 }; 807 808 enum MLPaddingMode { 809 "constant", 810 "edge", 811 "reflection" 812 }; 813 814 dictionary MLPadOptions : MLOperatorOptions { 815 MLPaddingMode mode = "constant"; 816 MLNumber value = 0; 817 }; 818 819 partial interface MLGraphBuilder { 820 MLOperand pad(MLOperand input, 821 sequence<[EnforceRange] unsigned long> beginningPadding, 822 sequence<[EnforceRange] unsigned long> endingPadding, 823 optional MLPadOptions options = {}); 824 }; 825 826 partial dictionary MLOpSupportLimits { 827 MLSingleInputSupportLimits pad; 828 }; 829 830 enum MLRoundingType { 831 "floor", 832 "ceil" 833 }; 834 835 dictionary MLPool2dOptions : MLOperatorOptions { 836 sequence<[EnforceRange] unsigned long> windowDimensions; 837 sequence<[EnforceRange] unsigned long> padding; 838 sequence<[EnforceRange] unsigned long> strides; 839 sequence<[EnforceRange] unsigned long> dilations; 840 MLInputOperandLayout layout = "nchw"; 841 MLRoundingType outputShapeRounding = "floor"; 842 sequence<[EnforceRange] unsigned long> outputSizes; 843 }; 844 845 partial interface MLGraphBuilder { 846 MLOperand averagePool2d(MLOperand input, optional MLPool2dOptions options = {}); 847 MLOperand l2Pool2d(MLOperand input, optional MLPool2dOptions options = {}); 848 MLOperand maxPool2d(MLOperand input, optional MLPool2dOptions options = {}); 849 }; 850 851 partial dictionary MLOpSupportLimits { 852 MLSingleInputSupportLimits averagePool2d; 853 MLSingleInputSupportLimits l2Pool2d; 854 MLSingleInputSupportLimits maxPool2d; 855 }; 856 857 partial interface MLGraphBuilder { 858 MLOperand prelu(MLOperand input, 859 MLOperand slope, 860 optional MLOperatorOptions options = {}); 861 }; 862 863 dictionary MLPreluSupportLimits { 864 MLTensorLimits input; 865 MLTensorLimits slope; 866 MLTensorLimits output; 867 }; 868 869 partial dictionary MLOpSupportLimits { 870 MLPreluSupportLimits prelu; 871 }; 872 873 dictionary MLReduceOptions : MLOperatorOptions { 874 sequence<[EnforceRange] unsigned long> axes; 875 boolean keepDimensions = false; 876 }; 877 878 partial interface MLGraphBuilder { 879 MLOperand reduceL1(MLOperand input, optional MLReduceOptions options = {}); 880 MLOperand reduceL2(MLOperand input, optional MLReduceOptions options = {}); 881 MLOperand reduceLogSum(MLOperand input, optional MLReduceOptions options = {}); 882 MLOperand reduceLogSumExp(MLOperand input, optional MLReduceOptions options = {}); 883 MLOperand reduceMax(MLOperand input, optional MLReduceOptions options = {}); 884 MLOperand reduceMean(MLOperand input, optional MLReduceOptions options = {}); 885 MLOperand reduceMin(MLOperand input, optional MLReduceOptions options = {}); 886 MLOperand reduceProduct(MLOperand input, optional MLReduceOptions options = {}); 887 MLOperand reduceSum(MLOperand input, optional MLReduceOptions options = {}); 888 MLOperand reduceSumSquare(MLOperand input, optional MLReduceOptions options = {}); 889 }; 890 891 partial dictionary MLOpSupportLimits { 892 MLSingleInputSupportLimits reduceL1; 893 MLSingleInputSupportLimits reduceL2; 894 MLSingleInputSupportLimits reduceLogSum; 895 MLSingleInputSupportLimits reduceLogSumExp; 896 MLSingleInputSupportLimits reduceMax; 897 MLSingleInputSupportLimits reduceMean; 898 MLSingleInputSupportLimits reduceMin; 899 MLSingleInputSupportLimits reduceProduct; 900 MLSingleInputSupportLimits reduceSum; 901 MLSingleInputSupportLimits reduceSumSquare; 902 }; 903 904 partial interface MLGraphBuilder { 905 MLOperand relu(MLOperand input, optional MLOperatorOptions options = {}); 906 }; 907 908 partial dictionary MLOpSupportLimits { 909 MLSingleInputSupportLimits relu; 910 }; 911 912 enum MLInterpolationMode { 913 "nearest-neighbor", 914 "linear" 915 }; 916 917 dictionary MLResample2dOptions : MLOperatorOptions { 918 MLInterpolationMode mode = "nearest-neighbor"; 919 sequence<float> scales; 920 sequence<[EnforceRange] unsigned long> sizes; 921 sequence<[EnforceRange] unsigned long> axes; 922 }; 923 924 partial interface MLGraphBuilder { 925 MLOperand resample2d(MLOperand input, optional MLResample2dOptions options = {}); 926 }; 927 928 partial dictionary MLOpSupportLimits { 929 MLSingleInputSupportLimits resample2d; 930 }; 931 932 partial interface MLGraphBuilder { 933 MLOperand reshape(MLOperand input, 934 sequence<[EnforceRange] unsigned long> newShape, 935 optional MLOperatorOptions options = {}); 936 }; 937 938 partial dictionary MLOpSupportLimits { 939 MLSingleInputSupportLimits reshape; 940 }; 941 942 dictionary MLReverseOptions : MLOperatorOptions { 943 sequence<[EnforceRange] unsigned long> axes; 944 }; 945 946 partial interface MLGraphBuilder { 947 MLOperand reverse(MLOperand input, optional MLReverseOptions options = {}); 948 }; 949 950 partial dictionary MLOpSupportLimits { 951 MLSingleInputSupportLimits reverse; 952 }; 953 954 dictionary MLScatterOptions : MLOperatorOptions { 955 [EnforceRange] unsigned long axis = 0; 956 }; 957 958 partial interface MLGraphBuilder { 959 MLOperand scatterElements(MLOperand input, 960 MLOperand indices, 961 MLOperand updates, 962 optional MLScatterOptions options = {}); 963 }; 964 965 dictionary MLScatterSupportLimits { 966 MLTensorLimits input; 967 MLTensorLimits indices; 968 MLTensorLimits updates; 969 MLTensorLimits output; 970 }; 971 972 partial dictionary MLOpSupportLimits { 973 MLScatterSupportLimits scatterElements; 974 }; 975 976 partial interface MLGraphBuilder { 977 MLOperand scatterND(MLOperand input, 978 MLOperand indices, 979 MLOperand updates, 980 optional MLOperatorOptions options = {}); 981 }; 982 983 partial dictionary MLOpSupportLimits { 984 MLScatterSupportLimits scatterND; 985 }; 986 987 partial interface MLGraphBuilder { 988 MLOperand sigmoid(MLOperand input, optional MLOperatorOptions options = {}); 989 }; 990 991 partial dictionary MLOpSupportLimits { 992 MLSingleInputSupportLimits sigmoid; 993 }; 994 995 dictionary MLSliceOptions : MLOperatorOptions { 996 sequence<[EnforceRange] unsigned long> strides; 997 }; 998 999 partial interface MLGraphBuilder { 1000 MLOperand slice(MLOperand input, 1001 sequence<[EnforceRange] unsigned long> starts, 1002 sequence<[EnforceRange] unsigned long> sizes, 1003 optional MLSliceOptions options = {}); 1004 }; 1005 1006 partial dictionary MLOpSupportLimits { 1007 MLSingleInputSupportLimits slice; 1008 }; 1009 1010 partial interface MLGraphBuilder { 1011 MLOperand softmax(MLOperand input, 1012 [EnforceRange] unsigned long axis, 1013 optional MLOperatorOptions options = {}); 1014 }; 1015 1016 partial dictionary MLOpSupportLimits { 1017 MLSingleInputSupportLimits softmax; 1018 }; 1019 1020 partial interface MLGraphBuilder { 1021 MLOperand softplus(MLOperand input, optional MLOperatorOptions options = {}); 1022 }; 1023 1024 partial dictionary MLOpSupportLimits { 1025 MLSingleInputSupportLimits softplus; 1026 }; 1027 1028 partial interface MLGraphBuilder { 1029 MLOperand softsign(MLOperand input, optional MLOperatorOptions options = {}); 1030 }; 1031 1032 partial dictionary MLOpSupportLimits { 1033 MLSingleInputSupportLimits softsign; 1034 }; 1035 1036 dictionary MLSplitOptions : MLOperatorOptions { 1037 [EnforceRange] unsigned long axis = 0; 1038 }; 1039 1040 partial interface MLGraphBuilder { 1041 sequence<MLOperand> split( 1042 MLOperand input, 1043 ([EnforceRange] unsigned long or sequence<[EnforceRange] unsigned long>) splits, 1044 optional MLSplitOptions options = {}); 1045 }; 1046 1047 dictionary MLSplitSupportLimits { 1048 MLTensorLimits input; 1049 MLTensorLimits outputs; 1050 }; 1051 1052 partial dictionary MLOpSupportLimits { 1053 MLSplitSupportLimits split; 1054 }; 1055 1056 partial interface MLGraphBuilder { 1057 MLOperand tanh(MLOperand input, optional MLOperatorOptions options = {}); 1058 }; 1059 1060 partial dictionary MLOpSupportLimits { 1061 MLSingleInputSupportLimits tanh; 1062 }; 1063 1064 partial interface MLGraphBuilder { 1065 MLOperand tile(MLOperand input, 1066 sequence<unsigned long> repetitions, 1067 optional MLOperatorOptions options = {}); 1068 }; 1069 1070 partial dictionary MLOpSupportLimits { 1071 MLSingleInputSupportLimits tile; 1072 }; 1073 1074 dictionary MLTransposeOptions : MLOperatorOptions { 1075 sequence<[EnforceRange] unsigned long> permutation; 1076 }; 1077 1078 partial interface MLGraphBuilder { 1079 MLOperand transpose(MLOperand input, optional MLTransposeOptions options = {}); 1080 }; 1081 1082 partial dictionary MLOpSupportLimits { 1083 MLSingleInputSupportLimits transpose; 1084 }; 1085 1086 dictionary MLTriangularOptions : MLOperatorOptions { 1087 boolean upper = true; 1088 [EnforceRange] long diagonal = 0; 1089 }; 1090 1091 partial interface MLGraphBuilder { 1092 MLOperand triangular(MLOperand input, optional MLTriangularOptions options = {}); 1093 }; 1094 1095 partial dictionary MLOpSupportLimits { 1096 MLSingleInputSupportLimits triangular; 1097 }; 1098 1099 partial interface MLGraphBuilder { 1100 MLOperand where(MLOperand condition, 1101 MLOperand trueValue, 1102 MLOperand falseValue, 1103 optional MLOperatorOptions options = {}); 1104 }; 1105 1106 dictionary MLWhereSupportLimits { 1107 MLTensorLimits condition; 1108 MLTensorLimits trueValue; 1109 MLTensorLimits falseValue; 1110 MLTensorLimits output; 1111 }; 1112 1113 partial dictionary MLOpSupportLimits { 1114 MLWhereSupportLimits where; 1115 };