[Mlir-commits] [mlir] [MLIR][Transform][Python] expose transform.debug extension in Python (PR #145550)

Rolf Morel llvmlistbot at llvm.org
Tue Jun 24 10:03:03 PDT 2025


================
@@ -0,0 +1,86 @@
+#  Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+#  See https://llvm.org/LICENSE.txt for license information.
+#  SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+from typing import Optional
+
+from ...ir import Attribute, Operation, Value, StringAttr
+from .._transform_debug_extension_ops_gen import *
+from .._transform_pdl_extension_ops_gen import _Dialect
+
+try:
+    from .._ods_common import _cext as _ods_cext
+except ImportError as e:
+    raise RuntimeError("Error loading imports from extension module") from e
+
+from typing import Union
+
+
+ at _ods_cext.register_operation(_Dialect, replace=True)
+class DebugEmitParamAsRemarkOp(DebugEmitParamAsRemarkOp):
+    def __init__(
+        self,
+        param: Attribute,
+        *,
+        anchor: Optional[Operation] = None,
+        message: Optional[Union[StringAttr, str]] = None,
+        loc=None,
+        ip=None,
+    ):
+        if isinstance(message, str):
+            message = StringAttr.get(message)
+
+        super().__init__(
+            param,
+            anchor=anchor,
+            message=message,
+            loc=loc,
+            ip=ip,
+        )
+
+
+def emit_param_as_remark(
+    param: Attribute,
+    *,
+    anchor: Optional[Operation] = None,
+    message: Optional[Union[StringAttr, str]] = None,
+    loc=None,
+    ip=None,
+):
+    return DebugEmitParamAsRemarkOp(
+        param, anchor=anchor, message=message, loc=loc, ip=ip
+    )
+
+del debug_emit_param_as_remark
----------------
rolfmorel wrote:

This I am a bit unsure about. The ODS-generated definition gives us ops with names prefixed with `Debug...`/`debug_` which live in the (`mlir.dialects.`)`transform.tune` namespace. This file corrects the snake_case wrappers -- by getting rid of the `debug_`-prefixed ops and introducing corresponding non-prefixed versions -- but how about `DebugEmitParamAsRemarkOp` and `DebugEmitRemarkAtOp` living in the  (`mlir.dialects.`)`transform.tune` namespace?

My current take on it is that we should primarily care that the snake_case ops have the look and feel of pretty-printed MLIR. Hence why I am taking "the middle road" here.

https://github.com/llvm/llvm-project/pull/145550


More information about the Mlir-commits mailing list