Script.scan¶
- Script.scan(x, *, dim, op, exclusive=False, out=None)¶
Prefix scan along
dim.For each non-
dimcoordinate independently, the output at positionialongdimis the ⊕-combination of the input values at positions[0, i](inclusive mode, default) or[0, i)with the identity at position0(exclusive mode).- Parameters:
x (RegisterTensor) – Input tile.
dim (int) – Compile-time scan axis.
op (str) – One of
'add','mul','max','min','and','or','xor'. Bitwise ops ('and'/'or'/'xor') require an integer dtype.exclusive (bool) – If
True, return the exclusive prefix (identity at the boundary); otherwise the inclusive prefix.out (RegisterTensor, optional) – Output tile. Must match
xin shape and dtype. If not provided, a new tile is allocated with the same layout asx. Passingout=xperforms the scan in-place (the emitter saves the original values when needed).
- Returns:
ret – The scanned tile, same shape and dtype as
x.- Return type:
Notes
Thread group: Can be executed by any sized thread group whose size matches the input layout’s
spatial_size.