triton.language.cast
- triton.language.cast(input, dtype: dtype, fp_downcast_rounding: str | None = None, bitcast: bool = False, _semantic=None)
将张量转换为给定的
dtype。- 参数:
dtype (tl.dtype) – 目标数据类型。
fp_downcast_rounding (str, optional) – 浮点值向下转型时的舍入模式。此参数仅在 self 为浮点张量且 dtype 为位宽更小的浮点类型时使用。支持的值为
"rtne"(舍入到最近,平局向偶数舍入)和"rtz"(向零舍入)。bitcast (bool, optional) – 若为 true,则张量将按位转换(bitcast)为指定的
dtype,而非进行数值转换。
此函数也可以作为
tensor的成员函数调用,即使用x.cast(...)代替cast(x, ...)。