chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
"""Utility functions for random number generation."""
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
def set_global_random_seed(seed):
|
||||
"""Set global random seed for python, numpy, torch and tvm."""
|
||||
if "numpy" in sys.modules:
|
||||
sys.modules["numpy"].random.seed(seed)
|
||||
if "torch" in sys.modules:
|
||||
sys.modules["torch"].manual_seed(seed)
|
||||
if "random" in sys.modules:
|
||||
sys.modules["random"].seed(seed)
|
||||
if "tvm" in sys.modules:
|
||||
set_seed = sys.modules["tvm"].get_global_func("mlc.random.set_seed")
|
||||
if set_seed:
|
||||
set_seed(seed)
|
||||
Reference in New Issue
Block a user