[Mlir-commits] [mlir] [mlir][python] Add Pythonic wrappers for gpu ops (PR #163883)
Asher Mancinelli
llvmlistbot at llvm.org
Mon Oct 20 23:24:08 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(
----------------
ashermancinelli wrote:
Good to know 😃
https://github.com/llvm/llvm-project/pull/163883
More information about the Mlir-commits
mailing list