Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
fferflo committed Jun 18, 2024
1 parent af49870 commit f034827
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ x = {np.asarray|torch.as_tensor|jnp.asarray|...}(...) # Create some tensor

einx.sum("a [b]", x) # Sum-reduction along second axis
einx.flip("... (g [c])", x, c=2) # Flip pairs of values along the last axis
einx.mean("b [s...] c", x) # Spatial mean-pooling
einx.sum("b (s [s2])... c", x, s2=2) # Sum-pooling with kernel_size=stride=2
einx.mean("b [...] c", x) # Spatial mean-pooling
einx.multiply("a..., b... -> (a b)...", x, y) # Kronecker product
einx.sum("b (s [ds])... c", x, ds=(2, 2)) # Sum-pooling with 2x2 kernel
einx.add("a, b -> a b", x, y) # Outer sum
einx.dot("a [b], [b] c -> a c", x, y) # Matmul

einx.get_at("b [h w] c, b i [2] -> b i c", x, y) # Gather values at coordinates

Expand All @@ -52,8 +54,6 @@ einx.vmap("b [s...] c -> b c", x, op=np.mean) # Spatial mean-pooling
einx.vmap("a [b], [b] c -> a c", x, y, op=np.dot) # Matmul
```

All einx functions simply forward computation to the respective backend, e.g. by internally calling `np.reshape`, `np.transpose`, `np.sum` with the appropriate arguments.

#### Common neural network operations

```python
Expand Down
3 changes: 1 addition & 2 deletions docs/source/faq/universal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ The following tables show examples of classical API calls that can be expressed
- ``einx.get_at("[_], ... -> ...", x, y)``
* - ``tf.gather_nd(x, y)``
- ``einx.get_at("[...], b [i] -> b", x, y)``
* - | ``tf.gather_nd(x, y, batch_dims=1)``
| ``x[y[..., 0], y[..., 1]]``
* - ``tf.gather_nd(x, y, batch_dims=1)``
- ``einx.get_at("a [...], a b [i] -> a b", x, y)``

.. list-table:: Example: ``einx.dot`` (similar to einsum)
Expand Down

0 comments on commit f034827

Please sign in to comment.