warp.tile_squeeze#
- warp.tile_squeeze( ) Tile[Any, tuple[int, ...]]#
Return a view of a tile with dimensions of length one removed.
The view aliases the source tile, so writing through it modifies
t. Taking the view requires shared storage, but the view itself is non-owning and allocates no additional storage.- Parameters:
t – Input tile to squeeze
axis – Axis or axes to remove, as a compile-time constant. If omitted, all dimensions of
twith extent one are removed. Each specified axis must refer to a dimension oftwith extent one. Negative axes count from the end.
- Returns:
A non-owning tile that aliases
twith all, or the selected, dimensions of length one removed.
Example
@wp.kernel def remove_singleton_dims(a: wp.array3d[float], out: wp.array[float]): t = wp.tile_load(a, shape=(1, 4, 1)) s = wp.tile_squeeze(t) wp.tile_store(out, s) a = wp.array(np.arange(1, 5, dtype=np.float32).reshape(1, 4, 1), dtype=float) out = wp.zeros(4, dtype=float) wp.launch_tiled(remove_singleton_dims, dim=1, inputs=[a], outputs=[out], block_dim=2) print(out.numpy())
[1. 2. 3. 4.]