mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[ONNX] Set default opset to 20 (#158802)
Bump default opset to 20, which is a newer opset and the max torchscript exporter supports. Pull Request resolved: https://github.com/pytorch/pytorch/pull/158802 Approved by: https://github.com/titaiwangms
This commit is contained in:
committed by
PyTorch MergeBot
parent
c917c63282
commit
767791943d
@ -281,10 +281,11 @@ class TestExportAPIDynamo(common_utils.TestCase):
|
||||
# Use GELU activation function
|
||||
return torch.nn.functional.gelu(input, approximate="tanh")
|
||||
|
||||
input = torch.randn(1, 3, 4, 4)
|
||||
input = (torch.randn(1, 3, 4, 4),)
|
||||
onnx_program_op18 = torch.onnx.export(
|
||||
GeluModel(),
|
||||
input,
|
||||
opset_version=18,
|
||||
dynamo=True,
|
||||
)
|
||||
all_nodes_op18 = [n.op_type for n in onnx_program_op18.model.graph]
|
||||
|
@ -6,7 +6,7 @@ ONNX_BASE_OPSET = 9
|
||||
ONNX_MIN_OPSET = 7
|
||||
ONNX_MAX_OPSET = 23
|
||||
ONNX_TORCHSCRIPT_EXPORTER_MAX_OPSET = 20
|
||||
ONNX_DEFAULT_OPSET = 18
|
||||
ONNX_DEFAULT_OPSET = 20
|
||||
ONNX_CONSTANT_FOLDING_MIN_OPSET = 9
|
||||
|
||||
PYTORCH_GITHUB_ISSUES_URL = "https://github.com/pytorch/pytorch/issues"
|
||||
|
@ -10,9 +10,9 @@ from collections.abc import Mapping, Sequence
|
||||
from typing import Any, Callable, TYPE_CHECKING
|
||||
|
||||
import torch
|
||||
from torch.onnx import _constants as onnx_constants
|
||||
from torch.onnx._internal._lazy_import import onnxscript_apis, onnxscript_ir as ir
|
||||
from torch.onnx._internal.exporter import (
|
||||
_constants,
|
||||
_core,
|
||||
_dynamic_shapes,
|
||||
_onnx_program,
|
||||
@ -50,7 +50,7 @@ def export_compat(
|
||||
verbose: bool | None = None,
|
||||
input_names: Sequence[str] | None = None,
|
||||
output_names: Sequence[str] | None = None,
|
||||
opset_version: int | None = _constants.TORCHLIB_OPSET,
|
||||
opset_version: int | None = onnx_constants.ONNX_DEFAULT_OPSET,
|
||||
custom_translation_table: dict[Callable, Callable | Sequence[Callable]]
|
||||
| None = None,
|
||||
dynamic_axes: Mapping[str, Mapping[int, str]]
|
||||
@ -70,7 +70,7 @@ def export_compat(
|
||||
legacy_export_kwargs: dict[str, Any] | None = None,
|
||||
) -> _onnx_program.ONNXProgram:
|
||||
if opset_version is None:
|
||||
opset_version = _constants.TORCHLIB_OPSET
|
||||
opset_version = onnx_constants.ONNX_DEFAULT_OPSET
|
||||
|
||||
if isinstance(model, torch.export.ExportedProgram):
|
||||
# We know the model is already exported program, so the args, kwargs, and dynamic_shapes
|
||||
|
Reference in New Issue
Block a user