This document is relevant for: Trn2, Trn3
nki.language.ds#
- nki.language.ds(start: Union[int, NkiTensor, VirtualRegister, NkiScalar], size: int)[source]#
A
size-element window starting atstart.Used inside an index expression:
t[nl.ds(start, size), :]is equivalent tot[start:start + size, :]for a compile-timestart.sizemust be a compile-time integer (the access pattern needs a static element count);startmay be anintor a runtime index (seeNkiTensor.select()). A runtimestartis only spelled this way, because a slice needs both bounds while the kernel is built.t = nl.ndarray((128, 64), dtype=nl.float32, buffer=nl.sbuf) t[:, nl.ds(8, 16)] # static: columns 8..23 idx = nl.ndarray((1, 1), dtype=nl.uint32, buffer=nl.sbuf) t[:, nl.ds(idx, 16)] # runtime: 16 columns starting at idx
With a runtime
startthe window slides at execution time and the resulting view is indirect (seeNkiTensor.is_indirect()).- Parameters:
start – window start — compile-time
intor a runtimeNkiTensor/VirtualRegister/NkiScalarsize – window length, must be a compile-time integer
- Returns:
a
DynamicSliceto use inside an index expression
This document is relevant for: Trn2, Trn3