()
| 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") |
no outgoing calls
no test coverage detected
searching dependent graphs…