torch.cuda.comm.broadcast_coalesced
- torch.cuda.comm.broadcast_coalesced(tensors, devices, buffer_size=10485760)[source][source]
将一系列张量广播到指定的 GPU 上。
小张量首先合并到缓冲区中,以减少同步次数。
- 参数:
张量(序列)- 要广播的张量。必须在同一设备上,无论是 CPU 还是 GPU。
设备(Iterable[torch.device, str 或 int])- 在其中广播的 GPU 设备集合。
buffer_size(int)- 用于合并的缓冲区最大大小。
- 返回值:
包含
tensor
副本的元组,放置于devices
。