MCPcopy
hub / github.com/tinygrad/tinygrad / manual_seed

Method manual_seed

tinygrad/tensor.py:535–550  ·  view source on GitHub ↗

Sets the seed for random operations. ```python exec="true" source="above" session="tensor" result="python" Tensor.manual_seed(42) print(Tensor.rand(5).numpy()) print(Tensor.rand(5).numpy()) ``` ```python exec="true" source="above" session="tensor" result="python" Te

(seed=0)

Source from the content-addressed store, hash-verified

533 _device_rng_counters: dict[str, Tensor] = {}
534 @staticmethod
535 def manual_seed(seed=0) -> None:
536 """
537 Sets the seed for random operations.
538
539 ```python exec="true" source="above" session="tensor" result="python"
540 Tensor.manual_seed(42)
541 print(Tensor.rand(5).numpy())
542 print(Tensor.rand(5).numpy())
543 ```
544 ```python exec="true" source="above" session="tensor" result="python"
545 Tensor.manual_seed(42) # reset to the same seed
546 print(Tensor.rand(5).numpy())
547 print(Tensor.rand(5).numpy())
548 ```
549 """
550 Tensor._seed, Tensor._device_seeds, Tensor._device_rng_counters = seed, {}, {}
551
552 @staticmethod
553 def _next_counter(device:str, num:int) -> tuple[Tensor, Tensor]:

Callers 15

_check_kernel_countMethod · 0.80
test_biased_conv2dMethod · 0.80
manual_seed_allMethod · 0.80
test_gcMethod · 0.80
test_gc_complexMethod · 0.80
test_softmax_upcastMethod · 0.80
test_softmax_backwardMethod · 0.80

Calls

no outgoing calls

Tested by 15

_check_kernel_countMethod · 0.64
test_biased_conv2dMethod · 0.64
test_gcMethod · 0.64
test_gc_complexMethod · 0.64
test_softmax_upcastMethod · 0.64
test_softmax_backwardMethod · 0.64
equal_distributionFunction · 0.64