triton.language.trans

triton.language.trans(input: tensor, *dims, _semantic=None)

置换张量的维度。

如果未指定参数 dims,则函数默认为 (1,0) 置换,有效地转置二维张量。

参数:
  • 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, ...)