Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
fferflo committed Jun 10, 2024
1 parent 2e15548 commit e6035f5
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 13 deletions.
3 changes: 2 additions & 1 deletion docs/source/faq/backend.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ How does einx support different tensor frameworks?
##################################################

einx provides interfaces for tensor frameworks in the ``einx.backend.*`` namespace. einx functions accept a ``backend`` argument
that defines which backend to use for the computation. For ``backend=None`` (the default case), the backend is implicitly determined from the input tensors.
that defines which backend to use for the computation. For ``backend=None`` (the default case), the backend is implicitly determined
from the type of the input tensors.

.. code:: python
Expand Down
23 changes: 11 additions & 12 deletions docs/source/faq/universal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,14 @@ einx notation
einx provides an interface to tensor operations where vectorization is expressed entirely using einx notation, and each elementary operation
is represented by exactly one API. The einx notation is:

* **Consistent**: The same type of notation is used for all elementary operations.
* **Unique**: Each elementary operation is represented by exactly one API.
* **Consistent**: The same type of notation is used for all elementary operations. Each elementary operation is represented by exactly one API.
* **Complete**: Any operation that can be expressed with existing vectorization tools such as
`jax.vmap <https://jax.readthedocs.io/en/latest/_autosummary/jax.vmap.html>`_ can also be expressed in einx notation.

The following tables show examples of classical API calls that can be expressed using universal einx operations.

.. list-table:: Elementary operation: ``einx.get_at``
:widths: 40 60
.. list-table:: Example: ``einx.get_at``
:widths: 42 58
:header-rows: 1

* - Classical API
Expand Down Expand Up @@ -70,8 +69,8 @@ The following tables show examples of classical API calls that can be expressed
| ``x[y[..., 0], y[..., 1]]``
- ``einx.get_at("a [...], a b [i] -> a b", x, y)``

.. list-table:: Elementary operation: ``einx.dot`` (similar to einsum)
:widths: 40 60
.. list-table:: Example: ``einx.dot`` (similar to einsum)
:widths: 42 58
:header-rows: 1

* - Classical API
Expand All @@ -90,8 +89,8 @@ The following tables show examples of classical API calls that can be expressed
* - ``np.inner(x, y)``
- ``einx.dot("x... [a], y... [a] -> x... y...", x, y)``

.. list-table:: Elementary operation: ``einx.multiply``
:widths: 40 60
.. list-table:: Example: ``einx.multiply``
:widths: 42 58
:header-rows: 1

* - Classical API
Expand All @@ -105,18 +104,18 @@ The following tables show examples of classical API calls that can be expressed
* - ``np.kron(x, y)``
- ``einx.multiply("a..., b... -> (a b)...", x, y),``

.. list-table:: Elementary operation: ``einx.flip``
:widths: 40 60
.. list-table:: Example: ``einx.flip``
:widths: 42 58
:header-rows: 1

* - Classical API
- einx API

* - | ``np.flip(x, y, axis=0)``
| ``np.flipud(x, y)``
- ``einx.flip("[a] b", x),``
- ``einx.flip("[a] b", x)``
* - ``np.fliplr(x, y)``
- ``einx.flip("a [b]", x),``
- ``einx.flip("a [b]", x)``

..
* - ``einx.rearrange``
Expand Down
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Welcome to einx's documentation!
:maxdepth: 1

more/jit.rst
more/backends.rst
more/gotchas.rst
more/related.rst

Expand Down
42 changes: 42 additions & 0 deletions docs/source/more/backends.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Supported tensor frameworks
###########################

**Numpy**: `https://numpy.org/ <https://numpy.org/>`_

Numpy does not support automatic vectorization (``vmap``). einx implements a custom ``vmap`` for Numpy instead using a Python for-loop
for testing and debugging purposes. This affects ``einx.vmap`` and ``einx.{index|get_at|set_at|...}``.

----

**Torch**: `https://pytorch.org/ <https://pytorch.org/>`_

einx disables ``torch.compile`` (using ``torch.compiler.disable``) when JIT-compiling a call into a Python function and reenables it when
executing the function.

----

**Jax**: `https://jax.readthedocs.io/ <https://jax.readthedocs.io/>`_

----

**Tensorflow**: `https://www.tensorflow.org/ <https://www.tensorflow.org/>`_

einx does not support tensors with dynamic shapes (i.e. ``None`` in the shape).

----

**MLX**: `https://ml-explore.github.io/mlx <https://ml-explore.github.io/mlx>`_

``einx.vmap`` and ``einx.{index|get_at|set_at|...}`` are currently not supported (``mx.vmap`` does not support all required primitives yet).

----

**Tinygrad**: `https://tinygrad.org/ <https://tinygrad.org/>`_

``einx.vmap`` and ``einx.{index|get_at|set_at|...}`` are currently not supported.

----

**Dask**: `https://docs.dask.org/en/stable/array.html <https://docs.dask.org/en/stable/array.html>`_

``einx.vmap`` and ``einx.{index|get_at|set_at|...}`` are currently not supported.

0 comments on commit e6035f5

Please sign in to comment.