pytorch - 💡(How to fix) Fix Make `ONNX_DEFAULT_OPSET` public. [4 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
pytorch/pytorch#178053Fetched 2026-04-08 01:12:29
View on GitHub
Comments
4
Participants
2
Timeline
19
Reactions
0
Author
Participants
Timeline (top)
commented ×4labeled ×4mentioned ×3subscribed ×3
RAW_BUFFERClick to expand / collapse

For my downstream applications it is really useful to just be able to go with the default opset version, but for logging purposes and model versioning it would still be nice to know the opset version that was used. Currently the ONNX_DEFAULT_OPSET is in the private module torch/onnx/_constants.py, which is why I am hesitant to use the constant directly. Would it be possible to make this a public constant? It has been there for multiple years, so I would consider it stable.

cc @justinchuby @titaiwangms

extent analysis

Fix Plan

To make the ONNX_DEFAULT_OPSET a public constant, we can create a new public module or add it to an existing one.

Steps

  • Create a new file torch/onnx/constants.py with the following content:
from torch.onnx._constants import ONNX_DEFAULT_OPSET as _ONNX_DEFAULT_OPSET

ONNX_DEFAULT_OPSET = _ONNX_DEFAULT_OPSET
  • Alternatively, add the constant to an existing public module, such as torch/onnx/__init__.py:
from torch.onnx._constants import ONNX_DEFAULT_OPSET

__all__ = [..., 'ONNX_DEFAULT_OPSET']
  • Update the documentation to reflect the new public constant.

Verification

To verify the fix, check that the constant is accessible from the new public module:

import torch.onnx

print(torch.onnx.ONNX_DEFAULT_OPSET)

This should print the default opset version.

Extra Tips

  • Make sure to update the documentation and tests to reflect the new public constant.
  • Consider adding a deprecation warning for the private constant to encourage users to switch to the new public one.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING