cuda.tile.wrapping_mul#
- cuda.tile.wrapping_mul(x, y, /)#
Elementwise integer multiplication that wraps around on overflow.
The shape of x and y will be broadcasted. Unlike
mul(), the dtypes are not promoted: x and y must have the same integer dtype, and the result is computed modulo 2**bitwidth of that dtype. A loosely typed constant is converted to the dtype of the other operand, also modulo 2**bitwidth: for example, -1 becomes 255 for uint8.At least one of the operands must have a concrete dtype, since loosely typed constants don’t have a bit width. For example,
ct.wrapping_mul(1, 2)is an error, butct.wrapping_mul(ct.uint8(16), 17)isct.uint8(16).- Return type:
Examples
tx = ct.arange(4, dtype=ct.int8) print(ct.wrapping_mul(tx, 64))
import cuda.tile as ct import torch @ct.kernel def kernel(): tx = ct.arange(4, dtype=ct.int8) print(ct.wrapping_mul(tx, 64)) torch.cuda.init() ct.launch(torch.cuda.current_stream(), (1,), kernel, ()) torch.cuda.synchronize()
Output
[0, 64, -128, -64]