Skip to content

Commit

Permalink
Use --opset-version provided by iree-import-onnx. (#776)
Browse files Browse the repository at this point in the history
This option was added in
iree-org/iree@d497571.
  • Loading branch information
ScottTodd authored and eagarvey-amd committed Jan 8, 2025
1 parent 81daf3c commit f26f4d7
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions shortfin/tests/invocation/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,21 @@
import urllib.request


def upgrade_onnx(original_path, converted_path):
import onnx

original_model = onnx.load_model(original_path)
converted_model = onnx.version_converter.convert_version(original_model, 17)
onnx.save(converted_model, converted_path)


@pytest.fixture(scope="session")
def mobilenet_onnx_path(tmp_path_factory):
try:
import onnx
except ModuleNotFoundError:
raise pytest.skip("onnx python package not available")
parent_dir = tmp_path_factory.mktemp("mobilenet_onnx")
orig_onnx_path = parent_dir / "mobilenet_orig.onnx"
upgraded_onnx_path = parent_dir / "mobilenet.onnx"
if not upgraded_onnx_path.exists():
onnx_path = parent_dir / "mobilenet.onnx"
if not onnx_path.exists():
print("Downloading mobilenet.onnx")
urllib.request.urlretrieve(
"https://github.com/onnx/models/raw/main/validated/vision/classification/mobilenet/model/mobilenetv2-12.onnx",
orig_onnx_path,
onnx_path,
)
upgrade_onnx(orig_onnx_path, upgraded_onnx_path)
return upgraded_onnx_path
return onnx_path


@pytest.fixture(scope="session")
Expand All @@ -47,7 +37,7 @@ def mobilenet_compiled_path(mobilenet_onnx_path, compile_flags):
if not vmfb_path.exists():
print("Compiling mobilenet")
args = import_onnx.parse_arguments(
["-o", str(mlir_path), str(mobilenet_onnx_path)]
["-o", str(mlir_path), str(mobilenet_onnx_path), "--opset-version", "17"]
)
import_onnx.main(args)
tools.compile_file(
Expand Down

0 comments on commit f26f4d7

Please sign in to comment.