Skip to content

Commit c6d7a67

Browse files
committed
add references to sparse section
1 parent dc2bb4d commit c6d7a67

File tree

5 files changed

+54
-10
lines changed

5 files changed

+54
-10
lines changed

docs_input/api/linalg/matvec/matmul.rst

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ is supported for any tensor with a rank higher than 2.
1313
.. doxygenfunction:: matmul(const OpA &A, const OpB &B, float alpha = 1.0, float beta = 0.0)
1414
.. doxygenfunction:: matmul(const OpA &A, const OpB &B, const int32_t (&axis)[2], float alpha = 1.0, float beta = 0.0)
1515

16+
For information on experimental sparse tensor support for Sparse-Matrix x Matrix (SpMM), please see :ref:`_sparse_tensor_api`.
17+
1618
Examples
1719
~~~~~~~~
1820

docs_input/api/linalg/other/solve.rst

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.. _solve_func:
2+
3+
solve
4+
=====
5+
6+
Solves the system of equations AX=Y, where X is the unknown.
7+
8+
.. doxygenfunction:: solve(const OpA &A, const OpB &B)
9+
10+
Currently only supported for sparse matrix A, please see :ref:`_sparse_tensor_api`.

docs_input/basics/creation.rst

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ to pick up the syntax quickly without understanding the underlying architecture.
88
it lacks flexibility and can prevent your code from running at the highest performance possible. This document walks through the
99
different ways to construct tensors, and when you should use certain methods over others.
1010

11+
For information on creating the still experimental sparse tensors, please see :ref:`_sparse_tensor_api`.
12+
1113
A Quick Primer On MatX Types
1214
----------------------------
1315
The basic type of tensor used in most examples and tests is the ``tensor_t`` object. ``tensor_t`` is the highest-level tensor class, and

docs_input/basics/sparse_tensor.rst

+39-10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _sparse_tensor_api:
2+
13
Sparse Tensor Type
24
##################
35

@@ -89,8 +91,8 @@ operations for sparse-to-dense, dense-to-sparse, matmul, and solve::
8991

9092
(A = sparse2dense(Acoo)).run(exec);
9193
(Acoo = dense2sparse(D)).run(exec);
92-
(C = matmul(Acoo, B)).run(exec);
93-
(X = solve(Acsr, Y)).run(exec); // CSR only
94+
(C = matmul(Acoo, B)).run(exec); // only Sparse-Matrix x Matrix (SpMM)
95+
(X = solve(Acsr, Y)).run(exec); // only on CSR format
9496

9597
We expect the assortment of supported sparse operations and storage
9698
formats to grow if the experimental implementation is well-received.
@@ -150,6 +152,32 @@ to where the tensor is being used, including device memory, managed memory,
150152
and host memory. MatX sparse tensors are very similar to e.g. SciPy's or
151153
cuPy sparse arrays.
152154

155+
The implementation of the UST follows the MatX design philosophy of using
156+
a header-only, ``constexpr``-heavy, templated approach, which facilitates
157+
applications to only compile what is used, and nothing more.
158+
The ``sparse_tensor_t`` type is essentially the following class,
159+
where the tensor format ``TF`` is part of the template::
160+
161+
template <typename VAL, typename CRD, typename POS, typename TF, ...>
162+
class sparse_tensor_t : public detail::tensor_impl_t<...> {
163+
164+
static constexpr int DIM = TF::DIM;
165+
static constexpr int LVL = TF::LVL;
166+
167+
private:
168+
// Primary storage of sparse tensor (explicitly stored element values).
169+
StorageV values_;
170+
171+
// Secondary storage of sparse tensor (coordinates and positions).
172+
StorageC coordinates_[LVL];
173+
StorageP positions_[LVL];
174+
}
175+
176+
Using this design, many tests (e.g. is this tensor in COO format)
177+
evaluate as ``constexpr`` at compile-time, keeping the binary
178+
size restricted to only what is actually used in a MatX computation.
179+
180+
153181
Matx Implementation of the Tensor Format DSL
154182
--------------------------------------------
155183

@@ -237,14 +265,15 @@ Historical Background of the UST Type
237265
-------------------------------------
238266

239267
The concept of the UST type has its roots in sparse compilers, first pioneered
240-
for sparse linear algebra in [`B&W95`_, `Bik96`_, `Bik98`_] and formalized to
241-
sparse tensor algebra in [`Kjolstad20`_, `Chou22`_, `Yadav22`_]. The tensor
242-
format DSL for the UST type, including the generalization to higher-dimensional
243-
levels, was introduced in [`MLIR22`_, `MLIR`_]. Please refer to this literature
244-
for a more extensive presentation of all topics only briefly discussed in this
245-
online documentation.
246-
247-
.. _B&W95: https://dl.acm.org/doi/10.1145/169627.169765
268+
for sparse linear algebra in [`B&W95`_, `B&W96`_, `Bik96`_, `Bik98`_] and
269+
formalized to sparse tensor algebra in [`Kjolstad20`_, `Chou22`_, `Yadav22`_].
270+
The tensor format DSL for the UST type, including the generalization to
271+
higher-dimensional levels, was introduced in [`MLIR22`_, `MLIR`_]. Please
272+
refer to this literature for a more extensive presentation of all topics only
273+
briefly discussed in this online documentation.
274+
275+
.. _B&W95: https://dl.acm.org/doi/10.1006/jpdc.1995.1141
276+
.. _B&W96: https://ieeexplore.ieee.org/document/485501
248277
.. _Bik96: https://theses.liacs.nl/1315
249278
.. _Bik98: https://dl.acm.org/doi/10.1145/290200.287636
250279
.. _Chou22: http://tensor-compiler.org/files/chou-phd-thesis-taco-formats.pdf

docs_input/basics/tensor.rst

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ contains only types that are available on both the host and device, and provides
2222
needed for device code.
2323

2424
For information on creating tensors, please see :ref:`creating` or :ref:`quickstart` for common usage.
25+
For information on experimental sparse tensor support, please see :ref:`_sparse_tensor_api`.
2526

2627
.. doxygenclass:: matx::tensor_t
2728
:members:

0 commit comments

Comments
 (0)