[Mlir-commits] [mlir] 6e4ea4e - add `owner` to OpResultsList. this is useful for when the list is empty and an element can't be used to fetch the owner.
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Fri Aug 11 19:20:49 PDT 2023
Author: max
Date: 2023-08-11T21:09:06-05:00
New Revision: 6e4ea4eeba50d99e822015e42aba22b2c5a880ca
URL: https://github.com/llvm/llvm-project/commit/6e4ea4eeba50d99e822015e42aba22b2c5a880ca
DIFF: https://github.com/llvm/llvm-project/commit/6e4ea4eeba50d99e822015e42aba22b2c5a880ca.diff
LOG: add `owner` to OpResultsList. this is useful for when the list is empty and an element can't be used to fetch the owner.
Differential Revision: https://reviews.llvm.org/D157769
Added:
Modified:
mlir/lib/Bindings/Python/IRCore.cpp
mlir/test/python/ir/operation.py
Removed:
################################################################################
diff --git a/mlir/lib/Bindings/Python/IRCore.cpp b/mlir/lib/Bindings/Python/IRCore.cpp
index d348175b576dc8..e1b8d296a7d1e5 100644
--- a/mlir/lib/Bindings/Python/IRCore.cpp
+++ b/mlir/lib/Bindings/Python/IRCore.cpp
@@ -2277,6 +2277,9 @@ class PyOpResultList : public Sliceable<PyOpResultList, PyOpResult> {
c.def_property_readonly("types", [](PyOpResultList &self) {
return getValueTypes(self, self.operation->getContext());
});
+ c.def_property_readonly("owner", [](PyOpResultList &self) {
+ return self.operation->createOpView();
+ });
}
private:
diff --git a/mlir/test/python/ir/operation.py b/mlir/test/python/ir/operation.py
index 9679b5846af190..129b7fa744e472 100644
--- a/mlir/test/python/ir/operation.py
+++ b/mlir/test/python/ir/operation.py
@@ -440,9 +440,11 @@ def testOperationResultList():
r"""
func.func @f1() {
%0:3 = call @f2() : () -> (i32, f64, index)
+ call @f3() : () -> ()
return
}
func.func private @f2() -> (i32, f64, index)
+ func.func private @f3() -> ()
""",
ctx,
)
@@ -465,6 +467,10 @@ def testOperationResultList():
expect_index_error(lambda: call.results[3])
expect_index_error(lambda: call.results[-4])
+ no_results_call = caller.regions[0].blocks[0].operations[1]
+ assert len(no_results_call.results) == 0
+ assert no_results_call.results.owner == no_results_call
+
# CHECK-LABEL: TEST: testOperationResultListSlice
@run
More information about the Mlir-commits
mailing list