Skip to content

Commit

Permalink
Fix PRNGKeyArray.broadcast_to with scalar shape
Browse files Browse the repository at this point in the history
  • Loading branch information
YouJiacheng authored Apr 14, 2022
1 parent 7ad1120 commit edace00
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions jax/_src/prng.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ def concatenate(self, key_arrs, axis):
return PRNGKeyArray(self.impl, jnp.concatenate(arrs, axis))

def broadcast_to(self, shape):
if jnp.ndim(shape) == 0:
shape = (shape,)
new_shape = (*shape, *self.impl.key_shape)
return PRNGKeyArray(self.impl, jnp.broadcast_to(self._keys, new_shape))

Expand Down

0 comments on commit edace00

Please sign in to comment.