3255 Commits

Author SHA1 Message Date
George Necula
4e89d43a75 Added JAX pytrees notebook
Also added docstrings to the tree_util module.
2019-11-24 20:29:07 +01:00
Peter Hawkins
45a1ba0bbc
Make more tests pass on TPU. (#1752) 2019-11-23 12:28:26 -05:00
Matthew Johnson
8f2a050e1e fix cov test tol
Co-authored-by: Skye Wanderman-Milne <skyewm@google.com>
2019-11-22 18:06:10 -08:00
Skye Wanderman-Milne
9f86b53af3 Revert LaxBackedNumpyTests.testCov to use all_dtypes 2019-11-22 14:28:47 -08:00
Peter Hawkins
a9d1b770e4
Relax test tolerances to reduce flakiness. (#1751)
* Relax test tolerances to reduce flakiness.

* Relax test tolerance for np.cov test.
2019-11-22 16:36:32 -05:00
Peter Hawkins
1dcddde4a0
Add jax.numpy.dtype as an alias of numpy.dtype. (#1750) 2019-11-22 16:06:56 -05:00
Skye Wanderman-Milne
3d1d140acd
Disable failing test (#1744) 2019-11-22 11:34:14 -08:00
Skye Wanderman-Milne
6f3cb1c3ee Add jax.devices(), etc. to the docs. 2019-11-22 11:03:42 -08:00
Matthew Johnson
b358c27c92 replace x.shape with onp.shape(x) in random.py
fixes #1748 (thanks @vitchyr)
2019-11-22 10:59:31 -08:00
Chris Jones
20a7e7b3f4 Remove as_abstract_val. 2019-11-22 10:52:38 -08:00
Chris Jones
9c966f9fb5 Fix as_abstract_value.
The `JaxprTracerTuple` appears to no longer exist and the function could return `None` if `pv` was another type other than `AbstractValue`, instead of raising an error.
2019-11-22 10:52:38 -08:00
Skye Wanderman-Milne
15d276ce0c Bump README to jaxlib 0.1.36 2019-11-22 10:41:59 -08:00
Thomas Keck
dc5a599a9c Fix bug in jax repeat which caused a value error for repeat arguments containing 0. (#1740) 2019-11-21 21:51:57 -05:00
Skye Wanderman-Milne
1314fb7cb1 Bump jaxlib version to 0.1.36 and update WORKSPACE. jaxlib-v0.1.36 2019-11-21 18:34:28 -08:00
Peter Hawkins
9dfb3cac28
Relax test tolerances to fix flakiness. (#1743) 2019-11-21 20:42:28 -05:00
Skye Wanderman-Milne
39e17398ee
jaxlib build improvements (#1742) 2019-11-21 16:25:24 -08:00
Stephan Hoyer
27aa76e6a6
Add precision to jax.numpy functions that use lax.dot_general (#1728)
* Add precision to jax.numpy functions that use lax.dot_general

* Test precision argument

* check default precision

* test with jaxprs

* Document precision
2019-11-21 15:30:02 -08:00
Peter Hawkins
eff7b45dba
Add jit decorators to most functions in jax.scipy.linalg. (#1741) 2019-11-21 16:31:16 -05:00
Skye Wanderman-Milne
c77cdb5144 Bump README to jaxlib 0.1.35 2019-11-21 11:02:54 -08:00
Peter Hawkins
c601950b1b
Build Mac wheels for Python 3.8 with scipy 1.3.2. (#1739)
scipy 1.3.1 never had a Python 3.8 wheel.
2019-11-21 13:52:08 -05:00
James Bradbury
a8c5b49fda
Merge pull request #1722 from google/jb/sinc-double-where
Use double-where trick to avoid NaNs in grad(sinc)
2019-11-21 09:03:19 -08:00
Peter Hawkins
a8a19e196c
Implement batching rule for lax._select_and_gather_add (#1736) 2019-11-21 11:52:58 -05:00
Peter Hawkins
2b0cde3648
Fix test failure for jax.numpy.signbit(bfloat16) on TPU. (#1735) 2019-11-21 10:48:53 -05:00
Peter Hawkins
c60f3fd65d
Minor documentation fixes. (#1734) 2019-11-21 09:51:26 -05:00
Peter Hawkins
ee36818a58
Add bfloat16 support to JAX. (#1720)
bfloat16 support is still immature, but this PR adds some initial support.

Fixes #76, at least enough that we can declare it fixed and open specific issues for specific bfloat16 problems.

The main awkwardness that this change deals with is that classic NumPy doesn't understand bfloat16 promotion rules, so we must:

implement our own type promotion operators that understand bfloat16 types
wrap a number of the reference implementations in tests to temporarily cast to float32 for computation.
2019-11-20 22:43:46 -05:00
Skye Wanderman-Milne
b7d11ab90d Bump jaxlib version to 0.1.35 jaxlib-v0.1.35 2019-11-20 15:58:34 -08:00
Stephan Hoyer
ee29705712
Add jax.scipy.ndimage to online docs (#1724) 2019-11-20 12:35:10 -08:00
Skye Wanderman-Milne
ad09822067 Bump README to jaxlib 0.1.34 2019-11-20 10:59:54 -08:00
Tzu-Wei Sung
db46a22b23 Implementation of np.signbit (#1627)
Implement `np.signbit`.
2019-11-20 13:32:43 -05:00
Matthew Johnson
2353345446 only use one gensym in tracers_to_jaxpr
fixes a bug in #1721 revealed by additional internal testing
2019-11-20 09:12:15 -08:00
Peter Buchlovsky
9d1204689f Fix typo 2019-11-20 08:53:01 -08:00
Peter Buchlovsky
410ebfeb1c Fix typo 2019-11-20 08:52:46 -08:00
Matthew Johnson
68b7dc85c3 fix multi-host pmap, disambiguate nrep
When #1667 inlined a function into its caller, it mixed up two distinct
values referred to as `nrep` in the two functions: num_global_replicas
vs num_local_replicas. The result caused errors on multi-host setups.

Co-authored-by: Jonathan Heek <jheek@google.com>
2019-11-20 08:01:15 -08:00
Stephan Hoyer
65f0556ead
Add support for scipy.ndimage.map_coordinates with order=0 and order=1 (#1711)
* Add support for scipy.ndimage.map_coordinates with order=1

Higher dimensional interpolation will be a bit trickier, but this should
already be useful.

* move around docstring

* dtype fixes, more tests

* fixup float32 tests

* Handle order=0

* Tests for errors from map_coordinates
2019-11-19 17:14:09 -08:00
James Bradbury
1817cab012 Use double-where trick to avoid NaNs in grad(sinc) 2019-11-19 16:47:32 -08:00
Skye Wanderman-Milne
b1888881da Bump jaxlib version to 0.1.33 and update WORKSPACE.
Includes XLA fixes for CPU psum.
jaxlib-v0.1.34
2019-11-19 15:30:10 -08:00
Matthew Johnson
1fcebbaa0e fix reference cycle in jaxpr tracing using weakrefs
As one step in tracing user code to a jaxpr using the machinery in
partial_eval.py, we construct a bipartite graph made of JaxprTracer
nodes, corresponding to values in the user code, and recipe nodes
,particularly those corresponding to jaxpr equations, representing
primitive operations. (This representation was put in place in #1224,
since when primitives only had single outputs we could identify each
primitive operation with the JaxprTracer value it produced.) This graph
had reference cycles because each equation recipe points to both its
input and output tracers (as a jaxpr eqn has both input and output vars)
and a tracer must be able to point to the equation recipe that produced
it (for us to toposort the graph from in_tracers to out_tracers in
tracers_to_jaxpr).

Those cycles caused memory leaks. This commit removes the strong
reference cycle using weakrefs. In particular, equation recipes only
hold weak references to their output tracers.

Before this change, we used the core.JaxprEqn struct both to represent
equations in jaxprs (where invars and outvars are instances of the
core.Var class) and to represent equation recipes (where invars and
outvars are instances of the partial_eval.JaxprTracer class). That was a
bit lazy. This commit distinguishes the two as separate JaxprEqn and
JaxprEqnRecipe structs.

Bug find and test code from @trevorcai. Thanks!
2019-11-19 15:23:08 -08:00
Matthew Johnson
5edda9e66c
remove very old "what we're working on" 2019-11-19 14:20:49 -08:00
James Bradbury
68c053319f
Merge pull request #1707 from google/jb/readme-jaxlib
Bump jaxlib version in README
2019-11-19 12:17:12 -08:00
Matthew Johnson
a3474fec38 bump version for pypi 2019-11-19 07:02:29 -08:00
Peter Hawkins
5c3b99d0b4
Implement the __pos__ operator on JAX arrays. (#1718) 2019-11-18 22:00:32 -05:00
Peter Hawkins
f95e3e969f
Check for None in indexer dtype check. (#1717) 2019-11-18 22:00:23 -05:00
Peter Hawkins
6cf2e4b8bf
Add type check that indexers are integers or boolean values. (#1716)
Improves error if, say, a float type is passed as an indexer.
2019-11-18 21:04:27 -05:00
Peter Hawkins
d323431d5e
Relax test tolerance for core_test jvp tests. (#1714) 2019-11-18 15:36:29 -05:00
Peter Hawkins
9679a87901
Avoid out-of-bounds dereference for arity-0 nodes. (#1713) 2019-11-18 15:35:07 -05:00
Peter Hawkins
42dd736afd
Change scalar promotion rules to prefer array types over scalar types. (#1709)
* Change scalar promotion rules to prefer array types over scalar types.

Currently JAX does not treat Python scalars specially during type promotion. This means that, for example:
`1. + np.array([...], np.float32)`
ends up as an array of type np.float64. The `1.` is promoted to a default type (here np.float64), and the type promotion of a np.float64 and an np.float32 is an np.float64. This is unlike classic NumPy, which treats scalars specially during type promotion, in particular, preferring the type of an array over the type of a scalar.

This change adds a notion of weak_type to JAX avals. During type promotion, we prefer non-weak types, i.e., the type of the array in the example above, ignoring the type of the scalar.

In contexts where a Python scalar is to be promoted to a NumPy value, a default type is used (e.g., `np.float_`). This change also makes it possible to use 32-bit default types that differ from NumPy's default types. The JAX test suite passes with 32-bit default types. However, we do not yet enable this change or expose it in the API.
2019-11-18 14:51:10 -05:00
George Necula
397a244e7f
Merge pull request #1706 from gnecula/loops
An implementation of an experimental syntactic sugar for 'for' and `while` loops and conditionals.
2019-11-18 12:17:59 +01:00
George Necula
8ec6ea4742 Implemented suggestions from code review.
* added example of while_range to the module docstring.
* wrap the very long lines
2019-11-18 11:39:58 +01:00
Anselm Levskaya
f882359511
fix lax.scan notes in gotchas notebook
Note that lax.scan is now jittable and differentiable in the Gotchas notebook.
2019-11-17 00:19:24 -08:00
James Bradbury
5fa68774ea
Bump jaxlib version in README 2019-11-16 17:51:16 -08:00