triton.language.broadcast_to

triton.language.broadcast_to(input, *shape)

尝试将给定的张量广播到新的shape

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

  • shape - 期望的形状。

shape 可以作为元组或单独参数传递:

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

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