Revert "[ONNX] Create deprecation warning on dynamo_export (#146003)"

This reverts commit e6c39d37e9.

Reverted https://github.com/pytorch/pytorch/pull/146003 on behalf of https://github.com/atalman due to Broke internally ([comment](https://github.com/pytorch/pytorch/pull/146003#issuecomment-2631599314))
This commit is contained in:
PyTorch MergeBot 2025-02-03 17:17:14 +00:00
parent 041e08f9dc
commit 64fc9ff09c
7 changed files with 22 additions and 37 deletions

View file

@ -341,6 +341,22 @@ class TestONNXExport(pytorch_test_common.ExportTestCase):
f = io.BytesIO()
torch.onnx.export(foo, (torch.zeros(1, 2, 3)), f)
def test_listconstruct_erasure(self):
class FooMod(torch.nn.Module):
def forward(self, x):
mask = x < 0.0
return x[mask]
f = io.BytesIO()
torch.onnx.export(
FooMod(),
(torch.rand(3, 4),),
f,
add_node_names=False,
do_constant_folding=False,
operator_export_type=torch.onnx.OperatorExportTypes.ONNX_ATEN_FALLBACK,
)
def test_export_dynamic_slice(self):
class DynamicSliceExportMod(torch.jit.ScriptModule):
@torch.jit.script_method

View file

@ -165,6 +165,7 @@ def export(
custom_opsets: Mapping[str, int] | None = None,
export_modules_as_functions: bool | Collection[type[torch.nn.Module]] = False,
autograd_inlining: bool = True,
**_: Any, # ignored options
) -> ONNXProgram | None:
r"""Exports a model into ONNX format.
@ -476,7 +477,7 @@ def dynamo_export(
"You are using an experimental ONNX export logic, which currently only supports dynamic shapes. "
"For a more comprehensive set of export options, including advanced features, please consider using "
"`torch.onnx.export(..., dynamo=True)`. ",
category=DeprecationWarning,
category=FutureWarning,
)
if export_options is not None and export_options.dynamic_shapes:

View file

@ -32,7 +32,7 @@ def deprecated(
f"'{function.__module__}.{function.__name__}' "
f"is deprecated in version {since} and will be "
f"removed in {removed_in}. Please {instructions}.",
category=DeprecationWarning,
category=FutureWarning,
stacklevel=2,
)
return function(*args, **kwargs)

View file

@ -21,7 +21,6 @@ import logging
import warnings
from collections import defaultdict
from typing import Any, Callable, TYPE_CHECKING, TypeVar
from typing_extensions import deprecated
import torch
import torch._ops
@ -80,10 +79,6 @@ class ONNXFakeContext:
"""List of paths of files that contain the model :meth:`state_dict`"""
@deprecated(
"torch.onnx.dynamo_export is deprecated since 2.6.0. Please use torch.onnx.export(..., dynamo=True) instead.",
category=DeprecationWarning,
)
class OnnxRegistry:
"""Registry for ONNX functions.
@ -228,10 +223,6 @@ class OnnxRegistry:
}
@deprecated(
"torch.onnx.dynamo_export is deprecated since 2.6.0. Please use torch.onnx.export(..., dynamo=True) instead.",
category=DeprecationWarning,
)
class ExportOptions:
"""Options to influence the TorchDynamo ONNX exporter.
@ -439,10 +430,6 @@ def enable_fake_mode():
) # type: ignore[assignment]
@deprecated(
"torch.onnx.dynamo_export is deprecated since 2.6.0. Please use torch.onnx.export(..., dynamo=True) instead.",
category=DeprecationWarning,
)
class ONNXRuntimeOptions:
"""Options to influence the execution of the ONNX model through ONNX Runtime.
@ -697,10 +684,6 @@ def _assert_dependencies(export_options: ResolvedExportOptions):
raise missing_opset("onnxscript")
@deprecated(
"torch.onnx.dynamo_export is deprecated since 2.6.0. Please use torch.onnx.export(..., dynamo=True) instead.",
category=DeprecationWarning,
)
def dynamo_export(
model: torch.nn.Module | Callable,
/,

View file

@ -218,6 +218,7 @@ def export_compat(
dump_exported_program: bool = False,
artifacts_dir: str | os.PathLike = ".",
fallback: bool = False,
**_,
) -> _onnx_program.ONNXProgram:
if opset_version is None:
opset_version = onnxscript_apis.torchlib_opset_version()

View file

@ -482,14 +482,14 @@ def export(
warnings.warn(
"Setting `operator_export_type` to something other than default is deprecated. "
"The option will be removed in a future release.",
category=DeprecationWarning,
category=FutureWarning,
)
if training == _C_onnx.TrainingMode.TRAINING:
warnings.warn(
"Setting `training` to something other than default is deprecated. "
"The option will be removed in a future release. Please set the training mode "
"before exporting the model.",
category=DeprecationWarning,
category=FutureWarning,
)
args = (args,) if isinstance(args, torch.Tensor) else args

View file

@ -17,7 +17,6 @@ import io
import itertools
import os
import tempfile
import typing_extensions
import warnings
from collections.abc import Collection, Mapping, Sequence
from typing import Any, Callable, Union
@ -772,11 +771,6 @@ def check_export_model_diff(
)
@typing_extensions.deprecated(
"torch.onnx.verification.* is deprecated. Consider using torch.onnx.export(..., dynamo=True) "
"and use ONNXProgram to test the ONNX model",
category=DeprecationWarning,
)
def verify(
model: _ModelType,
input_args: _InputArgsType,
@ -864,11 +858,6 @@ def verify(
)
@typing_extensions.deprecated(
"torch.onnx.verification.* is deprecated. Consider using torch.onnx.export(..., dynamo=True) "
"and use ONNXProgram to test the ONNX model",
category=DeprecationWarning,
)
def verify_aten_graph(
graph: torch.Graph,
input_args: tuple[Any, ...],
@ -1159,11 +1148,6 @@ class OnnxTestCaseRepro:
_compare_onnx_pytorch_outputs_in_np(run_outputs, expected_outs, options)
@typing_extensions.deprecated(
"torch.onnx.verification.* is deprecated. Consider using torch.onnx.export(..., dynamo=True) "
"and use ONNXProgram to test the ONNX model",
category=DeprecationWarning,
)
@dataclasses.dataclass
class GraphInfo:
"""GraphInfo contains validation information of a TorchScript graph and its converted ONNX graph."""