/usr/local/lib64/python3.6/site-packages/torch/nn/parallel/__pycache__
Edit: /usr/local/lib64/python3.6/site-packages/torch/nn/parallel/__pycache__/comm.cpython-36.pyc (10466B)
3
Eg$* @ s d dl Z d dlZd dlmZ d dlmZmZmZmZm Z m
Z
d dlmZ dddddZ
dd d
ZdddZdd
dZdddddZdddddZdS ) N)nccl)
_take_tensors_flatten_dense_tensors_unflatten_dense_tensors_reorder_tensors_as_get_device_index_handle_complex)List)outc C s^ t | } |dk|dkA s(tdj|||dk rLdd |D }tjj| |S tjj| |S dS )a Broadcasts a tensor to specified GPU devices.
Args:
tensor (Tensor): tensor to broadcast. Can be on CPU or GPU.
devices (Iterable[torch.device, str or int], optional): an iterable of
GPU devices, among which to broadcast.
out (Sequence[Tensor], optional, keyword-only): the GPU tensors to
store output results.
.. note::
Exactly one of :attr:`devices` and :attr:`out` must be specified.
Returns:
- If :attr:`devices` is specified,
a tuple containing copies of :attr:`tensor`, placed on
:attr:`devices`.
- If :attr:`out` is specified,
a tuple containing :attr:`out` tensors, each containing a copy of
:attr:`tensor`.
NzSExactly one of 'devices' and 'out' must be specified, but got devices={} and out={}c S s g | ]}t |qS )r ).0dr r B/usr/local/lib64/python3.6/site-packages/torch/nn/parallel/comm.py
# s zbroadcast..)r RuntimeErrorformattorch_CZ
_broadcastZ_broadcast_out)tensordevicesr
r r r broadcast s
r c C s, dd |D }dd | D } t jj| ||S )a/ Broadcasts a sequence tensors to the specified GPUs.
Small tensors are first coalesced into a buffer to reduce the number
of synchronizations.
Args:
tensors (sequence): tensors to broadcast. Must be on the same device,
either CPU or GPU.
devices (Iterable[torch.device, str or int]): an iterable of GPU
devices, among which to broadcast.
buffer_size (int): maximum size of the buffer used for coalescing
Returns:
A tuple containing copies of :attr:`tensor`, placed on :attr:`devices`.
c S s g | ]}t |qS r )r )r r
r r r r 8 s z'broadcast_coalesced..c S s g | ]}t |qS r )r )r tr r r r 9 s )r r Z_broadcast_coalesced)tensorsr buffer_sizer r r broadcast_coalesced) s r c sb t |dd}| d j }d xt| D ]v\}}|jjdksBtd|j |krR| |j |kr&djdd |j D }djd
d |D }tdj |||q&W