cuda.tile.astype#
- cuda.tile.astype(x, dtype, /, *, rounding_mode=None)#
Converts a tile to the specified data type.
- Parameters:
x (Tile) – input tile.
dtype (DType) – target data type.
rounding_mode (RoundingMode) – optional rounding mode for explicit float to float conversions. Default is round to nearest with ties to even.
- Return type:
Examples
tx = ct.arange(4, dtype=ct.int32) ty = ct.astype(tx, ct.float32) print(f"{ty:.1f}")
import cuda.tile as ct import torch @ct.kernel def kernel(): tx = ct.arange(4, dtype=ct.int32) ty = ct.astype(tx, ct.float32) print(f"{ty:.1f}") torch.cuda.init() ct.launch(torch.cuda.current_stream(), (1,), kernel, ()) torch.cuda.synchronize()
Output
[0.0, 1.0, 2.0, 3.0]