Skip to content
This repository was archived by the owner on Oct 11, 2025. It is now read-only.

Commit d1f22c8

Browse files
authored
[mlir][python] expose isAttached (#153045)
1 parent 1c23921 commit d1f22c8

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

mlir/lib/Bindings/Python/IRCore.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3442,6 +3442,14 @@ void mlir::python::populateIRCore(nb::module_ &m) {
34423442
return operation.createOpView();
34433443
},
34443444
"Detaches the operation from its parent block.")
3445+
.def_prop_ro(
3446+
"attached",
3447+
[](PyOperationBase &self) {
3448+
PyOperation &operation = self.getOperation();
3449+
operation.checkValid();
3450+
return operation.isAttached();
3451+
},
3452+
"Reports if the operation is attached to its parent block.")
34453453
.def("erase", [](PyOperationBase &self) { self.getOperation().erase(); })
34463454
.def("walk", &PyOperationBase::walk, nb::arg("callback"),
34473455
nb::arg("walk_order") = MlirWalkPostOrder);

mlir/python/mlir/_mlir_libs/_mlir/ir.pyi

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,13 @@ class _OperationBase:
194194
"""
195195
Detaches the operation from its parent block.
196196
"""
197+
198+
@property
199+
def attached(self) -> bool:
200+
"""
201+
Reports if the operation is attached to its parent block.
202+
"""
203+
197204
def erase(self) -> None: ...
198205

199206
@overload

0 commit comments

Comments
 (0)