Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5394 enable py311 tests #7182

Merged
merged 7 commits into from
Nov 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 21 additions & 33 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,22 +724,16 @@ def test_script_save(net, *inputs, device=None, rtol=1e-4, atol=0.0):
"""
# TODO: would be nice to use GPU if available, but it currently causes CI failures.
device = "cpu"
try:
with tempfile.TemporaryDirectory() as tempdir:
convert_to_torchscript(
model=net,
filename_or_obj=os.path.join(tempdir, "model.ts"),
verify=True,
inputs=inputs,
device=device,
rtol=rtol,
atol=atol,
)
except (RuntimeError, AttributeError):
if sys.version_info.major == 3 and sys.version_info.minor == 11:
warnings.warn("skipping py 3.11")
return
raise
with tempfile.TemporaryDirectory() as tempdir:
convert_to_torchscript(
model=net,
filename_or_obj=os.path.join(tempdir, "model.ts"),
verify=True,
inputs=inputs,
device=device,
rtol=rtol,
atol=atol,
)


def test_onnx_save(net, *inputs, device=None, rtol=1e-4, atol=0.0):
Expand All @@ -753,23 +747,17 @@ def test_onnx_save(net, *inputs, device=None, rtol=1e-4, atol=0.0):
# TODO: would be nice to use GPU if available, but it currently causes CI failures.
device = "cpu"
_, has_onnxruntime = optional_import("onnxruntime")
try:
with tempfile.TemporaryDirectory() as tempdir:
convert_to_onnx(
model=net,
filename=os.path.join(tempdir, "model.onnx"),
verify=True,
inputs=inputs,
device=device,
use_ort=has_onnxruntime,
rtol=rtol,
atol=atol,
)
except (RuntimeError, AttributeError):
if sys.version_info.major == 3 and sys.version_info.minor == 11:
wyli marked this conversation as resolved.
Show resolved Hide resolved
warnings.warn("skipping py 3.11")
return
raise
with tempfile.TemporaryDirectory() as tempdir:
convert_to_onnx(
model=net,
filename=os.path.join(tempdir, "model.onnx"),
verify=True,
inputs=inputs,
device=device,
use_ort=has_onnxruntime,
rtol=rtol,
atol=atol,
)


def download_url_or_skip_test(*args, **kwargs):
Expand Down