Skip to content
README.rst 2.78 KiB
Newer Older
Xiaoyu Wei's avatar
Xiaoyu Wei committed
Lappy
Xiaoyu Wei's avatar
Xiaoyu Wei committed
``Lappy`` is a fork of Sophia Lin's ``lazyray`` that supports more operations beyond arithmetics.
Xiaoyu Wei's avatar
Xiaoyu Wei committed
In ``Lappy``, everything computable is considered an array object (unlike ``numpy``, it does not offer separate scalar types).
An array object has six basic components: the shape, the dtype, the expression, the value, the formal argument list, and the environment (capture list).
Scalars are special arrays with shape being an empty tuple.
If the dtype is an integer type, there can be assumptions associated with the array elements represented by an integer set (for scalars) or map (for non-scalars).

Xiaoyu Wei's avatar
Xiaoyu Wei committed
Status
------

This is a list of things that can be achieved with ``lappy`` today:

- ✅ Arithmetic and scalar mathematics (lifted scalar functions / universal functions)
- ✅ Axis reordering / transpose
- ✅ Reshaping

Xiaoyu Wei's avatar
Xiaoyu Wei committed
Scope
-----

Xiaoyu Wei's avatar
Xiaoyu Wei committed
The following additional features are planned to be supported:
Xiaoyu Wei's avatar
Xiaoyu Wei committed

Xiaoyu Wei's avatar
Xiaoyu Wei committed
- ✅ Scan and fold
- ✅ Tensor contractions, like ``np.einsum`` (including dot products and matrix multiply)
- ✅ Slicing and broadcasting (static and dynamic)
- ✅ Fancy indexing (static and dynamic)
- ✅ Integration with Numpy's dispatch mechanism like ``__array__`` and ``__array_ufunc__``
- ✅ Some linear algebra like ``svd``, ``qr``, ``lstsq``
Xiaoyu Wei's avatar
Xiaoyu Wei committed

What are planned to be **not** supported:

Xiaoyu Wei's avatar
Xiaoyu Wei committed
- ❌ In-place primitives (rhs of any assignment is conceptually functional),
Xiaoyu Wei's avatar
Xiaoyu Wei committed
      e.g., in-place quick sort. Although the generated code may be in-place for
      ``A = sorted(A)``, it is up to the optimizer and not semantically guaranteed.

Xiaoyu Wei's avatar
Xiaoyu Wei committed
- ❌ Every feature of an APL-like IR.
Xiaoyu Wei's avatar
Xiaoyu Wei committed

Semantics
---------

In-place assignment
*******************

Like ``numpy``, each statement is considered one functional transaction with no hidden sequential
side effects, even the variable appears in both rhs and lhs.
For example, ``x = (diag(A)**-1) (b - R x)`` computes one step of Jacobi iteration for solving
``Ax = b`` where ``A = diag(A) + R``.

Static vs dynamic indexing
**************************

A static indexing like ``A[2:5, ...]`` has the index address known at compile time, and
can be handled in a piecewise fashion by ISL.
Examples of static indexing include finite difference and linear algebraic algorithms like GMRES.

A dynamic indexing like ``A[B]`` has the index address known at runtime and is handled
by special nodes. Examples of dynamic indexing include CSR sparse matrices with dynamic
sparsity patterns in adaptive tree building and graph algorithms.
In general, a statement with dynamic addressing will affect the expression for the
whole array, unless the access is bounded by a known subset (e.g., the CSR matrix has
bounded bandwidth) specified by the user.

Sophia Lin's avatar
Sophia Lin committed
----
Xiaoyu Wei's avatar
Xiaoyu Wei committed
``Lappy`` is licensed under the `MIT license <http://en.wikipedia.org/wiki/MIT_License>`_ and free for commercial, academic,
Sophia Lin's avatar
Sophia Lin committed
and private use.