warp.tile_transpose#
- warp.tile_transpose( ) Tile[Any, tuple[int, int]]#
Transpose a 2D tile.
The result aliases
awith reversed shape, so writing through it modifiesa. The current implementation placesain shared memory before transposing. The result is non-owning and allocates no additional storage.- Parameters:
a – 2D tile to transpose with
shape=(M,N)- Returns:
A non-owning tile with
shape=(N,M)that aliasesa.
Example
@wp.kernel def transpose_matrix(a: wp.array2d[float], out: wp.array2d[float]): t = wp.tile_load(a, shape=(2, 3)) wp.tile_store(out, wp.tile_transpose(t)) a = wp.array(np.arange(1, 7, dtype=np.float32).reshape(2, 3), dtype=float) out = wp.zeros((3, 2), dtype=float) wp.launch_tiled(transpose_matrix, dim=1, inputs=[a], outputs=[out], block_dim=4) print(out.numpy())
[[1. 4.] [2. 5.] [3. 6.]]