diff --git a/mlir/lib/Bindings/Python/IRCore.cpp b/mlir/lib/Bindings/Python/IRCore.cpp --- a/mlir/lib/Bindings/Python/IRCore.cpp +++ b/mlir/lib/Bindings/Python/IRCore.cpp @@ -2105,10 +2105,6 @@ }, "Shortcut to get an op result if it has only one (throws an error " "otherwise).") - .def("__iter__", - [](PyOperationBase &self) { - return PyRegionIterator(self.getOperation().getRef()); - }) .def( "__str__", [](PyOperationBase &self) { diff --git a/mlir/python/mlir/dialects/_builtin_ops_ext.py b/mlir/python/mlir/dialects/_builtin_ops_ext.py --- a/mlir/python/mlir/dialects/_builtin_ops_ext.py +++ b/mlir/python/mlir/dialects/_builtin_ops_ext.py @@ -197,6 +197,8 @@ return_values = [] elif isinstance(return_values, Value): return_values = [return_values] + elif isinstance(return_values, OpView): + return_values = return_values.results else: return_values = list(return_values) std.ReturnOp(return_values) diff --git a/mlir/test/python/dialects/math.py b/mlir/test/python/dialects/math.py --- a/mlir/test/python/dialects/math.py +++ b/mlir/test/python/dialects/math.py @@ -19,7 +19,7 @@ return mlir_math.SqrtOp(F32Type.get(), arg) # CHECK-LABEL: func @emit_sqrt( - # CHECK-SAME: %[[ARG:.*]]: f32) { + # CHECK-SAME: %[[ARG:.*]]: f32) -> f32 { # CHECK: math.sqrt %[[ARG]] : f32 # CHECK: return # CHECK: } diff --git a/mlir/test/python/ir/operation.py b/mlir/test/python/ir/operation.py --- a/mlir/test/python/ir/operation.py +++ b/mlir/test/python/ir/operation.py @@ -36,7 +36,7 @@ print(f".verify = {module.operation.verify()}") # Get the regions and blocks from the default collections. - default_regions = list(op) + default_regions = list(op.regions) default_blocks = list(default_regions[0]) # They should compare equal regardless of how obtained. assert default_regions == regions @@ -49,7 +49,7 @@ assert default_operations == operations def walk_operations(indent, op): - for i, region in enumerate(op): + for i, region in enumerate(op.regions): print(f"{indent}REGION {i}:") for j, block in enumerate(region): print(f"{indent} BLOCK {j}:")