Voice et bot modif

This commit is contained in:
pi 2026-06-16 17:09:34 +00:00
parent 189d56026b
commit 7333a22bcd
10774 changed files with 634644 additions and 933308 deletions

View file

@ -13,13 +13,16 @@ Keep in sync with doco generated from /docs/execution-providers/CoreML-Execution
|ai.onnx:ConvTranspose|Weight and bias must be constant.<br/>padding_type of SAME_UPPER/SAME_LOWER is not supported.<br/>kernel_shape must have default values.<br/>output_shape is not supported.<br/>output_padding must have default values.|
|ai.onnx:DepthToSpace|If 'mode' is 'CRD' the input must have a fixed shape.|
|ai.onnx:Div||
|ai.onnx:Elu||
|ai.onnx:Erf||
|ai.onnx:Exp||
|ai.onnx:Gemm|Input B must be constant.|
|ai.onnx:Gelu||
|ai.onnx:GlobalAveragePool|Only 2D Pool is supported currently. 3D and 5D support can be added if needed.|
|ai.onnx:GlobalMaxPool|Only 2D Pool is supported currently. 3D and 5D support can be added if needed.|
|ai.onnx:GridSample|4D input.<br/>'mode' of 'linear' or 'zeros'.<br/>(mode==linear && padding_mode==reflection && align_corners==0) is not supported.|
|ai.onnx:GroupNormalization||
|ai.onnx:HardSigmoid||
|ai.onnx:InstanceNormalization||
|ai.onnx:LayerNormalization||
|ai.onnx:LeakyRelu||
@ -39,6 +42,7 @@ Keep in sync with doco generated from /docs/execution-providers/CoreML-Execution
|ai.onnx:Round||
|ai.onnx:Shape||
|ai.onnx:Slice|starts/ends/axes/steps must be constant initializers.|
|ai.onnx:Softplus||
|ai.onnx:Split|If provided, `splits` must be constant.|
|ai.onnx:Sub||
|ai.onnx:Sigmoid||
@ -48,3 +52,4 @@ Keep in sync with doco generated from /docs/execution-providers/CoreML-Execution
|ai.onnx:Tanh||
|ai.onnx:Transpose||
|ai.onnx:Unsqueeze||
|com.microsoft:QuickGelu|Produced by ORT's `QuickGeluFusion` optimizer pass. Decomposed into `mul` / `sigmoid` / `mul`.|

View file

@ -6,6 +6,7 @@ Support for registering ONNX Runtime's built-in contrib ops with
PyTorch-ONNX exporter (torch.onnx.export).
"""
import contextlib
import typing
try:
@ -22,7 +23,7 @@ _OPSET_VERSION = 1
_registered_ops: typing.AbstractSet[str] = set()
def _reg(symbolic_fn: typing.Callable, namespace: str = ""):
def _reg(symbolic_fn: typing.Callable, namespace: str = "aten"):
name = f"{namespace}::{symbolic_fn.__name__}"
torch.onnx.register_custom_op_symbolic(name, symbolic_fn, _OPSET_VERSION)
_registered_ops.add(name)
@ -49,13 +50,6 @@ def register():
padding_mode_str = ["zeros", "border", "reflection"][padding_mode]
align_corners = int(symbolic_helper._maybe_get_const(align_corners, "b"))
# From opset v13 onward, the output shape can be specified with
# (N, C, H, W) (N, H_out, W_out, 2) => (N, C, H_out, W_out)
# input_shape = input.type().sizes()
# gird_shape = grid.type().sizes()
# output_shape = input_shape[:2] + gird_shape[1:3]
# g.op(...).setType(input.type().with_sizes(output_shape))
return g.op(
"com.microsoft::GridSample",
input,
@ -71,15 +65,24 @@ def register():
return g.op("com.microsoft::Inverse", self).setType(self.type())
_reg(inverse)
torch.onnx.register_custom_op_symbolic("aten::linalg_inv", inverse, _OPSET_VERSION)
_registered_ops.add("aten::linalg_inv")
@torch.onnx.symbolic_helper.parse_args("v", "s")
def gelu(g, self: torch._C.Value, approximate: str = "none"):
# Use microsoft::Gelu for performance if possible. It only supports approximate == "none"
def gelu(g, self: torch._C.Value, approximate="none"):
# PyTorch can emit aten::gelu with or without the optional approximate arg.
if not isinstance(approximate, str):
approximate = symbolic_helper._maybe_get_const(approximate, "s")
# Use microsoft::Gelu for performance if possible. It only supports approximate == "none".
if approximate == "none":
return g.op("com.microsoft::Gelu", self).setType(self.type())
return torch.onnx.symbolic_opset9.gelu(g, self, approximate)
_reg(gelu)
# Some PyTorch versions dispatch GELU symbolic lookup by exporter opset.
# Registering across stable opsets keeps ORT Gelu fusion consistently enabled.
for opset in range(9, 21):
torch.onnx.register_custom_op_symbolic("aten::gelu", gelu, opset)
def triu(g, self, diagonal):
return g.op("com.microsoft::Trilu", self, diagonal, upper_i=1).setType(self.type())
@ -127,3 +130,8 @@ def unregister():
for version in symbolic_helper._onnx_stable_opsets:
if version >= _OPSET_VERSION and symbolic_registry.is_registered_op(kind, namespace, version):
del symbolic_registry._registry[(namespace, version)][kind]
# Also clean up gelu's multi-opset registrations (see register()).
for opset in range(9, 21):
with contextlib.suppress(Exception):
torch.onnx.unregister_custom_op_symbolic("aten::gelu", opset)

View file

@ -1,6 +1,8 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
from __future__ import annotations
import inspect
from collections import abc

View file

@ -7,7 +7,12 @@ import logging
import numpy as np
import onnx
import sympy
try:
import sympy
except ImportError:
raise ImportError("sympy is required for symbolic shape inference. Install with: pip install sympy") from None
from onnx import helper, numpy_helper, shape_inference
from packaging import version