8000 Update warnings · pytorch/pytorch@b024438 · GitHub
[go: up one dir, main page]

Skip to content

Commit b024438

Browse files
committed
Update warnings
1 parent f63c04a commit b024438

File tree

5 files changed

+21
-35
lines changed

5 files changed

+21
-35
lines changed

torch/onnx/__init__.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ def export(
169169
custom_opsets: Mapping[str, int] | None = None,
170170
export_modules_as_functions: bool | Collection[type[torch.nn.Module]] = False,
171171
autograd_inlining: bool = True,
172-
**_ignored_kwargs: Any,
173172
) -> ONNXProgram | None:
174173
r"""Exports a model into ONNX format.
175174
@@ -348,11 +347,6 @@ def forward(self, x):
348347
Flag used to control whether to inline autograd functions.
349348
Refer to https://github.com/pytorch/pytorch/pull/74765 for more details.
350349
"""
351-
if _ignored_kwargs:
352-
logger.warning(
353-
"torch.onnx.export received unexpected keyword arguments: %s",
354-
_ignored_kwargs,
355-
)
356350
if dynamo is True or isinstance(model, torch.export.ExportedProgram):
357351
from torch.onnx._internal.exporter import _compat
358352

@@ -413,8 +407,7 @@ def forward(self, x):
413407

414408

415409
@deprecated(
416-
"torch.onnx.dynamo_export is deprecated since 2.6.0. Please use torch.onnx.export(..., dynamo=True) instead.",
417-
category=None,
410+
"torch.onnx.dynamo_export is deprecated since 2.6.0. Please use torch.onnx.export(..., dynamo=True) instead."
418411
)
419412
def dynamo_export(
420413
model: torch.nn.Module | Callable | torch.export.ExportedProgram, # type: ignore[name-defined]
@@ -493,7 +486,7 @@ def forward(self, x, bias=None):
493486
"You are using an experimental ONNX export logic, which currently only supports dynamic shapes. "
494487
"For a more comprehensive set of export options, including advanced features, please consider using "
495488
"`torch.onnx.export(..., dynamo=True)`. ",
496-
category=FutureWarning,
489+
category=DeprecationWarning,
497490
)
498491

499492
if export_options is not None and export_options.dynamic_shapes:

torch/onnx/_internal/_exporter_legacy.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ class ONNXFakeContext:
8181

8282

8383
@deprecated(
84-
"torch.onnx.dynamo_export is deprecated since 2.6.0. Please use torch.onnx.export(..., dynamo=True) instead.",
85-
category=None,
84+
"torch.onnx.dynamo_export is deprecated since 2.6.0. Please use torch.onnx.export(..., dynamo=True) instead."
8685
)
8786
class OnnxRegistry:
8887
"""Registry for ONNX functions.
@@ -233,8 +232,7 @@ def _all_registered_ops(self) -> set[str]:
233232

234233

235234
@deprecated(
236-
"torch.onnx.dynamo_export is deprecated since 2.6.0. Please use torch.onnx.export(..., dynamo=True) instead.",
237-
category=None,
235+
"torch.onnx.dynamo_export is deprecated since 2.6.0. Please use torch.onnx.export(..., dynamo=True) instead."
238236
)
239237
class ExportOptions:
240238
"""Options to influence the TorchDynamo ONNX exporter.
@@ -451,8 +449,7 @@ def enable_fake_mode():
451449

452450

