Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
identify PRNG schemes on key arrays, and recognize them in key constr…
…uctors Specifically: * Introduce `jax.random.key_impl`, which accepts a key array and returns a hashable identifier of its PRNG implementation. * Accept this identifier optionally as the `impl` argument to `jax.random.key` and `wrap_key_data`. This now works: ```python k1 = jax.random.key(72, impl='threefry2x32') impl = jax.random.key_impl(k1) k2 = jax.random.key(72, impl=impl) assert arrays_equal(k1, k2) assert k1.dtype == k2.dtype ``` This change also set up an internal PRNG registry and register built-in implementations, to simplify various places where we essentially reconstruct such a registry from scratch (such as in tests). Co-authored-by: Jake Vanderplas <jakevdp@google.com>
- Loading branch information
Showing
5 changed files
with
137 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters