8265 Commits

Author SHA1 Message Date
Jake VanderPlas
79d0852145 Add optional size argument to jnp.union1d for JIT compatibility 2021-06-09 11:36:34 -07:00
jax authors
2a1936e6f9 Merge pull request #6824 from jakevdp:sparse-bcoo
PiperOrigin-RevId: 378437750
2021-06-09 10:25:28 -07:00
jax authors
8362db6ef8 Merge pull request #6925 from jakevdp:nonzero-test
PiperOrigin-RevId: 378420194
2021-06-09 09:10:59 -07:00
Jake VanderPlas
69f29a631a Add experimental batched COO sparse format.
This is an implementation of a batch-friendly multidimensional COO format for JAX. It contains implementations of four primitives (bcoo_todense, bcoo_fromdense, bcoo_extract, bcoo_dot_general), as well as batching, JVP, and transpose rules for each.

For convenience, this also adds class BCOO, which is a pytree wrapper around these.
2021-06-09 09:10:53 -07:00
Marc van Zee
b749e78d2c Adds support for enable_xla=False for shape polymorphism tests and adds such tests for dynamic_slice.
It turned out that, in jax2tf._dynamic_slice, tf.constant doesn't work with polymorphic shapes, so I replaced it with a tf.cast.

PiperOrigin-RevId: 378392273
2021-06-09 06:35:07 -07:00
jax authors
86d2da44c0 Merge pull request #6919 from marcvanzee:patch-3
PiperOrigin-RevId: 378352041
2021-06-09 01:53:27 -07:00
jax authors
aac8d7434c Merge pull request #6860 from gnecula:tf_source
PiperOrigin-RevId: 378351073
2021-06-09 01:45:19 -07:00
George Necula
59ae45a83c [jax2tf] Add support for generating HLO OpMetadata in the TF graph
The goal is to ensure that the HLO that
jax2tf->TF/XLA generates has the same metadata as what JAX generates.
This includes `op_type`, `op_name`, and source information, which are
used for debugging and profiling.

In order to ensure that this metadata is carried from the JAX tracing
time to TF/XLA, we save the metadata in custom TF op attributes. These
attributes are automatically preserved through SavedModel. This relies
on a separate change in TF/XLA to look for these custom attributes
and override its default.

For the source information, we use pretty much the same code that
xla.py uses. HLO OpMetadata has room for only one source location.
JAX (xla.py) picks the top-most user frame, which is obtained by
filtering out the stack frames in the JAX source tree. When used
with jax2tf we also need to filter out stack frames in the
TensorFlow source tree.

The hardest part is to generate the `op_name`, which is a hierarchical
name with components separated by '/', e.g., `jax2tf(top_func)/while/cond/le`.
We carry the current `name_stack` in thread-local state. Unfortunately, there
is no easy way to share the exact code that achieves this in xla.py. At the
same time it is not crucial that we have exactly identical name stacks as in
JAX.

I attempted to also carry this state in the JAX `MainTrace`, but could not
fully control the name stack. E.g., when calling a jitted-function we
have to reuse the current `MainTrace` although we want to push an element
on the name stack.

For now this option is not yet enabled until we make the necessary
changes in TensorFlow.
2021-06-09 08:08:42 +02:00
Jake VanderPlas
0f4f4102ce Add more complete test for jnp.nonzero size argument 2021-06-08 16:40:53 -07:00
jax authors
30b00095a9 Merge pull request #6915 from jakevdp:argwhere-size
PiperOrigin-RevId: 378275722
2021-06-08 16:39:57 -07:00
jax authors
c6d389387e Merge pull request #6926 from jakevdp:fix-random-validation
PiperOrigin-RevId: 378271745
2021-06-08 16:21:18 -07:00
Jake VanderPlas
f97e2f945f jnp.argwhere: add optional size parameter for JIT compatibility 2021-06-08 16:17:37 -07:00
jax authors
0383d7b312 Merge pull request #6910 from jakevdp:where-size
PiperOrigin-RevId: 378270750
2021-06-08 16:16:13 -07:00
Jake VanderPlas
022464b91b jnp.where: add optional size argument 2021-06-08 15:53:12 -07:00
Allen Lavoie
e7fe44e9fd Fix jax2tf._is_tfval after tf.constant placement changes
complex128 isn't supported on TPUs in TF, tf.constant now places on TPU by default, _is_tfval saw the exception and assumed it wasn't convertable to a TF type.

