mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 05:34:18 +08:00
Refactor Random Number Generators in ATen (#21364)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/21364 ghimport-source-id: ca7d37e10190ba46dc8512f437404ca9216d3369 Differential Revision: D15696497 Pulled By: ezyang fbshipit-source-id: 2e713b8566ae915e175b5a79ac1dd9b86cc2a23d
This commit is contained in:
committed by
Facebook Github Bot
parent
96910251e0
commit
ae342fd076
@ -20,7 +20,7 @@ def get_rng_state():
|
||||
|
||||
def manual_seed(seed):
|
||||
r"""Sets the seed for generating random numbers. Returns a
|
||||
`torch._C.Generator` object.
|
||||
`torch.Generator` object.
|
||||
|
||||
Args:
|
||||
seed (int): The desired seed.
|
||||
@ -34,6 +34,19 @@ def manual_seed(seed):
|
||||
return default_generator.manual_seed(seed)
|
||||
|
||||
|
||||
def seed():
|
||||
r"""Sets the seed for generating random numbers to a non-deterministic
|
||||
random number. Returns a 64 bit number used to seed the RNG.
|
||||
"""
|
||||
seed = default_generator.seed()
|
||||
import torch.cuda
|
||||
|
||||
if not torch.cuda._in_bad_fork:
|
||||
torch.cuda.manual_seed_all(seed)
|
||||
|
||||
return seed
|
||||
|
||||
|
||||
def initial_seed():
|
||||
r"""Returns the initial seed for generating random numbers as a
|
||||
Python `long`.
|
||||
|
Reference in New Issue
Block a user