warp.tile#
- warp.tile(x: Any, preserve_type: bool) Tile[Any, tuple]#
Kernel
Differentiable
Construct a new tile from per-thread kernel values.
This function converts values computed using scalar kernel code to a tile representation for input into collective operations.
If the input value is a scalar, then the resulting tile has
shape=(block_dim,)If the input value is a vector, then the resulting tile has
shape=(length(vector), block_dim)If the input value is a vector, and
preserve_type=True, then the resulting tile hasdtype=vectorandshape=(block_dim,)If the input value is a matrix, then the resulting tile has
shape=(rows, cols, block_dim)If the input value is a matrix, and
preserve_type=True, then the resulting tile hasdtype=matrixandshape=(block_dim,)
- param x:
A per-thread local value, e.g. scalar, vector, or matrix.
- param preserve_type:
If true, the tile will have the same data type as the input value.
- returns:
If
preserve_type=True, a tile of typex.typeof lengthblock_dim. Otherwise, an N-dimensional tile such that the first N-1 dimensions match the shape ofxand the final dimension is of sizeblock_dim.
This example shows how to create a linear sequence from thread variables:
@wp.kernel def compute(): i = wp.tid() t = wp.tile(i*2) print(t) wp.launch(compute, dim=16, inputs=[], block_dim=16)
Prints:
[0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30] = tile(shape=(16), storage=register)