mirror of
https://github.com/ROCm/jax.git
synced 2025-04-24 21:46:05 +00:00

Mark the index_update() etc. operators as deprecated in the documentation. Add new .divide and .power operators. Fixes #2694. Add .multiply as an alias for .mul. To be more numpy-like we should probably prefer the longer names.
65 lines
1.7 KiB
ReStructuredText
65 lines
1.7 KiB
ReStructuredText
|
|
jax.ops package
|
|
=================
|
|
|
|
.. currentmodule:: jax.ops
|
|
|
|
.. automodule:: jax.ops
|
|
|
|
.. _syntactic-sugar-for-ops:
|
|
|
|
Indexed update operators
|
|
------------------------
|
|
|
|
JAX is intended to be used with a functional style of programming, and
|
|
does not support NumPy-style indexed assignment directly. Instead, JAX provides
|
|
alternative pure functional operators for indexed updates to arrays.
|
|
|
|
JAX array types have a property ``at``, which can be used as
|
|
follows (where ``idx`` is a NumPy index expression).
|
|
|
|
========================= ===================================================
|
|
Alternate syntax Equivalent in-place expression
|
|
========================= ===================================================
|
|
``x.at[idx].set(y)`` ``x[idx] = y``
|
|
``x.at[idx].add(y)`` ``x[idx] += y``
|
|
``x.at[idx].multiply(y)`` ``x[idx] *= y``
|
|
``x.at[idx].divide(y)`` ``x[idx] /= y``
|
|
``x.at[idx].power(y)`` ``x[idx] **= y``
|
|
``x.at[idx].min(y)`` ``x[idx] = np.minimum(x[idx], y)``
|
|
``x.at[idx].max(y)`` ``x[idx] = np.maximum(x[idx], y)``
|
|
========================= ===================================================
|
|
|
|
None of these expressions modify the original `x`; instead they return
|
|
a modified copy of `x`.
|
|
|
|
|
|
Indexed update functions (deprecated)
|
|
-------------------------------------
|
|
|
|
The following functions are aliases for the ``x.at[idx].set(y)``
|
|
style operators. Prefer to use the ``x.at[idx]`` operators instead.
|
|
|
|
.. autosummary::
|
|
:toctree: _autosummary
|
|
|
|
index
|
|
index_update
|
|
index_add
|
|
index_mul
|
|
index_min
|
|
index_max
|
|
|
|
|
|
|
|
Other operators
|
|
---------------
|
|
|
|
.. autosummary::
|
|
:toctree: _autosummary
|
|
|
|
segment_max
|
|
segment_min
|
|
segment_prod
|
|
segment_sum
|