[Mlir-commits] [mlir] [MLIR][Transform][Python] expose transform.debug extension in Python (PR #145550)
Rolf Morel
llvmlistbot at llvm.org
Wed Jun 25 04:00:16 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:
Have now removed the `Debug...` prefix on the ops themselves. This is inline with pretty much all other Transform-dialect ops, per https://mlir.llvm.org/docs/Dialects/Transform including in extensions.
Due to that observation, should we maybe be placing extensions ops in their own sub-namespace in C++. This would reflect the apparent namespacing we see in ops' names in IR. As it stands we will have name clashes in C++ for ops which appear to have distinct names in IR. Maybe @ftynse wants to chime in on this. This is not something we need to resolve for this PR though.
(Also, I like the full namespacing being apparent in your repo. It would be nice if there was a less "cursed" way to achieve the same.)
https://github.com/llvm/llvm-project/pull/145550
More information about the Mlir-commits
mailing list