diff --git a/python/torch_mlir/extras/onnx_importer.py b/python/torch_mlir/extras/onnx_importer.py index 9fe29212386a..ab9b6de3cd5b 100644 --- a/python/torch_mlir/extras/onnx_importer.py +++ b/python/torch_mlir/extras/onnx_importer.py @@ -739,6 +739,13 @@ def type_proto_to_type(self, tp: onnx.TypeProto) -> IrType: def _sanitize_name(self, name): if not name.isidentifier(): name = "_" + name + + # The presence of '-' characters in the initializer names can cause + # unintended side-effects when the IR is parsed during compilation. + # Simply replace all the occurrences of '-' in the name string when the + # dense resource is created. + name = name.replace("-", "_") + return re.sub("[:/]", "_", name) def tensor_proto_to_attr(self, tp: onnx.TensorProto) -> Attribute: