Skip to content

Commit

Permalink
Merge pull request #4412 from jakevdp:axis-concrete
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 333822998
  • Loading branch information
jax authors committed Sep 25, 2020
2 parents 4d55683 + 185590f commit aaa5724
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions jax/core.py
Expand Up @@ -867,6 +867,8 @@ def error(self, arg):

def concrete_or_error(force: Any, val: Any, context=""):
"""Like force(val), but gives the context in the error message."""
if force is None:
force = lambda x: x
if isinstance(val, Tracer):
if isinstance(val.aval, ConcreteArray):
return force(val.aval.val)
Expand Down
1 change: 1 addition & 0 deletions jax/numpy/lax_numpy.py
Expand Up @@ -1739,6 +1739,7 @@ def reduction(a, axis=None, dtype=None, out=None, keepdims=False):
if out is not None:
raise ValueError("reduction does not support the `out` argument.")
_check_arraylike(name, a)
axis = core.concrete_or_error(None, axis, f"axis argument to jnp.{name}().")

a = a if isinstance(a, ndarray) else asarray(a)
a = preproc(a) if preproc else a
Expand Down

0 comments on commit aaa5724

Please sign in to comment.