How do you pick specific items from a list without going through them one by one?
Image: U.S. Department of the Interior National Park Service Natural Resource Stewardship and Science Fort Collins, Colorado, Public domain, via Wikimedia Commons
How do you pick specific items from a list without going through them one by one?
Imagine you have a box of chocolates, and you only want to eat the ones at the end of the box. You don't want to taste every single one until you reach the end.
Think of it like grabbing a slice of pizza. You don't eat the whole pizza; you just take a slice. In programming, tl.arange(0, BLOCK_SIZE) helps you grab a slice of indices, like picking specific chocolates or a slice of pizza.
Example
If your box has 20 chocolates (BLOCK_SIZE = 20) and you want to eat the last 5, you would use tl.arange(15, 20) to pick those chocolates without looking at the first 15.
Remember this
tl.arange(0, BLOCK_SIZE) lets you access a specific set of items quickly, like choosing a slice of pizza from the whole without eating everything.
Text adapted from Wikipedia, licensed under CC BY-SA 4.0.
tl.program_id(0) returns: the index of the current parallel block
tl.program_id(0) returns: the index of the current parallel block
tl.where(mask, x, 0) does: conditional select to handle boundary conditions
`tl.where(mask, x, 0) = x if mask else 0`
tl.dot does in Triton: block-level matrix multiply using tensor cores
tl.dot performs block-level matrix multiplication using tensor cores in Triton
BLOCK_SIZE means in Triton: the tile size each program instance processes
Why does your computer sometimes feel slow when you're playing games?
tl.load and tl.store do in Triton: read/write tensors from/to GPU global memory
`tl.load` reads tensors from GPU memory; `tl.store` writes tensors to GPU memory
to write a vector addition kernel in Triton: load blocks, add, store
```
Swipe through 100 ML concepts daily
Open Pocket Polymath