triton.language.permute

triton.language.permute(input, *dims, _semantic=None)

置换张量的维度。

参数:
  • input (Block) – 输入张量。

  • dims – 所需的维度排列顺序。例如,(2, 1, 0) 会反转 3D 张量的维度顺序。

dims 可以以元组形式传入,也可以作为单独的参数传入

# These are equivalent
permute(x, (2, 1, 0))
permute(x, 2, 1, 0)

trans() 与此函数等效,区别在于当 dims 为空时,它会尝试交换最后两个轴。

此函数也可以作为 tensor 的成员函数调用,即使用 x.permute(...) 而不是 permute(x, ...)