Function
add_kernel
(
x_ptr,
y_ptr,
output_ptr,
n_elements,
BLOCK_SIZE: tl.constexpr,
)
Source from the content-addressed store, hash-verified
| 5 | |
| 6 | @triton.jit |
| 7 | def add_kernel( |
| 8 | x_ptr, |
| 9 | y_ptr, |
| 10 | output_ptr, |
| 11 | n_elements, |
| 12 | BLOCK_SIZE: tl.constexpr, |
| 13 | ): |
| 14 | pid = tl.program_id(axis=0) |
| 15 | block_start = pid * BLOCK_SIZE |
| 16 | offsets = block_start + tl.arange(0, BLOCK_SIZE) |
| 17 | mask = offsets < n_elements |
| 18 | x = tl.load(x_ptr + offsets, mask=mask) |
| 19 | y = tl.load(y_ptr + offsets, mask=mask) |
| 20 | output = x + y |
| 21 | tl.store(output_ptr + offsets, output, mask=mask) |
| 22 | |
| 23 | |
| 24 | x = torch.rand(1024) |
Callers
nothing calls this directly
Tested by
no test coverage detected