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 为空时,它会尝试执行 (1,0) 置换。

此函数也可以作为 tensor 的成员函数调用,例如 x.permute(...) 而非 permute(x, ...)