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

Function main

testing/python/kernel/test_tilelang_kernel_gemm.py:27–47  ·  view source on GitHub ↗
(
        A: T.Tensor(A_shape, in_dtype),
        B: T.Tensor(B_shape, in_dtype),
        C: T.Tensor((M, N), out_dtype),
    )

Source from the content-addressed store, hash-verified

25
26 @T.prim_func
27 def main(
28 A: T.Tensor(A_shape, in_dtype),
29 B: T.Tensor(B_shape, in_dtype),
30 C: T.Tensor((M, N), out_dtype),
31 ):
32 with T.Kernel(T.ceildiv(N, block_N), T.ceildiv(M, block_M), threads=threads) as (bx, by):
33 A_shared = T.alloc_shared(A_shared_shape, in_dtype)
34 B_shared = T.alloc_shared(B_shared_shape, in_dtype)
35 C_local = T.alloc_fragment((block_M, block_N), accum_dtype)
36 T.clear(C_local)
37 for k in T.Pipelined(T.ceildiv(K, block_K), num_stages=num_stages):
38 if trans_A:
39 T.copy(A[k * block_K, by * block_M], A_shared)
40 else:
41 T.copy(A[by * block_M, k * block_K], A_shared)
42 if trans_B:
43 T.copy(B[bx * block_N, k * block_K], B_shared)
44 else:
45 T.copy(B[k * block_K, bx * block_N], B_shared)
46 T.gemm(A_shared, B_shared, C_local, trans_A, trans_B)
47 T.copy(C_local, C[by * block_M, bx * block_N])
48
49 return main
50

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…