[Mlir-commits] [mlir] [mlir][python] Fix how the mlir variadic Python accessor `_ods_equally_sized_accessor` is used (#101132) (PR #106003)

Maksim Levental llvmlistbot at llvm.org
Thu Aug 29 16:17:15 PDT 2024


================
@@ -208,3 +209,70 @@ class TestOp(OpView):
 
 
 run(testOdsBuildDefaultCastError)
+
+
+def testOdsEquallySizedAccessor():
+    class TestOpMultiResultSegments(OpView):
+        OPERATION_NAME = "custom.test_op"
+        _ODS_REGIONS = (1, True)
----------------
makslevental wrote:

I goofed and misread what `mlir/test/mlir-tblgen/op-python-bindings.td` is - it is not the test that actually generates python bindings that can be used in tests. That's [mlir/test/python/python_test_ops.td](https://github.com/llvm/llvm-project/blob/9315645834ea81cf9550364a4950f289e9706a26/mlir/test/python/python_test_ops.td). 

> I do not think the traits are currently exposed through the Python API.

What I'm proposing is you just copy-paste 

```
def SameVariadicResultSizeOp : TestOp<"same_variadic_result",
                                      [SameVariadicResultSize]> {
  let results = (outs Variadic<AnyType>:$variadic1, AnyType:$non_variadic,
                 Variadic<AnyType>:$variadic2);
}
```

into `mlir/test/python/python_test_ops.td` and then create/query it in `python_test.py`.

https://github.com/llvm/llvm-project/pull/106003


More information about the Mlir-commits mailing list