A block pointer is a structured descriptor for a rectangular region of a tensor. It records the base address, parent shape and strides, starting offsets, block shape, and dimension order. section 5.6.2
Creating one does not access memory. Loads and stores perform the actual reads and writes; boundary checks can handle tiles that cross tensor edges. section 5.6.2 section 5.4.3
Use tl.advance to update a descriptor’s logical position:
- Supply one element-offset value per tensor dimension; positive and negative values move the descriptor forward or backward. section 5.6.3
- Advancement updates coordinates but neither loads data nor checks bounds; a later load can check the updated coordinates. section 5.6.3
Tiled matrix multiplication
Descriptors select matching A and B tiles along the shared K dimension. Advancing A by (0, BLOCK_K) and B by (BLOCK_K, 0) selects the next pair of slices for tl.dot. section 5.6.3
a_block_ptr = tl.make_block_ptr(
base=a_ptr,
shape=(M, K),
strides=(stride_am, stride_ak),
offsets=(pid_m * BLOCK_M, 0),
block_shape=(BLOCK_M, BLOCK_K),
order=(1, 0),
)
b_block_ptr = tl.make_block_ptr(
base=b_ptr,
shape=(K, N),
strides=(stride_bk, stride_bn),
offsets=(0, pid_n * BLOCK_N),
block_shape=(BLOCK_K, BLOCK_N),
order=(1, 0),
)
See how base addresses, shapes, strides, offsets, block shapes, and dimension order define matrix tiles. section 5.6.2
