[Mlir-commits] [mlir] [mlir][polynomial] python bindings (PR #93109)

Jeremy Kun llvmlistbot at llvm.org
Wed May 22 18:50:47 PDT 2024


================
@@ -0,0 +1,24 @@
+# RUN: %PYTHON %s | FileCheck %s
+
+from mlir.ir import *
+from mlir.dialects import polynomial
+
+
+def constructAndPrintInModule(f):
+    print("\nTEST:", f.__name__)
+    with Context(), Location.unknown():
+        module = Module.create()
+        with InsertionPoint(module.body):
+            f()
+        print(module)
+    return f
+
+
+# CHECK-LABEL: TEST: test_smoke
+ at constructAndPrintInModule
+def test_smoke():
+    value = Attribute.parse("#polynomial.float_polynomial<0.5 + 1.3e06 x**2>")
+    output = Type.parse("!polynomial.polynomial<ring=<coefficientType=f32>>")
+    res = polynomial.constant(output, value)
+    # CHECK: polynomial.constant {value = #polynomial.float_polynomial<0.5 + 1.3E+6x**2>} : <ring = <coefficientType = f32>>
----------------
j2kun wrote:

It may also require you to replace the attribute with a typed variant...

```mlir
#polynomial.typed_float_polynomial<0.5 + 1.3e06 x**2> : !polynomial.polynomial<ring=<coefficientType=f32>>
```

All as one typed attribute instead of a separate value/type. I think this is a change to the constant builder

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


More information about the Mlir-commits mailing list