warp.tile_arange#
- warp.tile_arange( ) Tile[float32, tuple[int]]#
Generate a 1D tile of linearly spaced elements.
The range follows the half-open interval
[start, stop)and holdsceil((stop - start) / step)elements. For example,tile_arange(0, 10, 3)yields[0, 3, 6, 9].The interval excludes
stop, except whenstepis non-integral and floating-point round-off affects the number of elements.The range is interpreted at the output element type: each argument must be representable there, so an integer
dtyperejects a fractional bound, and a floating-point range is counted from its rounded values rather than from the wider ones it was written as.A zero
stepraises an error, as does a range spanning no elements, such astile_arange(5, 5)ortile_arange(0, 10, -1), because zero-length tile dimensions are not supported.- Parameters:
args –
Positional compile-time constants specifying the range:
(stop,): Use0forstartand1forstep.(start, stop): Use1forstep.(start, stop, step): Use the suppliedstart,stop, andstep.
dtype – Data type of output tile’s elements. Defaults to
floateven when the range arguments are integers; passdtype=intfor an integer tile. Must be a compile-time constant and a numeric scalar type.storage – The storage location for the tile:
"register"for registers or"shared"for shared memory. Must be a compile-time constant.
- Returns:
A tile with
shape=(n,)holding the linearly spaced elements.
Example
@wp.kernel def store_ranges(out: wp.array[int]): a = wp.tile_arange(4, dtype=int) b = wp.tile_arange(9, 0, -3, dtype=int) wp.tile_store(out, a) wp.tile_store(out, b, offset=(4,)) out = wp.zeros(7, dtype=int) wp.launch_tiled(store_ranges, dim=1, outputs=[out], block_dim=4) print(out.numpy())
[0 1 2 3 9 6 3]