Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix doc #179

Merged
merged 5 commits into from
Jul 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions doc/api/math-operations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ or
\beta_j = \operatorname{Reduction}_i\limits \big[ F(x^0_{\iota_0}, ... , x^{n-1}_{\iota_{n-1}}) \big]

where :math:`F` is a symbolic formula, the :math:`x^k_{\iota_k}`'s are vector variables
and
and
:math:`\text{Reduction}` is a Sum, LogSumExp or any other standard operation (see :ref:`part.reduction` for the full list of supported reductions).

We now describe the symbolic syntax that
We now describe the symbolic syntax that
can be used through all KeOps bindings.

.. _`part.varCategory`:
Expand All @@ -29,7 +29,7 @@ Variables: category, index and dimension
========================================


At a low level, every variable :math:`x^k_{\iota_k}` is specified by its **category** :math:`\iota_k\in\{i,j,\emptyset\}` (meaning that the variable is indexed by :math:`i`, by :math:`j`, or is a fixed parameter across indices), its **positional index** :math:`k` and its **dimension** :math:`d_k`.
At a low level, every variable :math:`x^k_{\iota_k}` is specified by its **category** :math:`\iota_k\in\{i,j,\emptyset\}` (meaning that the variable is indexed by :math:`i`, by :math:`j`, or is a fixed parameter across indices), its **positional index** :math:`k` and its **dimension** :math:`d_k`.

In practice, the category :math:`\iota_k` is given through a keyword

Expand Down Expand Up @@ -78,10 +78,11 @@ To define formulas with KeOps, you can use simple arithmetics:
Elementary functions:

====================== =========================================================================================================
``Minus(f)`` element-wise opposite of ``f``
``Inv(f)`` element-wise inverse ``1 ./ f``
``Exp(f)`` element-wise exponential function
``Log(f)`` element-wise natural logarithm
``XLogX(f)`` computes ``f * log(f)`` element-wise (with value ``0`` at ``0``)
``XLogX(f)`` computes ``f * log(f)`` element-wise (with value ``0`` at ``0``)
``Sin(f)`` element-wise sine function
``SinXDivX(f)`` function ``sin(f)/f`` element-wise (with value ``1`` at ``0``)
``Asin(f)`` element-wise arc-sine function
Expand Down Expand Up @@ -172,7 +173,7 @@ Elementary dot products:
``MatVecMult(f, g)`` matrix-vector product ``f x g``: ``f`` is vector interpreted as matrix (column-major), ``g`` is vector
``VecMatMult(f, g)`` vector-matrix product ``f x g``: ``f`` is vector, ``g`` is vector interpreted as matrix (column-major)
``TensorProd(f, g)`` tensor cross product ``f x g^T``: ``f`` and ``g`` are vectors of sizes M and N, output is of size MN.
``TensorDot(f, g, dimf, dimg, contf, contg)`` tensordot product ``f : g``(similar to `numpy's tensordot <https://docs.scipy.org/doc/numpy/reference/generated/numpy.tensordot.html>`_ in the spirit): ``f`` and ``g`` are tensors of sizes listed in ``dimf`` and ``dimg`` :ref:`index sequences <part.reservedWord>` and contracted along the dimensions listed in ``contf`` and ``contg`` :ref:`index sequences <part.reservedWord>`. The ``MatVecMult``, ``VecMatMult`` and ``TensorProd`` operations are special cases of ``TensorDot``.
``TensorDot(f, g, dimf, dimg, contf, contg)`` tensordot product ``f : g``(similar to `numpy\'s tensordot <https://docs.scipy.org/doc/numpy/reference/generated/numpy.tensordot.html>`_ in the spirit): ``f`` and ``g`` are tensors of sizes listed in ``dimf`` and ``dimg`` :ref:`index sequences <part.reservedWord>` and contracted along the dimensions listed in ``contf`` and ``contg`` :ref:`index sequences <part.reservedWord>`. The ``MatVecMult``, ``VecMatMult`` and ``TensorProd`` operations are special cases of ``TensorDot``.
============================================== ====================================================================================================================================================================================================================================================================================

