Files
mlc-ai--mlc-llm/python/mlc_llm/support/random.py
T
wehub-resource-sync 770d92cb1f
Lint / lint (push) Has been cancelled
Build Docs / Deploy Docs (push) Has been cancelled
Windows CI / Windows (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:23:58 +08:00

18 lines
552 B
Python

"""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)