triton.language.broadcast_to

triton.language.broadcast_to(input, *shape)

尝试将给定张量广播到新的 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, ...)