Symbolic gradients:
Expand All @@ -194,7 +195,7 @@ The operations that can be used to reduce an array are described in the followin
code name arguments mathematical expression remarks
(reduction over j)
========================= ===================== ============================================================================================================================ =========================================================================
``Sum`` ``f`` :math:`\sum_j f_{ij}`
``Sum`` ``f`` :math:`\sum_j f_{ij}`
``Max_SumShiftExp`` ``f`` (scalar) :math:`(m_i,s_i)` with :math:`\left\{\begin{array}{l}m_i=\max_j f_{ij}\\s_i=\sum_j\exp(f_{ij}-m_i)\end{array}\right.` - core KeOps reduction for ``LogSumExp``.
- gradient is a pseudo-gradient, should not be used by itself
``LogSumExp`` ``f`` (scalar) :math:`\log\left(\sum_j\exp(f_{ij})\right)` only in Python bindings
Expand All @@ -209,7 +210,7 @@ code name arguments mathematical expression
``ArgMax`` ``f`` :math:`\text{argmax}_j f_{ij}` gradient returns zeros
``Max_ArgMax`` ``f`` :math:`\left(\max_j f_{ij},\text{argmax}_j f_{ij}\right)` no gradient
``KMin`` ``f``, ``K`` (int) :math:`\begin{array}{l}\left[\min_j f_{ij},\ldots,\min^{(K)}_jf_{ij}\right] no gradient
\\(\min^{(k)}\text{means k-th smallest value})\end{array}`
\\(\min^{(k)}\text{means k-th smallest value})\end{array}`
``ArgKMin`` ``f``, ``K`` (int) :math:`\left[\text{argmin}_jf_{ij},\ldots,\text{argmin}^{(K)}_j f_{ij}\right]` gradient returns zeros
``KMin_ArgKMin`` ``f``, ``K`` (int) :math:`\left([\min^{(1...K)}_j f_{ij} ],[\text{argmin}^{(1...K)}_j f_{ij}]\right)` no gradient
========================= ===================== ============================================================================================================================ =========================================================================
Expand Down
4 changes: 2 additions & 2 deletions doc/cpp/generic-syntax.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Next we define the type of reduction that we want to perform, as follows:
auto Sum_f = Sum_Reduction(f,0);


This means that we want to perform a sum reduction over the "j" indices, resulting in a "i"-indexed output.
This means that we want to perform a sum reduction over the "j" indices, resulting in an "i"-indexed output.
We would use ``Sum_Reduction(f,1)`` for a reduction over the "i" indices.

The list of available reductions is given in the following table: :ref:`part.reduction`. The code name of the reduction must be followed by ``_Reduction`` in C++ code.
Expand All @@ -39,7 +39,7 @@ The convolution operation is then performed using one of these three calls:
EvalRed<GpuConv1D_FromHost>(Sum_f,Nx, Ny, pres, params, px, py, pu, pv, pb);
EvalRed<GpuConv2D_FromHost>(Sum_f,Nx, Ny, pres, params, px, py, pu, pv, pb);

where ``pc``, ``pp``, ``pa``, ``px``, and ``py`` are pointers to their respective arrays in (Cpu) memory, ``pc`` denoting the output. These three functions correspond to computations performed repectively on the Cpu, on the Gpu with a "1D" tiling algorithm, and with a "2D" tiling algorithm.
where ``pc``, ``pp``, ``pa``, ``px``, and ``py`` are pointers to their respective arrays in (Cpu) memory, ``pc`` denoting the output. These three functions correspond to computations performed respectively on the Cpu, on the Gpu with a "1D" tiling algorithm, and with a "2D" tiling algorithm.

For a minimal working example code, see the files
`./keops/examples/test_simple.cpp <https://github.com/getkeops/keops/tree/master/keops/examples/test_simple.cpp>`_ and
Expand Down
2 changes: 1 addition & 1 deletion doc/formulas/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Generic formulas
========================

The two previous sections have higlighted the need for **efficient
The two previous sections have highlighted the need for **efficient
Map-Reduce GPU routines** in data sciences. To complete our guided tour of
the inner workings of the KeOps library, we now explain how
**generic reductions and formulas** are encoded within our C++
Expand Down
Loading