triton.language.broadcast_to

triton.language.broadcast_to(input, *shape, _semantic=None)

尝试将给定的张量广播(broadcast)为新的 shape(形状)。

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

  • shape – 目标形状。

shape 可以作为元组传递,也可以作为单独的参数传递。

# These are equivalent
broadcast_to(x, (32, 32))
broadcast_to(x, 32, 32)

该函数也可以作为 tensor 的成员函数调用,即使用 x.broadcast_to(...) 而非 broadcast_to(x, ...)