453451
@deprecated(
454-
"torch.onnx.dynamo_export is deprecated since 2.6.0. Please use torch.onnx.export(..., dynamo=True) instead.",
455-
category=None,
452+
"torch.onnx.dynamo_export is deprecated since 2.6.0. Please use torch.onnx.export(..., dynamo=True) instead."
456453
)
457454
class ONNXRuntimeOptions:
458455
"""Options to influence the execution of the ONNX model through ONNX Runtime.
@@ -713,8 +710,7 @@ def missing_opset(package_name: str):
713710

714711

715712
@deprecated(
716-
"torch.onnx.dynamo_export is deprecated since 2.6.0. Please use torch.onnx.export(..., dynamo=True) instead.",
717-
category=None,
713+
"torch.onnx.dynamo_export is deprecated since 2.6.0. Please use torch.onnx.export(..., dynamo=True) instead."
718714
)
719715
def dynamo_export(
720716
model: torch.nn.Module | Callable,

torch/onnx/symbolic_opset9.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3316,55 +3316,55 @@ def _unique2(g: jit_utils.GraphContext, input, sorted, return_inverse, return_co
33163316

33173317

33183318
@_onnx_symbolic("aten::_cast_Byte")
3319-
@deprecated("Avoid using this function and create a Cast node instead", category=None)
3319+
@deprecated("Avoid using this function and create a Cast node instead")
33203320
def _cast_Byte(g: jit_utils.GraphContext, input, non_blocking):
33213321
return g.op("Cast", input, to_i=_C_onnx.TensorProtoDataType.UINT8)
33223322

33233323

33243324
@_onnx_symbolic("aten::_cast_Char")
3325-
@deprecated("Avoid using this function and create a Cast node instead", category=None)
3325+
@deprecated("Avoid using this function and create a Cast node instead")
33263326
def _cast_Char(g: jit_utils.GraphContext, input, non_blocking):
33273327
return g.op("Cast", input, to_i=_C_onnx.TensorProtoDataType.INT8)
33283328

33293329

33303330
@_onnx_symbolic("aten::_cast_Short")
3331-
@deprecated("Avoid using this function and create a Cast node instead", category=None)
3331+
@deprecated("Avoid using this function and create a Cast node instead")
33323332
def _cast_Short(g: jit_utils.GraphContext, input, non_blocking):
33333333
return g.op("Cast", input, to_i=_C_onnx.TensorProtoDataType.INT16)
33343334

33353335

33363336
@_onnx_symbolic("aten::_cast_Int")
3337-
@deprecated("Avoid using this function and create a Cast node instead", category=None)
3337+
@deprecated("Avoid using this function and create a Cast node instead")
33383338
def _cast_Int(g: jit_utils.GraphContext, input, non_blocking):
33393339
return g.op("Cast", input, to_i=_C_onnx.TensorProtoDataType.INT32)
33403340

33413341

33423342
@_onnx_symbolic("aten::_cast_Long")
3343-
@deprecated("Avoid using this function and create a Cast node instead", category=None)
3343+
@deprecated("Avoid using this function and create a Cast node instead")
33443344
def _cast_Long(g: jit_utils.GraphContext, input, non_blocking):
33453345
return g.op("Cast", input, to_i=_C_onnx.TensorProtoDataType.INT64)
33463346

33473347

33483348
@_onnx_symbolic("aten::_cast_Half")
3349-
@deprecated("Avoid using this function and create a Cast node instead", category=None)
3349+
@deprecated("Avoid using this function and create a Cast node instead")
33503350
def _cast_Half(g: jit_utils.GraphContext, input, non_blocking):
33513351
return g.op("Cast", input, to_i=_C_onnx.TensorProtoDataType.FLOAT16)
33523352

33533353

33543354
@_onnx_symbolic("aten::_cast_Float")
3355-
@deprecated("Avoid using this function and create a Cast node instead", category=None)
3355+
@deprecated("Avoid using this function and create a Cast node instead")
33563356
def _cast_Float(g: jit_utils.GraphContext, input, non_blocking):
33573357
return g.op("Cast", input, to_i=_C_onnx.TensorProtoDataType.FLOAT)
33583358

33593359

33603360
@_onnx_symbolic("aten::_cast_Double")
3361-
@deprecated("Avoid using this function and create a Cast node instead", category=None)
3361+
@deprecated("Avoid using this function and create a Cast node instead")
33623362
def _cast_Double(g: jit_utils.GraphContext, input, non_blocking):
33633363
return g.op("Cast", input, to_i=_C_onnx.TensorProtoDataType.DOUBLE)
33643364

33653365

33663366
@_onnx_symbolic("aten::_cast_Bool")
3367-
@deprecated("Avoid using this function and create a Cast node instead", category=None)
3367+
@deprecated("Avoid using this function and create a Cast node instead")
33683368
def _cast_Bool(g: jit_utils.GraphContext, input, non_blocking):
33693369
return g.op("Cast", input, to_i=_C_onnx.TensorProtoDataType.BOOL)
33703370

torch/onnx/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def disable_apex_o2_state_dict_hook(model: torch.nn.Module | torch.jit.ScriptFun
147147
pass
148148

149149

150-
@deprecated("Please remove usage of this function", category=None)
150+
@deprecated("Please remove usage of this function")
151151
@contextlib.contextmanager
152152
def setup_onnx_logging(verbose: bool):
153153
"""A context manager to temporarily set the ONNX logging verbosity.
@@ -510,14 +510,14 @@ def forward(self, x):
510510
warnings.warn(
511511
"Setting `operator_export_type` to something other than default is deprecated. "
512512
"The option will be removed in a future release.",
513-
category=FutureWarning,
513+
category=DeprecationWarning,
514514
)
515515
if training == _C_onnx.TrainingMode.TRAINING:
516516
warnings.warn(
517517
"Setting `training` to something other than default is deprecated. "
518518
"The option will be removed in a future release. Please set the training mode "
519519
"before exporting the model.",
520-
category=FutureWarning,
520+
category=DeprecationWarning,
521521
)
522522

523523
args = (args,) if isinstance(args, torch.Tensor) else args

torch/onnx/verification.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -871,8 +871,7 @@ def verify(
871871

872872
@typing_extensions.deprecated(
873873
"torch.onnx.verification.* is deprecated. Consider using torch.onnx.export(..., dynamo=True) "
874-
"and use ONNXProgram to test the ONNX model",
875-
category=None,
874+
"and use ONNXProgram to test the ONNX model"
876875
)
877876
def verify_aten_graph(
878877
graph: torch.Graph,
@@ -1173,8 +1172,7 @@ def validate(self, options: VerificationOptions):
11731172

11741173
@typing_extensions.deprecated(
11751174
"torch.onnx.verification.* is deprecated. Consider using torch.onnx.export(..., dynamo=True) "
1176-
"and use ONNXProgram to test the ONNX model",
1177-
category=None,
1175+
"and use ONNXProgram to test the ONNX model"
11781176
)
11791177
@dataclasses.dataclass
11801178
class GraphInfo:
@@ -1711,8 +1709,7 @@ def _produced_by(value: torch.Value, nodes: Collection[torch.Node]) -> bool:
17111709

17121710
@typing_extensions.deprecated(
17131711
"torch.onnx.verification.* is deprecated. Consider using torch.onnx.export(..., dynamo=True) "
1714-
"and use ONNXProgram to test the ONNX model",
1715-
category=None,
1712+
"and use ONNXProgram to test the ONNX model"
17161713
)
17171714
def find_mismatch(
17181715
model: torch.nn.Module | torch.jit.ScriptModule,

0 commit comments

Comments
 (0)
0