/usr/local/lib64/python3.6/site-packages/torch/cuda/__pycache__
Edit: /usr/local/lib64/python3.6/site-packages/torch/cuda/__pycache__/random.cpython-36.pyc (5520B)
3
Egg @ s d dl Z d dlmZmZmZmZ ddlmZmZm Z m
Z
ddlmZ ddd d
ddd
ddg Zdee
ee jf edddZee dddZd eee
ee jf dddd Zee dddd
Ze
ddddZe
ddddZdddd
ZddddZe
dddZdS )! N)castIterableListUnion )
_lazy_init
_lazy_calldevice_countcurrent_device )Tensor
get_rng_stateget_rng_state_all
set_rng_stateset_rng_state_allmanual_seedmanual_seed_allseedseed_allinitial_seedcuda)devicereturnc C sZ t t| trtj| } nt| tr2tjd| } | j}|dkrFt }tjj | }|j
S )aS Returns the random number generator state of the specified GPU as a ByteTensor.
Args:
device (torch.device or int, optional): The device to return the RNG state of.
Default: ``'cuda'`` (i.e., ``torch.device('cuda')``, the current CUDA device).
.. warning::
This function eagerly initializes CUDA.
r N)r
isinstancestrtorchr intindexr
r default_generatorsZ get_state)r idxdefault_generator r! =/usr/local/lib64/python3.6/site-packages/torch/cuda/random.pyr
s
)r c C s* g } x t t D ]}| jt| qW | S )zRReturns a list of ByteTensor representing the random number states of all devices.)ranger appendr
)resultsir! r! r" r " s ) new_stater r c sT | j tjdt tr$tj nt tr:tjd fdd}t| dS )a0 Sets the random number generator state of the specified GPU.
Args:
new_state (torch.ByteTensor): The desired state
device (torch.device or int, optional): The device to set the RNG state.
Default: ``'cuda'`` (i.e., ``torch.device('cuda')``, the current CUDA device).
)Z
memory_formatr c s6 t tj j} | d krt } tjj| }|j d S )N)r r r r r
r r Z set_state)r r )r new_state_copyr! r" cb9 s
zset_rng_state.
.cbN)cloner Zcontiguous_formatr r r r r )r' r r) r! )r r( r" r + s
)
new_statesr c C s$ xt | D ]\}}t|| q
W dS )zSets the random number generator state of all devices.
Args:
new_states (Iterable of torch.ByteTensor): The desired state for each deviceN) enumerater )r+ r&