[Mlir-commits] [mlir] [mlir][spirv] Add support for C-API/python binding to SPIR-V dialect (PR #76055)

Jacques Pienaar llvmlistbot at llvm.org
Wed Dec 20 06:18:25 PST 2023


================
@@ -0,0 +1,22 @@
+# RUN: %PYTHON %s | FileCheck %s
+
+from mlir.ir import *
+import mlir.dialects.spirv as spirv
+
+
+def run(f):
+    print("\nTEST:", f.__name__)
+    f()
+
+
+# CHECK-LABEL: TEST: testConstantOp
+ at run
+def testConstantOps():
+    with Context() as ctx, Location.unknown():
+        module = Module.create()
+        with InsertionPoint(module.body):
+            spirv.ConstantOp(
+                value=FloatAttr.get(F32Type.get(), 42.42), constant=F32Type.get()
+            )
+        # CHECK:         %cst_f32 = spirv.Constant 4.242000e+01 : f32
----------------
jpienaar wrote:

Perhaps just choose 4 as constant to avoid any printer behavior affecting test. Main thing is actually the test running rather than value.

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


More information about the Mlir-commits mailing list