PiperOrigin-RevId: 378240447
2021-06-08 14:06:22 -07:00
jax authors
17c2d8a50b Merge pull request #6913 from jakevdp:flatnonzero-size
PiperOrigin-RevId: 378235152
2021-06-08 13:43:55 -07:00
Jake VanderPlas
119c9bc0dd jax.random: improve input validation (fixes #6922) 2021-06-08 13:37:21 -07:00
Jake VanderPlas
1296dc3f1e jnp.flatnonzero: add optional size argument for JIT compatibility 2021-06-08 13:16:51 -07:00
jax authors
72cd6d0072 Merge pull request #6912 from jakevdp:jittable-unique
PiperOrigin-RevId: 378217815
2021-06-08 12:34:24 -07:00
jax authors
d38def4660 Merge pull request #6923 from jakevdp:gamma-doc
PiperOrigin-RevId: 378217732
2021-06-08 12:31:06 -07:00
jax authors
648b5d3265 Merge pull request #6066 from apaszke:xmap-no-mesh-slicing
PiperOrigin-RevId: 378209333
2021-06-08 11:54:05 -07:00
Jake VanderPlas
d198ad0ac1 jnp.unique: add optional size argument for JIT compatibility 2021-06-08 11:31:42 -07:00
Jake VanderPlas
22dbe80255 DOC: state that digamma only accepts float 2021-06-08 10:47:27 -07:00
jax authors
3927946456 Merge pull request #6920 from apaszke:xmap-loops
PiperOrigin-RevId: 378147047
2021-06-08 07:15:57 -07:00
Adam Paszke
54ba051631 Always run xmap over all mesh axes
Automatic mesh slicing might be surprising, and can always be
performed manually.
2021-06-08 13:36:13 +00:00
Adam Paszke
490f9778c8 Raise a friendlier error message when using loop axes in collectives 2021-06-08 11:55:03 +00:00
Marc van Zee
80e69d456e
Update README.md 2021-06-08 07:21:40 +02:00
jax authors
7a3a160b26 Merge pull request #6869 from colemanliyah:file_system_cache
PiperOrigin-RevId: 378012890
2021-06-07 14:59:49 -07:00
Peter Hawkins
e9611eb090 Move jax.ad_util to jax._src.ad_util.
Expose ad_util.stop_gradient_p as jax.lax.stop_gradient_p. stop_gradient() is already under the external lax namespace.

PiperOrigin-RevId: 378011152
2021-06-07 14:51:34 -07:00
jax authors
7591e16c98 Merge pull request #6917 from hawkinsp:token
PiperOrigin-RevId: 377997455
2021-06-07 13:50:56 -07:00
jax authors
737efb5908 Merge pull request #6916 from jakevdp:doc-typo
PiperOrigin-RevId: 377990039
2021-06-07 13:19:26 -07:00
Peter Hawkins
d5ba87ad7f Add a device_put handler for tokens.
Fixes bug with tokens passed to trivial computations.
2021-06-07 16:19:14 -04:00
Jake VanderPlas
9be4a3e83f Fix typo/formatting issue in DeviceArray docs 2021-06-07 13:11:37 -07:00
jax authors
871b91443e Merge pull request #6900 from erwincoumans:master
PiperOrigin-RevId: 377980545
2021-06-07 12:38:54 -07:00
jax authors
32bcb5b098 Merge pull request #6911 from zhangqiaorjc:rm_cache_if_st
PiperOrigin-RevId: 377979800
2021-06-07 12:35:27 -07:00
Qiao Zhang
f5f62ce0d5 Remove stale cache_clear in api_test. 2021-06-07 12:10:54 -07:00
Liyah Coleman
75cc734c8e completed FilesystemCache class with corresponding unit tests 2021-06-07 17:26:23 +00:00
jax authors
fe3de5ab72 Merge pull request #6906 from apaszke:xmap-loops
PiperOrigin-RevId: 377939118
2021-06-07 09:49:24 -07:00
Marc van Zee
9fed620119 Adds support for lax.dynamic_slice_p when XLA is disabled.
PiperOrigin-RevId: 377909682
2021-06-07 07:22:48 -07:00
jax authors
69c707639d Merge pull request #6891 from skye:peter_comments
PiperOrigin-RevId: 377900628
2021-06-07 06:30:34 -07:00
Adam Paszke
4fc4a3e471 Add support for sequential loop resources in xmap
This is especially useful because it makes it easy to implement
"memory-limited vmaps". It might also come in handy for pipelining,
as that could represent the microbatching loop.

Note that at the moment the xmap has to be a pure map along all axes
that are assigned to loop resources. No collectives are supported.
2021-06-07 12:58:08 +00:00
erwin coumans
f0e55e3ce2 move #endif so that Windows doesn't have GetXCR0EAX defined twice
(erroring out)
2021-06-04 17:26:27 -07:00
jax authors
0c102db5eb Merge pull request #6892 from gnecula:tf_cplx
PiperOrigin-RevId: 377529860
2021-06-04 09:40:43 -07:00
George Necula
d243258b86 [jax2tf] Implement inequalities and friends for complex numbers.
This requires re-using JAX's lowering rule for comparisons of
complex numbers to use lexicographic comparison.
2021-06-04 17:56:44 +03:00
jax authors
de9f55720d Merge pull request #6895 from gnecula:tf_uint64
PiperOrigin-RevId: 377510835
2021-06-04 07:49:44 -07:00
George Necula
ede457f1a5 [jax2tf] Fix bug with max_int for uint64 2021-06-04 15:29:54 +03:00
George Necula
293ca655e0 [jax2tf] Update limitations to account for tf.math improvements for trigonometric functions.
PiperOrigin-RevId: 377436077
2021-06-03 21:17:56 -07:00
jax authors
1912bd97f4 Merge pull request #6673 from hypercubestart:master
PiperOrigin-RevId: 377417011
2021-06-03 18:29:31 -07:00
Skye Wanderman-Milne
4a85877159 Clean up multi-process guide language.
Many thanks to hawkinsp@ for these suggestions.
2021-06-03 14:19:22 -07:00
jax authors
9d677e6641 Merge pull request #6875 from gnecula:tf_x32
PiperOrigin-RevId: 377351830
2021-06-03 12:51:57 -07:00