MCPcopy Create free account
hub / github.com/tile-ai/tilelang / matmul

Function matmul

testing/python/webgpu/test_webgpu_codegen.py:7–31  ·  view source on GitHub ↗
(M, N, K, block_M, block_N, block_K, dtype=T.float16, accum_dtype=T.float32)

Source from the content-addressed store, hash-verified

5
6
7def matmul(M, N, K, block_M, block_N, block_K, dtype=T.float16, accum_dtype=T.float32):
8 @T.prim_func
9 def main(
10 A: T.Tensor((M, K), dtype),
11 B: T.Tensor((K, N), dtype),
12 C: T.Tensor((M, N), dtype),
13 ):
14 # Initialize Kernel Context
15 with T.Kernel(T.ceildiv(N, block_N), T.ceildiv(M, block_M), threads=128) as (bx, by):
16 A_shared = T.alloc_shared((block_M, block_K), dtype)
17 B_shared = T.alloc_shared((block_K, block_N), dtype)
18 C_local = T.alloc_fragment((block_M, block_N), accum_dtype)
19
20 T.clear(C_local)
21
22 for ko in T.Pipelined(T.ceildiv(K, block_K), num_stages=0):
23 T.copy(A[by * block_M, ko * block_K], A_shared, coalesced_width=2)
24 T.copy(B[ko * block_K, bx * block_N], B_shared, coalesced_width=2)
25
26 for i, j, k in T.grid(block_M, block_N, block_K):
27 C_local[i, j] += A_shared[i, k] * B_shared[k, j]
28
29 T.copy(C_local, C[by * block_M, bx * block_N], coalesced_width=2)
30
31 return main
32
33
34def assert_gemm_codegen(

Callers 1

assert_gemm_codegenFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…