diff --git a/python/torch_mlir/extras/onnx_importer.py b/python/torch_mlir/extras/onnx_importer.py index ab9b6de3cd5b..9aa2ae8994e4 100644 --- a/python/torch_mlir/extras/onnx_importer.py +++ b/python/torch_mlir/extras/onnx_importer.py @@ -740,13 +740,9 @@ 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) + # Remove characters that are invalid in MLIR identifier names. + # https://mlir.llvm.org/docs/LangRef/#identifiers-and-keywords + return re.sub("[:/-]", "_", name) def tensor_proto_to_attr(self, tp: onnx.TensorProto) -> Attribute: tensor_type = self.tensor_proto_to_builtin_type(tp)