Use opset table for torch<1.13 (#22155)

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
Glenn Jocher 2025-09-19 16:12:52 +01:00 committed by GitHub
parent aa8a1d5d9d
commit 67aa76afca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -154,7 +154,7 @@ def export_formats():
def best_onnx_opset(onnx) -> int:
"""Return max ONNX opset for this torch version with ONNX fallback."""
if hasattr(torch.onnx.utils, "_constants"): # not supported in torch 1.8
if TORCH_1_13: # not supported by torch<1.13
opset = torch.onnx.utils._constants.ONNX_MAX_OPSET - 1 # use second-latest version for safety
else:
opset = {