From 31e57bc0ec92da9cc8be76ebe1170343ff15ba92 Mon Sep 17 00:00:00 2001 From: Ziliang Zhang Date: Mon, 29 Sep 2025 14:03:18 +0800 Subject: [PATCH] Add `enable-debug-info` command-line option for onnx_importer --- python/torch_mlir/tools/import_onnx/__main__.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/python/torch_mlir/tools/import_onnx/__main__.py b/python/torch_mlir/tools/import_onnx/__main__.py index 5ec5c63f820e..d3f562790150 100644 --- a/python/torch_mlir/tools/import_onnx/__main__.py +++ b/python/torch_mlir/tools/import_onnx/__main__.py @@ -50,9 +50,9 @@ def main(args: argparse.Namespace): # some copies. if args.output_file and args.output_file != "-": with open(args.output_file, "wt") as f: - print(m.get_asm(assume_verified=not args.no_verify), file=f) + print(m.get_asm(assume_verified=not args.no_verify, enable_debug_info=args.enable_debug_info), file=f) else: - print(m.get_asm(assume_verified=not args.no_verify)) + print(m.get_asm(assume_verified=not args.no_verify, enable_debug_info=args.enable_debug_info)) def load_onnx_model(args: argparse.Namespace) -> onnx.ModelProto: @@ -215,6 +215,13 @@ def parse_arguments(argv=None) -> argparse.Namespace: help="Disable the allowlist for ONNX function expansion," " allowing non-allowlisted functions to be expanded.", ) + parser.add_argument( + "--enable-debug-info", + action="store_true", + default=False, + help="Whether to print debug/location information." + " Defaults to False.", + ) args = parser.parse_args(argv) return args