You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spec/use_cases.md
+34Lines changed: 34 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -109,3 +109,37 @@ and have `freq`, `Pxx` be arrays of the same type and on the same device as `x`.
109
109
This type of use case applies to many other libraries, from scikit-learn
110
110
and scikit-image to domain-specific libraries like AstroPy and
111
111
scikit-bio, to code written for a single purpose or user.
112
+
113
+
114
+
### Use case 2: simplify einops by removing the backend system
115
+
116
+
[einops](https://github.com/arogozhnikov/einops) is a library that provides flexible tensor operations and supports many array libraries (NumPy, TensorFlow, PyTorch, CuPy, MXNet, JAX).
contains the glue code needed to support that many array libraries.
123
+
124
+
The amount of code in each of those two files is almost the same (~550 LoC each).
125
+
The typical pattern in `einops.py` is:
126
+
```
127
+
def some_func(x):
128
+
...
129
+
backend = get_backend(x)
130
+
shape = backend.shape(x)
131
+
result = backend.reduce(x)
132
+
...
133
+
```
134
+
With a standard array API, the `_backends.py` glue layer could almost completely disappear,
135
+
because the purpose it serves (providing a unified interface to array operations from each
136
+
of the supported backends) is already addressed by the array API standard.
137
+
Hence the complete `einops` code base could be close to 50% smaller, and easier to maintain or add to.
138
+
139
+
.. note::
140
+
141
+
Other libraries that have a similar backend system to support many array libraries
142
+
include [TensorLy](https://github.com/tensorly/tensorly),
143
+
[Unumpy](https://github.com/Quansight-Labs/unumpy) and
144
+
[EagerPy](https://github.com/jonasrauber/eagerpy). Many end users and organizations will also have such glue code - it tends to be needed whenever one tries to support multiple
0 commit comments