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

Function reduce_kernel

testing/python/amd/test_tilelang_hip_codegen.py:100–114  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

98
99 @tilelang.jit
100 def reduce_kernel():
101 @T.prim_func
102 def kernel(
103 x: T.Tensor((N,), T.float32),
104 out: T.Tensor((1,), T.float32),
105 ) -> None:
106 with T.Kernel(1, threads=N) as _:
107 frag = T.alloc_fragment((N,), T.float32)
108 T.copy(x, frag)
109 s = T.alloc_fragment((1,), T.float32)
110 T.reduce_sum(frag, s, dim=0)
111 if T.get_thread_binding() == 0:
112 out[0] = s[0]
113
114 return kernel
115
116 x = torch.arange(1, N + 1, dtype=torch.float32, device="cuda")
117 out = torch.zeros(1, dtype=torch.float32, device="cuda")

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…