Open
Description
In the Python-based ONNX importer, if --temp-dir
is specified and --data-dir
is not, and the model large enough to fail in-memory shape inference, the import fails with this error:
Traceback (most recent call last):
<internal traces elided>
File "<elided>/import_onnx/__main__.py", line 38, in main
model_proto = load_onnx_model(args)
^^^^^^^^^^^^^^^^^^^^^
File "<elided>/import_onnx/__main__.py", line 139, in load_onnx_model
data_dir = Path(input_dir if args.temp_dir is None else args.data_dir)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<elided>/python3.11/pathlib.py", line 871, in __new__
self = cls._from_parts(args)
^^^^^^^^^^^^^^^^^^^^^
File "<elided>/python3.11/pathlib.py", line 509, in _from_parts
drv, root, parts = self._parse_args(args)
^^^^^^^^^^^^^^^^^^^^^^
File "<elided>/python3.11/pathlib.py", line 493, in _parse_args
a = os.fspath(a)
^^^^^^^^^^^^
TypeError: expected str, bytes or os.PathLike object, not NoneType
I think the issue is this line that tries to set up data_dir
based on whether --data-dir
is set, but it mistakenly checks args.temp_dir
instead:
I changed that line with this patch and it seems to be working for me now:
diff --git c/python/torch_mlir/tools/import_onnx/__main__.py i/python/torch_mlir/tools/import_onnx/__main__.py
index 4f852d34..ff4f651e 100644
--- c/python/torch_mlir/tools/import_onnx/__main__.py
+++ i/python/torch_mlir/tools/import_onnx/__main__.py
@@ -136,7 +136,7 @@ def load_onnx_model(args: argparse.Namespace) -> onnx.ModelProto:
# Load the temp file and the external data.
inferred_model = onnx.load(temp_inferred_file, load_external_data=False)
- data_dir = Path(input_dir if args.temp_dir is None else args.data_dir)
+ data_dir = Path(input_dir if args.data_dir is None else args.data_dir)
onnx.load_external_data_for_model(inferred_model, str(data_dir))
# Remove the inferred shape file unless asked to keep it
Metadata
Metadata
Assignees
Labels
No labels