triton.language.trans¶
- triton.language.trans(input: 张量, *dims)¶
对张量的维度进行排列。
如果未指定参数
dims
,该函数默认使用(1,0)置换,实际上就是对2D张量进行转置。- Parameters:
input – 输入张量。
dims – 维度的期望排序顺序。例如,
(2, 1, 0)
会反转3D张量中的维度顺序。
dims
可以作为元组或单独参数传递:# These are equivalent trans(x, (2, 1, 0)) trans(x, 2, 1, 0)
permute()
等同于这个函数,只是它没有处理未指定排列时的特殊情况。此函数也可以作为成员函数在
tensor
上调用, 形式为x.trans(...)
而非trans(x, ...)
。