(
low: float,
high: float,
size: Optional[Iterable[int]],
seed: int,
device: str,
handle: int,
)
| 90 | |
| 91 | |
| 92 | def _uniform( |
| 93 | low: float, |
| 94 | high: float, |
| 95 | size: Optional[Iterable[int]], |
| 96 | seed: int, |
| 97 | device: str, |
| 98 | handle: int, |
| 99 | ) -> Tensor: |
| 100 | assert low < high, "Uniform is not defined when low >= high" |
| 101 | if size is None: |
| 102 | size = (1,) |
| 103 | op = UniformRNG(seed=seed, handle=handle, dtype="float32") |
| 104 | _ref = Tensor([], dtype="int32", device=device) |
| 105 | shape = utils.astensor1d(size, _ref, dtype="int32", device=device) |
| 106 | (output,) = apply(op, shape) |
| 107 | if low == 0 and high == 1: |
| 108 | return output |
| 109 | return low + (high - low) * output |
| 110 | |
| 111 | |
| 112 | def _normal( |
no test coverage detected