Dtypes
The dtypes are bool, u8, i8, i16, i32, i64, f16, bf16, f32 and f64. Numbers in the source, true and false, and sizes used as values are host scalars: Python int, float and bool. The module default float dtype is f32; there is no syntax to change it yet.
Promotion follows torch’s result_type: bool < integer < float; tensors with axes outrank zero-dimensional tensors, which outrank Python numbers, unless a lower tier is of a higher kind; a Python float counts as the default float. So [b D] bf16 * 0.5 stays bf16, [b D] u8 * 2 stays u8, and bf16 + f16 is f32. / and float functions of integers give the default float, and sum and prod of booleans and integers give i64.
@, matmul and einsum need one dtype, since torch doesn’t promote them (E0502). Calls and returns compare dtypes exactly (E0502), except that a Python number fits any dtype of its kind or a higher one, a shapeless parameter takes any dtype unless it names one, and the tensor parameters of an extern fn take the call’s float dtype (Extern declarations).