[Mlir-commits] [mlir] [mlir][python] Add tests for gpu.launch(_func) ops (PR #163883)
Maksim Levental
llvmlistbot at llvm.org
Thu Oct 16 17:19:48 PDT 2025
================
@@ -157,3 +158,99 @@ def builder(func: gpu.GPUFuncOp) -> None:
# CHECK: %[[VAL_0:.*]] = gpu.global_id x
# CHECK: gpu.return
# CHECK: }
+
+# CHECK-LABEL: testGPULaunchFuncOp
+ at run
+def testGPULaunchFuncOp():
+ module = Module.create()
+
+ module.operation.attributes["gpu.container_module"] = UnitAttr.get()
+ with InsertionPoint(module.body):
+ gpu_module = gpu.GPUModuleOp("gpu_module")
+ block = gpu_module.bodyRegion.blocks.append()
+
+ with InsertionPoint(block):
+ gpu_func = gpu.GPUFuncOp(
+ FunctionType.get([], []),
+ "kernel",
+ body_builder=lambda func: gpu.return_([]),
+ kernel=True,
+ )
+
+ with InsertionPoint(module.body):
+ host = func.FuncOp(type=FunctionType.get([], []), name="host")
+
+ with InsertionPoint(host.add_entry_block()):
+ c1 = arith.constant(T.index(), 1)
+ grid_sizes = [c1] * 3
+ block_sizes = [c1] * 3
+ sym_ref = SymbolRefAttr.get([gpu_module.sym_name.value, gpu_func.name.value])
+ token_type = Type.parse("!gpu.async.token")
+ token = gpu.wait(async_token=token_type, async_dependencies=[])
+ token = gpu.launch_func(
----------------
makslevental wrote:
The python APIs aren't stable (ie we make no stability guarantees). So basically this same "breakage" occurs whenever we add one of these nicer builders. Also there's a simple "migration path": people can just import the generated original APIs directly from `_gpu_ops_gen`.
https://github.com/llvm/llvm-project/pull/163883
More information about the Mlir-commits
mailing list