torch.cuda.comm.gather¶
- torch.cuda.comm.gather(tensors, dim=0, destination=None, *, out=None)[source][source]¶
從多個 GPU 裝置收集張量。
- 引數
tensors (Iterable[Tensor]) – 要收集的張量可迭代物件。除了
dim之外的所有維度的張量大小必須匹配。dim (int, optional) – 張量將沿其連線的維度。預設值:
0。destination (torch.device, str, or int, optional) – 輸出裝置。可以是 CPU 或 CUDA。預設值:當前的 CUDA 裝置。
out (Tensor, optional, keyword-only) – 用於儲存收集結果的張量。除了
dim外,其大小必須與tensors的大小匹配,在dim維度上,大小必須等於sum(tensor.size(dim) for tensor in tensors)。可以在 CPU 或 CUDA 上。
注意
指定
out時,不得指定destination。- 返回值
- 如果指定了
destination, 一個位於
destination裝置上的張量,它是將tensors沿dim連線的結果。
- 如果指定了
- 如果指定了
out, out張量,現在包含將tensors沿dim連線的結果。
- 如果指定了