Skip to content

Commit cf886e7

Browse files
authored
5394 enable py311 tests (#7182)
Fixes #5394 ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [ ] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. --------- Signed-off-by: Wenqi Li <[email protected]>
1 parent 3239db8 commit cf886e7

File tree

1 file changed

+21
-33
lines changed

1 file changed

+21
-33
lines changed

tests/utils.py

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -724,22 +724,16 @@ def test_script_save(net, *inputs, device=None, rtol=1e-4, atol=0.0):
724724
"""
725725
# TODO: would be nice to use GPU if available, but it currently causes CI failures.
726726
device = "cpu"
727-
try:
728-
with tempfile.TemporaryDirectory() as tempdir:
729-
convert_to_torchscript(
730-
model=net,
731-
filename_or_obj=os.path.join(tempdir, "model.ts"),
732-
verify=True,
733-
inputs=inputs,
734-
device=device,
735-
rtol=rtol,
736-
atol=atol,
737-
)
738-
except (RuntimeError, AttributeError):
739-
if sys.version_info.major == 3 and sys.version_info.minor == 11:
740-
warnings.warn("skipping py 3.11")
741-
return
742-
raise
727+
with tempfile.TemporaryDirectory() as tempdir:
728+
convert_to_torchscript(
729+
model=net,
730+
filename_or_obj=os.path.join(tempdir, "model.ts"),
731+
verify=True,
732+
inputs=inputs,
733+
device=device,
734+
rtol=rtol,
735+
atol=atol,
736+
)
743737

744738

745739
def test_onnx_save(net, *inputs, device=None, rtol=1e-4, atol=0.0):
@@ -753,23 +747,17 @@ def test_onnx_save(net, *inputs, device=None, rtol=1e-4, atol=0.0):
753747
# TODO: would be nice to use GPU if available, but it currently causes CI failures.
754748
device = "cpu"
755749
_, has_onnxruntime = optional_import("onnxruntime")
756-
try:
757-
with tempfile.TemporaryDirectory() as tempdir:
758-
convert_to_onnx(
759-
model=net,
760-
filename=os.path.join(tempdir, "model.onnx"),
761-
verify=True,
762-
inputs=inputs,
763-
device=device,
764-
use_ort=has_onnxruntime,
765-
rtol=rtol,
766-
atol=atol,
767-
)
768-
except (RuntimeError, AttributeError):
769-
if sys.version_info.major == 3 and sys.version_info.minor == 11:
770-
warnings.warn("skipping py 3.11")
771-
return
772-
raise
750+
with tempfile.TemporaryDirectory() as tempdir:
751+
convert_to_onnx(
752+
model=net,
753+
filename=os.path.join(tempdir, "model.onnx"),
754+
verify=True,
755+
inputs=inputs,
756+
device=device,
757+
use_ort=has_onnxruntime,
758+
rtol=rtol,
759+
atol=atol,
760+
)
773761

774762

775763
def download_url_or_skip_test(*args, **kwargs):

0 commit comments

Comments
 (0)