/usr/local/lib64/python3.6/site-packages/torch/__pycache__
Edit: /usr/local/lib64/python3.6/site-packages/torch/__pycache__/random.cpython-36.pyc (4271B)
3
Eg @ s d dl Z d dlmZ d dlZd dlmZ d dlZejddddZejddd Z ej
jdd
dZeddd
Z
edddZdae jdedddZdS ) N) Generator)default_generator) new_statereturnc C s t j| dS )zSets the random number generator state.
.. note: This function only works for CPU. For CUDA, please use
torch.manual_seed(seed), which works for both CPU and CUDA.
Args:
new_state (torch.ByteTensor): The desired state
N)r Z set_state)r r 8/usr/local/lib64/python3.6/site-packages/torch/random.py
set_rng_state s r )r c C s t j S )zBReturns the random number generator state as a `torch.ByteTensor`.)r Z get_stater r r r
get_rng_state s r c C s0 t | } ddl}|jj s&|jj| tj| S )a Sets the seed for generating random numbers. Returns a
`torch.Generator` object.
Args:
seed (int): The desired seed. Value must be within the inclusive range
`[-0x8000_0000_0000_0000, 0xffff_ffff_ffff_ffff]`. Otherwise, a RuntimeError
is raised. Negative inputs are remapped to positive values with the formula
`0xffff_ffff_ffff_ffff + seed`.
r N)int
torch.cudacuda_is_in_bad_forkmanual_seed_allr manual_seed)seedtorchr r r r s
r c C s* t j } ddl}|jj s&|jj| | S )zSets the seed for generating random numbers to a non-deterministic
random number. Returns a 64 bit number used to seed the RNG.
r N)r r r r r
r )r r r r r r - s
r c C s t j S )zSReturns the initial seed for generating random numbers as a
Python `long`.
)r initial_seedr r r r r : s r FTfork_rngdevicesc
c s ddl }|sdV dS | dkr^|jj }|dkrPt rPtjdj|||d datt|} nt| } |j }g }x| D ]}|j
|jj | qxW z
dV W d|j| x$t| |D ]\}} |jj| | qW X dS )a
Forks the RNG, so that when you return, the RNG is reset
to the state that it was previously in.
Args:
devices (iterable of CUDA IDs): CUDA devices for which to fork
the RNG. CPU RNG state is always forked. By default, :meth:`fork_rng` operates
on all devices, but will emit a warning if your machine has a lot
of devices, since this function will run very slowly in that case.
If you explicitly specify devices, this warning will be suppressed
enabled (bool): if ``False``, the RNG is not forked. This is a convenience
argument for easily disabling the context manager without having
to delete it and unindent your Python code under it.
r N a CUDA reports that you have {num_devices} available devices, and you have used {caller} without explicitly specifying which devices are being used. For safety, we initialize *every* CUDA device by default, which can be quite slow if you have a lot of GPUs. If you know that you are only making use of a few CUDA devices, set the environment variable CUDA_VISIBLE_DEVICES or the '{devices_kw}' keyword argument of {caller} with the set of devices you are actually using. For example, if you are using CPU only, set CUDA_VISIBLE_DEVICES= or devices=[]; if you are using GPU 0 only, set CUDA_VISIBLE_DEVICES=0 or devices=[0]. To initialize all devices and suppress this warning, set the '{devices_kw}' keyword argument to `range(torch.cuda.device_count())`.)num_devicesZcallerZ
devices_kwT)
r r Zdevice_count_fork_rng_warned_alreadywarningswarnformatlistranger appendr zip)
r enabledZ_callerZ_devices_kwr r Z
cpu_rng_stateZgpu_rng_statesZdeviceZ
gpu_rng_stater r r r D s,
)NTr r )
contextlibtypingr r Ztorch._Cr r ZTensorr r _Cr r
r r r contextmanagerr r r r r
s