Download lib/python3.12/site-packages/cupy/random/_permutations.py from ZhengyangZhang/attn-env: direct link, hf CLI and curl.
- Browser
- Download file 752 Bytes
-
https://huggingface.co/ZhengyangZhang/attn-env/resolve/main/lib/python3.12/site-packages/cupy/random/_permutations.py
- Command line
-
hf download hf://ZhengyangZhang/attn-env/lib/python3.12/site-packages/cupy/random/_permutations.py
-
curl -L -o _permutations.py https://huggingface.co/ZhengyangZhang/attn-env/resolve/main/lib/python3.12/site-packages/cupy/random/_permutations.py
752 Bytes
| from __future__ import annotations | |
| from cupy.random import _generator | |
| def shuffle(a): | |
| """Shuffles an array. | |
| Args: | |
| a (cupy.ndarray): The array to be shuffled. | |
| .. seealso:: :meth:`numpy.random.shuffle` | |
| """ | |
| rs = _generator.get_random_state() | |
| return rs.shuffle(a) | |
| def permutation(a): | |
| """Returns a permuted range or a permutation of an array. | |
| Args: | |
| a (int or cupy.ndarray): The range or the array to be shuffled. | |
| Returns: | |
| cupy.ndarray: If `a` is an integer, it is permutation range between 0 | |
| and `a` - 1. | |
| Otherwise, it is a permutation of `a`. | |
| .. seealso:: :meth:`numpy.random.permutation` | |
| """ | |
| rs = _generator.get_random_state() | |
| return rs.permutation(a) | |