Overview
Attributes are written above a kernel, one or more per line, each starting
with @. They set the kernel’s launch shape, declare its tuning space, make
promises about the data, and opt into hardware paths:
@autotune(TILE_M in [32, 256], TILE_N in [32, 256], TILE_K in [4, 32])@launch(256)@pipeline@aligned(M = TILE_M, N = TILE_N, K = TILE_K)kernel gemm(A: tensor<f32>[M, K], B: tensor<f32>[K, N], C: tensor<f32>[M, N], alpha: f32, beta: f32) {An attribute’s arguments take three forms: a search dimension
(TILE_M in [64, 128]), a keyword argument (M = TILE_M), or a positional
value or flag (256, wmma). Which forms an attribute accepts is on its
page.
The normative table is in the spec under Attributes.
The attributes
Section titled “The attributes”| Attribute | Effect |
|---|---|
@autotune |
Declares tile constants and the values a tuner searches. |
@launch |
Sets the CTA size, and optionally an occupancy hint and a register cap. |
@aligned |
Promises a dimension is a whole number of tiles, which removes its masks. |
@pipeline |
Asserts that the kernel’s loops are double-buffered, and enables it for the GEMM. |
@padstage |
Pads staging tiles whose rows would collide on shared-memory banks. |
@dynshared |
Uses dynamic shared memory, sized at launch, instead of the static 48 KB. |
@registers |
Keeps named tiles in registers instead of shared memory. |
@tensorcore |
Runs dot and dot_t on tensor cores. |
@persistent |
Declares that the grid must be co-resident, as grid_barrier needs. |
@cluster |
Experimental. Super-tile dimensions for cluster tuning. |
Unknown attributes are errors
Section titled “Unknown attributes are errors”An attribute the compiler does not read is a compile-time error, not a
silent no-op. A misspelled @pipline would otherwise compile into a kernel
that quietly skips the promise it was meant to check.
@unroll@autotune(BLOCK in [1024])kernel copy(x: tensor<f32>[N], y: tensor<f32>[N]) { let base = ctx.block.x * BLOCK y[base :+ BLOCK] = x[base :+ BLOCK]}The message names the kernel, the attribute it did not recognize, and every
attribute it does read. Unrolling is not an attribute: a loop asks for it
itself, as for<unroll n>.
Planned attributes
Section titled “Planned attributes”The spec lists three attributes as planned: @readonly, @fast_math and
@assert_coalesced. None of them is implemented yet, and each is a
compile-time error until it is, the same error as for @unroll above.