mirror of
https://github.com/intel/llvm.git
synced 2026-01-13 19:08:21 +08:00
[MLIR][Python] fix getOwner to return (typed) nb::object instead of abstract PyOpView (#165053)
https://github.com/llvm/llvm-project/pull/157930 changed `nb::object getOwner()` to `PyOpView getOwner()` which implicitly constructs the generic OpView against from a (possibly) concrete OpView. This PR fixes that.
This commit is contained in:
@@ -598,7 +598,7 @@ class PyOpOperand {
|
||||
public:
|
||||
PyOpOperand(MlirOpOperand opOperand) : opOperand(opOperand) {}
|
||||
|
||||
PyOpView getOwner() {
|
||||
nb::typed<nb::object, PyOpView> getOwner() {
|
||||
MlirOperation owner = mlirOpOperandGetOwner(opOperand);
|
||||
PyMlirContextRef context =
|
||||
PyMlirContext::forContext(mlirOperationGetContext(owner));
|
||||
|
||||
@@ -1187,3 +1187,15 @@ def testOpWalk():
|
||||
module.operation.walk(callback)
|
||||
except RuntimeError:
|
||||
print("Exception raised")
|
||||
|
||||
|
||||
# CHECK-LABEL: TEST: testGetOwnerConcreteOpview
|
||||
@run
|
||||
def testGetOwnerConcreteOpview():
|
||||
with Context() as ctx, Location.unknown():
|
||||
module = Module.create()
|
||||
with InsertionPoint(module.body):
|
||||
a = arith.ConstantOp(value=42, result=IntegerType.get_signless(32))
|
||||
r = arith.AddIOp(a, a, overflowFlags=arith.IntegerOverflowFlags.nsw)
|
||||
for u in a.result.uses:
|
||||
assert isinstance(u.owner, arith.AddIOp)
|
||||
|
||||
Reference in New Issue
Block a user