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, ...)
。