triton.language.broadcast_to

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

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