diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..07e76ee --- /dev/null +++ b/.gitignore @@ -0,0 +1,117 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# Generated C code +*.c + +# C extensions +*.so + +# Vi +*.swp +*.swo + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ + +# PyCharm +.idea + +# Mac +.DS_Store diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..a0cba38 --- /dev/null +++ b/LICENSE @@ -0,0 +1,29 @@ +BSD 3-Clause License + +Copyright (c) 2022, GraphBLAS +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..31a1f1f --- /dev/null +++ b/README.md @@ -0,0 +1,40 @@ +# Binary Sparse Format Specification +This is part of a new effort to create a binary storage format for storing sparse matrices and other sparse data to disk. + +Minutes from our meetings are available [here](https://hackmd.io/0qzK4fJlQp-78t067yiYsA?view) (see also: [previous minutes](minutes)). + + + +## Specification + +[View Latest Spec](https://api.csswg.org/bikeshed/?url=https://raw.githubusercontent.com/GraphBLAS/binsparse-specification/main/spec/latest/index.bs) + +## Parsers + +Here is a table listing the current tensor frameworks that support the format: + +| Language | Framework | Status | Notes | +| -------- | ------ | ------ | ----- | +| C++ | [binsparse-reference-impl](https://github.com/GraphBLAS/binsparse-reference-impl) | under development | converts between binsparse V1.0 and custom in-memory sparse matrices | +| Julia | [Finch.jl](https://willowahrens.io/Finch.jl/dev/fileio/) | under development | converts between binsparse V1.0 and V2.0 and Finch matrices and tensors | +| Python | [binsparse-python](https://github.com/ivirshup/binsparse-python) | under development | converts between binsparse V1.0 and scipy.sparse matrices | + +### Editing + +The working version of the specification can be found under `spec/latest/index.bs`. + +The spec is written in [bikeshed](https://github.com/tabatkins/bikeshed) – a variant of markdown. +To render the spec locally: + +* Install bikeshed (ideally in an isolated environment): `pipx install bikeshed` +* Call `bikeshed spec spec/latest/index.bs` + +To render the spec online, see [api.csswg.org](https://api.csswg.org/bikeshed/), +or use the following commands: + +``` +cd binsparse-specification/spec/latest +curl https://api.csswg.org/bikeshed/ -F file=@index.bs > index.html +``` + +Rendered versions will generated for pull requests. diff --git a/binder/postBuild b/binder/postBuild new file mode 100644 index 0000000..c356031 --- /dev/null +++ b/binder/postBuild @@ -0,0 +1,3 @@ +set -ex + +pip install -e sparsetensorviz/ --no-deps diff --git a/binder/requirements.txt b/binder/requirements.txt new file mode 100644 index 0000000..4e195eb --- /dev/null +++ b/binder/requirements.txt @@ -0,0 +1,3 @@ +numpy +pandas +sphinxcontrib-svgbob diff --git a/binder/runtime.txt b/binder/runtime.txt new file mode 100644 index 0000000..9850e86 --- /dev/null +++ b/binder/runtime.txt @@ -0,0 +1 @@ +python-3.8 diff --git a/design_docs/01_rankN_arrays.md b/design_docs/01_rankN_arrays.md new file mode 100644 index 0000000..af47f3f --- /dev/null +++ b/design_docs/01_rankN_arrays.md @@ -0,0 +1,249 @@ + + + + + +
Author Erik Welch (eriknw)
Status Draft
Created Aug 26, 2022
Resolution <url> (Accepted | Rejected | Withdrawn)
+ +## Abstract + +This design document considers what is necessary to support sparse rank N arrays. We will consider a narrow scope and broad scope: +1. how to support rank 1 and 2 arrays in a way that will let us support rank N arrays in the future, and +2. how to fully support rank N arrays + +We use [TACO](http://tensor-compiler.org/) and [MLIR's sparse_tensor dialect](https://mlir.llvm.org/docs/Dialects/SparseTensorOps/) as motivation for sparse rank N arrays (or tensors), and our proposal will be fully compatible with them. + +## Motivation + +We are developing a specification for binary storage of sparse matrices and vectors. The solution will entail saving metadata and storing multiple one-dimensional arrays. Storing rank N arrays need the same things: metadata and one-dimensional arrays. So, why not try to support arrays of arbitrary dimension if it's easy to do so? This will make the binary storage format more capable. + +Many people are already familiar with existing compression schemes for arrays, including COO, CSR (or CRS), DCSC (or HyperCSC), CSF, and more. I think it would be best to reuse these names when possible to increase usability. Doing so will make our documentation clearer, and we want users who only use 1d and 2d arrays to be comfortable. Is this possible with a generic scheme that supports rank N arrays? Let's find out! + +## Detailed description + +### Rank 1 and 2 arrays + +Since we don't yet have specific proposals for how to support rank 1 and 2 arrays, this section will be speculative and constructive. + +#### Names of constituent arrays + +Using names like `rows` and `col_indices` does not scale to arbitrary rank. For example, the two arrays for CSR may typically be called `indptr` and `col_indices`, but we can use names such as `pointers_0` and `indices_1` that can be generalized to arbitrary rank. + +Here's how these arrays would be used for common structures: + +| Type | `indices_0` | `pointers_0` | `indices_1` | `axis_order` | +| -- | :--: | :--: | :--: | :--: | +| **Vector** | Yes | | | `[0]` | +| **CSR** | | Yes | Yes | `[0, 1]` | +| **CSC** | | Yes | Yes | `[1, 0]` | +| **DCSR** | Yes | Yes | Yes | `[0, 1]` | +| **DCSC** | Yes | Yes | Yes | `[1, 0]` | +| **COO** | Yes | | Yes | `[0, 1]` or `[1, 0]` | + +`pointers_i` array is used to group indices of the current dimension to the indices of the next dimension. + + + +#### Row or column orientation + +Observe that CSR and CSC both use `pointers_0` and `indices_1` in the table above, and `axis_order` is used to determine whether the array is row-major or column-major. This is also called `dimOrdering` in [MLIR sparse_tensor](https://mlir.llvm.org/docs/Dialects/SparseTensorOps/#parameters). It is necessary for `axis_order` to be a list or tuple to support different axis ordering in higher dimensions such as `axis_order=[1, 3, 0, 2]`. + +For COO, `axis_order` indicates whether `indices_0` is rows (`axis_order=[0, 1]`) or columns (`axis_order[1, 0]`). + +_Proposal:_ if the compression type (such as CSR) ends in **"R"**, then `axis_order` uses **r**egular ordering `0, 1, ..., N-1`, and if it ends in **"C"**, then `axis_order` uses **c**ontrary ordering `N-1, N-2, ... 1, 0`. + + + +#### Simplifying assumptions + +Traditionally, COO is a common and flexible format. It can often have duplicate indices, and indices may not be sorted. Other storage formats can also allow for duplicate indices or unsorted indices; for example SuiteSparse:GraphBLAS import and export of CSR allows the column indices to be unsorted. + +Let us assume that the _standard_ storage formats that we are designing will have unique indices, and the indices will be sorted lexicographically by `indices_0`, `indices_1`, etc. + +_Remark:_ it would be nice to easily allow extensions to our specification so that e.g. SuiteSparse:GraphBLAS could keep data unsorted. Data readers should fail when reading unknown extensions that break the standard storage format. + +#### Names of compression types + +Indices for a dimension may be compressed in three different ways: like COO, CSR, or DCSR. Let's give these names: + +| Name | Abbv | `indices_i` | `pointers_i` | Like | +| -- | :--: | :--: | :--: | :--: | +| **sparse** | **`S`** | Yes | | COO | +| **compressed** | **`C`** | | Yes | CSR | +| **doubly compressed** | **`DC`** | Yes | Yes | DCSR | + +- **"sparse" (`S`)** dimension indices are aligned to the indices of the following dimension (or values if the final dimension) + - `len(indices_i) == len(indices_{i+1})`, or `len(indices_i) == len(values)` if the final dimension +- **"compressed" (`C`)** dimension allows fast O(1) lookup by the index into the pointers array + - The previous dimension does not need to store `pointers_{i-1}` +- **"doubly compressed" (`DC`)** stores unique index values (so O(1) lookup isn't possible) and pointers to the next dimension + - `len(pointers_i) == len(indices_i) + 1` + +The final dimension must be "sparse" (`S`). The compression schemes for rank 2 arrays are: + +| Dim 0 | Dim 1 | Ordering | Abbv | +| :--: | :--: | :--: | :--: | +| C
compressed | S
sparse | R
`[0, 1]` | CSR | +| C
compressed | S
sparse | C
`[1, 0]` | CSC | +| DC
doubly compressed | S
sparse | R
`[0, 1]` | DCSR | +| DC
doubly compressed | S
sparse | C
`[1, 0]` | DCSC | +| S
sparse | S
sparse | R
`[0, 1]` | SSR | +| S
sparse | S
sparse | C
`[1, 0]` | SSC | + +CSR, CSC, DCSR, and DCSC are familiar and keep their original meanings. + +#### COO + +SSR and SSC in the previous table are new and are instances of COO with sorted indices and no duplicates (according to our simplifying assumptions). SSR indices are lexicographically sorted by row then column, and a backronym could be "sorted sparse rows" (or "simple" or "standard" instead of "sorted"). Conversely, SSC indices are lexicographically sorted by column then row, and a backronym could be "sorted sparse columns". + +We can consider also keeping COO as a type of compression. COO does not need to be sorted, and metadata can indicate whether or not it may have duplicate indices. + +#### Dense dimensions or multidimensional values array + +Examples of structures with dense dimensions are dense vectors, dense matrices, and sparse vectors where each value is a dense array (so it's actually a matrix). It is an open question if and how we want to handle these. It may be straightforward to support this by allowing the values array to be N-dimensional and have metadata that indicates the shape and layout. + +Per our language, we do not consider CSR to have any dense dimensions. Dense dimensions are those that can be combined into a dense, multidimensional values array. + +#### Multiple value arrays + +It may be reasonable for the same sparse structure to have multiple value arrays. This is another open design question. + +Supporting rank N arrays probably doesn't constrain how we may support having multiple value arrays. A potential complication is when one values array is a scalar per element, and another is an array per element. + +#### Attributes + +It may be useful to store attributes such as `is_symmetric`, `is_structure_symmetric`, `is_upper_triangular`, `ndiag`, etc. It may be more complicated to have attributes like this in a way that generalizes to higher dimensions. + +### Rank N arrays + +#### Names of constituent arrays + +Use `indices_0`, `pointers_0`, `indices_1`, `pointers_1`, ..., `indices_{N-1}`. + +#### Dimension order + +Use `axis_order` with the same semantics as `dimOrdering` in MLIR sparse tensor dialect. + + + +We can reuse "R" to mean regular ordering `axis_order=[0, 1, ..., N-1]` and "C" to mean contrary ordering `axis_order=[N-1, N-2, ..., 1, 0]`. Perhaps we can use "X" to indicate any other ordering. + +#### Compression types + +The last dimension must be "sparse" (`S`). All other dimensions may be sparse (`S`), compressed (`C`), or doubly compressed (`DC`). This fully supports the TACO and MLIR sparse tensor formats. + +For larger dimensions, it is sometimes more clear to separate the abbreviated structure with hyphens. For example, `C-DC-S-S-R` instead of `CDCSSR`. + +**Examples:** + +**`DC-DC-DC-S`** + +![](img/DC-DC-DC-S.svg) + +**`S-C-DC-S`** + +![](img/S-C-DC-S.svg) + +See more examples of different compression types on a rank 4 array here: + +https://nbviewer.org/github/GraphBLAS/binsparse-specification/blob/main/spz_python/notebooks/Example_Rank4.ipynb + +#### COO + +As with rank 2, we can support sorted COO without duplicates as e.g. SSSSSSR. + +We can consider supporting rank N COO that is unsorted and may have duplicates. + +#### Dense dimensions or multidimensional values array + +Probably no change necessary to support rank N. + +This is important to support in order to fully match TACO and MLIR sparse tensor. + +This is also necessary to support semi-COO (sCOO): +- ["Optimizing Sparse Tensor Times Matrix on +Multi-core and Many-core Architectures" by Jiajia Li, et al +](http://fruitfly1026.github.io/static/files/sc16-ia3.pdf) + +#### Multiple value arrays + +Probably no change necessary to support rank N. + +#### Different jargon + +Sparse compression of rank N arrays is an active area of research, and users of that community may prefer the use of different jargon. For example, _modes_ (the order of dimensions), _fibers_, and _slices_. Also, _tensor_ is generally understood to be a multidimensional array, but may have different meanings for physicists, mathematicians, Python users (e.g., a tensor is an N-D array that can use GPUs), etc. + +#### Chunking strategies + +Not determined for ranks 1 and 2 yet, but probably little to no change necessary to support rank N. + +We may want to consider whether our strategy can support HiCOO: +- https://sc17.supercomputing.org/SC17%20Archive/tech_poster/poster_files/post213s2-file3.pdf +- http://fruitfly1026.github.io/static/files/sc18-li.pdf + +### Differences from TACO and MLIR sparse tensor + +Our proposal uses different naming schemes than TACO and MLIR sparse tensor, which use: + +| Type | Dim 0 | Dim 1 | +| -- | :--: | :--: | +| CSR | dense | compressed | +| DCSR | compressed | compressed | +| DCSR (alt) | singleton | compressed | +| COO | singleton | singleton | + +- "dense" dimensions store no arrays +- "compressed" dimension store `pointers_i` and `indices_i` arrays +- "singleton" dimension store `indices_i` arrays + +Note that TACO does not support "singleton" compression, and "singleton" may not be fully supported yet in MLIR sparse tensor. + +The main difference from our proposal is the use of `pointer_i`. In TACO and MLIR sparse tensor, `pointers_i` groups the _previous_ indices to the current indices. In our proposal, `pointers_i` groups the current indices to the _next_ indices. + +In TACO, DCSR is constructed using "compressed", "compressed" dimensions. This results in _two_ `pointers` arrays, which is not standard DCSR. Only one `pointers` array is necessary. In MLIR, there are two ways to specify DCSR arrays. Our proposal only has one way to specify DCSR, and it does not have an extra, unnecessary `pointers` array. + +It is straightforward to convert from our specification to MLIR sparse tensor specification with only "compressed" and "dense" dimensions: +1. Increment `pointers` arrays, so e.g. `pointers_0` becomes `mlir_pointers_1` +2. If a dimension has both `mlir_pointers_i` and `indices_i`, then it is MLIR's "compressed" +3. If a dimension has only `indices_i`, then it is MLIR's "singleton" +4. If a dimension does not have `mlir_pointers_i` or `indices_i`, then it is MLIR's "dense" + +Converting to TACO-style with "singleton" and "compressed-nonunique" is signficantly more difficult. + +### Extensions + +#### Multigraph support + +It would be easy support multigraphs, which can have multiple edges between nodes. This is done by allowing duplicate indices so an index can have multiple values. COO naturally supports this. Other formats can as well. + +Our proposal needs two changes to support multigraphs: +1. Allow the final dimension to be "compressed" (`C`) or "doubly compressed" (`DC`) where the pointers group indices to values +2. Add a flag to the global metadata to indicate whether there may be duplicate indices + +Observe that this is a natural, "obvious" consequence of our proposal, whereas TACO and MLIR sparse tensor cannot support multigraphs like this without adding another dimension. + +This gives us two more compression types for vectors ("compressed" and "doubly compressed"), and 12 more compression types for matrices (`SCR`, `SDCR`, `CCR`, `CDCR`, `DCCR`, `DCDCR` and the columnwise variants). These should only be used for multigraphs. + +#### Unsorted dimensions + +Indices in "sparse" and "doubly compressed" dimensions do not need to be sorted, but `pointers` boundaries must still be respected. For example, import and export in SuiteSparse:GraphBLAS supports unsorted column indices within each row for CSR and DCSR. + +If there are multiple sequential "sparse" dimensions (such as COO), only the first one needs to indicate that it is unsorted. This is because sortedness only applies to indices between pointers; for example, column indices for a given row in CSR are between pointers. Furthermore, if a "sparse" dimension _did_ store pointers, it would be `[0, 1, 2, ..., N]`, which means there is only one index in the next dimension that is grouped between pointers, and sortedness of a single element is extraneous. + +This could be supported by adding a flag to each "sparse" and "doubly compressed" dimension. + +#### Balanced CSF + +This is an extension to "doubly compressed" dimensions based on B-CSF in ["Load-Balanced Sparse MTTKRP on GPUs" by Israt Nisa, et al](https://arxiv.org/pdf/1904.03329.pdf). It allows indices in "doubly compressed" dimensions to be duplicated in order for subtrees to be more comparably sized. + +This could be supported by adding a flag to each "doubly compressed" dimension. + +#### Different sub-tree compressions + +Sometimes compression can be improved by using different compression schemes for different groups of indices. Examples: + +- HB-CSF: https://arxiv.org/pdf/1904.03329.pdf +- MM-CSF: https://par.nsf.gov/servlets/purl/10172913 + +This may be challenging or complicated to support. + diff --git a/design_docs/img/DC-DC-DC-S.svg b/design_docs/img/DC-DC-DC-S.svg new file mode 100644 index 0000000..3108232 --- /dev/null +++ b/design_docs/img/DC-DC-DC-S.svg @@ -0,0 +1,253 @@ + + + + + + + + + + + + + + + + + + + + + i0 + + i1 + + i2 + + i3 + p0 + p1 + p2 + + + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 2 + 2 + 1 + 0 + 0 + 2 + 2 + 4 + 1 + 0 + 3 + 5 + 1 + 1 + 1 + 0 + 3 + 4 + 1 + 2 + 8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/design_docs/img/S-C-DC-S.svg b/design_docs/img/S-C-DC-S.svg new file mode 100644 index 0000000..bd3279c --- /dev/null +++ b/design_docs/img/S-C-DC-S.svg @@ -0,0 +1,276 @@ + + + + + + + + + + + + + + + + + + + + + i0 + + i1 + + i2 + + i3 + + 0 + + 1 + + 1 + p0 + p1 + p2 + + + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 1 + 2 + 2 + 0 + 0 + 0 + 2 + 2 + 4 + 1 + 0 + 1 + 0 + 3 + 3 + 5 + 3 + 1 + 1 + 0 + 4 + 4 + 1 + 2 + 8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/index.html b/index.html new file mode 100644 index 0000000..1a38b64 --- /dev/null +++ b/index.html @@ -0,0 +1,1390 @@ + + + + + Binary Sparse Format Specification Version 0.1 + + + + + + + + + + + + + + +
+

+

Binary Sparse Format Specification Version 0.1

+

Unofficial Proposal Draft,

+
+ More details about this document +
+
+
This version: +
http://example.com/url-this-spec-will-live-at +
Issue Tracking: +
GitHub +
Editors: +
Benjamin Brock (Intel) +
Tim Davis (Texas A&M) +
Jim Kitchen (Anaconda) +
Erik Welch (NVIDIA) +
Isaac Virshup (Helmholtz Munich) +
Willow Ahrens (MIT) +
+
+
+
+ +
+
+
+

Abstract

+

A cross-platform binary storage format for sparse data, particularly sparse matrices.

+
+

Status of this document

+
+

+
+
+ +
+

1. Introduction

+

The Binsparse Specification (name tentative) provides a cross-platform format +for efficiently storing data, particularly sparse multidimensional arrays, in +binary format. Binsparse is designed to be both a standalone and embeddable +format. It consists of two parts:

+ +

Both the descriptor and binary arrays are stored in a supported binary container.

+

2. Definitions

+

Binsparse is intended to support multidimensional sparse arrays, meaning arrays +in which not every location has a value. We refer to each location in the array +with a value as a stored value. Stored values have associated with them a scalar value, which is the value stored in that location in the array, and one +or more indices, which describe the location where the stored value is located +in the array. Some or all of these indices may be stored explicitly, or they may +be implicitly derived, depending on storage format. When stored explicitly, +indices are 0-based positive integers.

+

3. Binsparse JSON Descriptors

+

Binsparse descriptors are key-value metadata that describe the binary format of sparse +data. The key-value data is namespaced as "binsparse" to avoid any conflict with other +metadata in the container. The required entries in the "binsparse" entry are listed +below. Optional attributes may be defined to hold additional metadata and must be stored +outside of the "binsparse" namespace.

+
+ +

Example of a JSON descriptor for a compressed-sparse column (CSC) matrix with 10 +rows and 12 columns, containing float32 values, along with user-defined +attributes.

+
{
+  "binsparse": {
+    "version": "0.1",
+    "format": "CSC",
+    "shape": [10, 12],
+    "data_types": {
+      "pointers_to_1": "uint64",
+      "indices_1": "uint64",
+      "values": "float32"
+    }
+  },
+  "original_source": "https://url/of/original/file.mtx",
+  "author": "John Doe"
+}
+
+
+

3.1. Version

+

Version indicates the version of the Binsparse specification used here. +This is a two digit specifier of the form major.minor. +Any minor updates should be backwards compatible with the previous version, e.g. must be a superset of the previous versions within the major release series. +Major versions may break backwards compatibility.

+

3.2. Shape

+

The shape key must be present and shall define the shape of the sparse tensor. +It shall contain a JSON array of integers, with index i containing the size of +the i'th dimension. For matrices, index 0 shall contain the number of rows, +and index 1 shall contain the number of columns. For vectors, index 0 shall +contain the vector’s dimension.

+

Note: a matrix has shape [number_of_rows, number_of_columns] regardless of whether +the format orientation is row-wise or column-wise.

+

3.3. Fill

+ The fill key may be present. If the fill key is present, it shall have a +boolean value. If the value is true, it signifies the presence of a fill_value array, whose single element defines the value at indices not specified +by the sparse tensor structure. +

3.4. Format

+

The format key must be present and shall describe the binary storage format +of dense arrays used to represent the sparse array. The format +defined by the format key determines the named binary arrays that shall exist +in the binary storage container.

+

3.4.1. Pre-defined Formats

+

The following is a list of all pre-defined formats and the arrays that shall +be present in the binary container. number_of_elements refers to the number +of stored values, number_of_rows refers to the number of rows, and number_of_columns refers to the number of columns.

+
3.4.1.1. DVEC
+

Dense Vector format

+
+
values +
+

Array of size number_of_elements containing stored values.

+
+

The element of the vector located at index i has scalar value values[i].

+
3.4.1.2. DMATR
+

Row-Major Dense Matrix format

+
+
values +
+

Array of size number_of_elements containing stored values.

+
+

The element of the vector located at index i, j has scalar value values[i * number_of_columns + j].

+
3.4.1.3. DMATC
+

Column-Major Dense Matrix format

+
+
values +
+

Array of size number_of_elements containing stored values.

+
+

The element of the vector located at index i, j has scalar value values[i + j * number_of_rows].

+
3.4.1.4. DMAT
+

DMAT format is an alias for § 3.4.1.2 DMATR format.

+
3.4.1.5. CVEC
+

Compressed Sparse Vector format

+
+
indices_0 +
+

Array of size number_of_elements containing indices.

+
values +
+

Array of size number_of_elements containing stored values.

+
+

The element of the vector located at index indices_0[i] has scalar value values[i]. Elements shall be sorted by index and must not be duplicated.

+
3.4.1.6. CSR
+

Compressed-Sparse Row format

+
+
pointers_to_1 +
+

Array of size number_of_rows + 1 containing start and end positions by row.

+
indices_1 +
+

Array of size number_of_elements containing 0-based column indices.

+
values +
+

Array of size number_of_elements containing stored values.

+
+

The column indices of the stored values located in row i are located in the range [pointers_to_1[i], pointers_to_1[i+1]) in the indices_1 array. The scalar values for +each of those stored values is stored in the corresponding index in the values array.

+

Within a row, elements shall be sorted by column index and must not be duplicated.

+
3.4.1.7. CSC
+

Compressed-Sparse Column format

+
+
pointers_to_1 +
+

Array of size number_of_columns + 1 containing start and end positions by column.

+
indices_1 +
+

Array of size number_of_elements containing 0-based row indices.

+
values +
+

Array of size number_of_elements containing stored values.

+
+

The rows indices of the stored values located in column j are located in the range [pointers_to_1[j], pointers_to_1[j+1]) in the indices_1 array. The scalar values for +each of those stored values is stored in the corresponding index in the values array.

+

Within a column, elements shall be sorted by row index and must not be duplicated.

+
3.4.1.8. DCSR
+

Doubly Compressed-Sparse Row format

+
+
indices_0 +
+

Array of size number_of_nonempty_rows containing 0-based row indices corresponding + to positions within pointers_to_1.

+
pointers_to_1 +
+

Array of size number_of_nonempty_rows + 1 containing start and end positions.

+
indices_1 +
+

Array of size number_of_elements containing 0-based column indices.

+
values +
+

Array of size number_of_elements containing stored values.

+
+

DCSR is similar to CSR, except that rows which are entirely empty are not stored. pointers_to_1 contains no repeated values. Because the position within pointers_to_1 no longer dictates the +corresponding row index, indices_0 provides the row index.

+

Rows shall be sorted and must not be duplicated. +Within each row, elements shall be sorted by column index and must not be duplicated.

+
3.4.1.9. DCSC
+

Doubly Compressed-Sparse Column format

+
+
indices_0 +
+

Array of size number_of_nonempty_columns containing 0-based column indices + corresponding to positions within pointers_to_1.

+
pointers_to_1 +
+

Array of size number_of_nonempty_columns + 1 containing start and end positions.

+
indices_1 +
+

Array of size number_of_elements containing 0-based row indices.

+
values +
+

Array of size number_of_elements containing stored values.

+
+

DCSC is similar to CSC, except that columns which are entirely empty are not stored. pointers_to_1 contains no repeated values. Because the position within pointers_to_1 no longer dictates the +corresponding column index, indices_0 provides the column index.

+

Columns shall be sorted and not duplicated. +Within each column, elements shall be sorted by row index and must not be duplicated.

+
3.4.1.10. COOR
+

Row-wise Coordinate format

+
+
indices_0 +
+

Array of size number_of_elements containing 0-based row indices.

+
indices_1 +
+

Array of size number_of_elements containing 0-based column indices.

+
values +
+

Array of size number_of_elements containing stored values.

+
+

Pairs of (row index, column index) shall be sorted first by row and then by column. +Pairs must not be duplicated.

+
3.4.1.11. COOC
+

Column-wise Coordinate format

+
+
indices_0 +
+

Array of size number_of_elements containing 0-based column indices.

+
indices_1 +
+

Array of size number_of_elements containing 0-based row indices.

+
values +
+

Array of size number_of_elements containing stored values.

+
+

Pairs of (column index, row index) shall be sorted first by column and then by row. +Pairs must not be duplicated.

+
3.4.1.12. COO
+

Coordinate format is an alias for § 3.4.1.10 COOR format.

+

3.4.2. Version 2.0 only: Custom Formats

+

The contents of this section will be finalized with the release of Binsparse +V2.0, and are subject to change until then.

+

Binsparse describes custom multidimensional formats hierarchically. We can +understand these formats as arrays of arrays, where the parent array and +child arrays might use different formats. For example, we could have a dense +outer array which contains sparse inner arrays, so the first index would be +dense and the second index would be sparse. To achieve efficient storage, all +arrays in the same level are stored contiguously in a specialized datastructure +called a level.

+

A level is a collection of zero or more arrays which all have the same format. +The elements of arrays in a level may be subarrays in a sublevel. The global +array we wish to store is represented by a level that holds a single root array.

+

For example, the simplest level is the element format, which represents a +collection of scalars. We can represent a collection of dense vectors with a +dense level format. Each vector in the collection would be composed from +contiguous scalars in an element level (analogously to the numpy.stack +operator). We can represent a collection of sparse vectors using a sparse level. +The sparse level format represents sparse vectors by listing the locations of +nonzeros, and storing only the nonzero scalars inside an element level.

+

In addition to storing scalars, dense and sparse levels may themselves store +multidimensional arrays. This leads to multiple ways to store sparse matrices +and tensors. For example, a dense vector of sparse vectors is equivalent to the +CSR matrix format, and a sparse vector of sparse vectors is equivalent to the +hypersparse DCSR matrix format.

+

When defining a custom format, the outermost subformat key is defined as the +root level descriptor (a level which will only hold one array). If a level holds +many different arrays, we refer to the pth array as the array in position p.

+

Levels are row-major by default (adding an outer level adds a row dimension). +The format descriptor may optionally define a transpose key, equal to a list of +the described dimensions in the order they should appear. If the tensor we wish +to represent is A and the tensor described by the format descriptor is B, +then A[i_1, ..., i_n] = B[i_(transpose[1]), ..., i_(transpose[n])]. transpose must +be a permutation.

+

If the format key is a dictionary, the level key must be present and shall +describe the storage format of the level used to represent the sparse array.

+

The level descriptors are dictionaries defined as follows:

+
3.4.2.1. Element
+

If the level key is "element", the level represents zero or more scalars.

+
+
values +
+

Array of size number_of_positions whose pth element holds the value of the scalar at position p.

+
+
3.4.2.2. Dense
+

If the level key is "dense", the subformat key must be present. The rank key must be present, and set to an integer r greater than or equal to 1. The +dense level represents zero or more r-dimensional dense arrays whose elements +are themselves arrays specified by subformat. For example, a dense level +of +rank 2 represents a collection of dense matrices of subarrays.

+

Assuming that the level describes arrays of shape I_0, ..., I_(N - 1), the +array at position p in a dense level of rank r is an array whose slice

+

A[i_0, ..., i_(r - 1), :, ..., :]

+

is described by the row-major position

+

q = (((((p * I_0) + i_0) * I_1) + i_1) * I_2 + i_2) * ... + i_(r - 1)

+

of the sublevel.

+
3.4.2.3. Sparse
+

If the level key is "sparse", the subformat key must be present. The rank key must be present, and set to an integer r greater than or equal to 1. The sparse level represents zero or more r-dimensional sparse arrays +whose non-implicit elements are themselves arrays specified by subformat. For +example, a sparse level of rank 1 represents a collection of sparse vectors of +subarrays.

+

Assume that this level represents n-dimensional subarrays and the root array +is N-dimensional. The sparse level implies the following binary arrays are +present:

+
+
pointers_to_(N - n) +
+

Array of size number_of_positions + 1 whose 1st element is equal to 0 and whose p + 1th element is equal to the sum of pointers_to_(N - n)[p] and the number of explicitly represented slices in the pth position.

+
indices_(N - n), ..., indices(N - n + r - 1) +
+

There are r such arrays. When A[i_0, ..., i_(r - 1), :, ..., :] is explicitly represented by the subarray in position q, indices_(N-n+s)[q] = i_s. The arrays must be ordered such that the tuples (indices_(N-n)[q], ..., indices_(N-n+r-1)[q]) are unique and appear in lexicographic order for all q in each range pointers_to_(N-n)[p] <= q < pointers_to_(N-n)[p + 1]. This array must contain no other elements.

+
+

Special note: If the sparse level is the root level, the pointers array should +be ommitted, as its first value will be 0 and its last value will be the +length of any of the indices arrays in this level.

+

3.4.3. Equivalent Formats

+

The following formats are equivalent

+
3.4.3.1. DVEC
+
"format": {
+  "subformat": {
+    "level": "dense",
+    "rank": 1,
+    "subformat": {
+      "level": "element",
+    }
+  }
+}
+
+
3.4.3.2. DMATR
+
"format": {
+  "subformat": {
+    "level": "dense",
+    "rank": 1,
+    "subformat": {
+      "level": "dense",
+      "rank": 1,
+      "subformat": {
+        "level": "element",
+      }
+    }
+  }
+}
+
+
3.4.3.3. DMATC
+
"format": {
+  "transpose": [1, 0],
+  "subformat": {
+    "level": "dense",
+    "rank": 1,
+    "subformat": {
+      "level": "dense",
+      "rank": 1,
+      "subformat": {
+        "level": "element",
+      }
+    }
+  }
+}
+
+
3.4.3.4. CVEC
+
"format": {
+  "subformat": {
+    "level": "sparse",
+    "rank": 1,
+    "subformat": {
+      "level": "element",
+    }
+  }
+}
+
+
3.4.3.5. CSR
+
"format": {
+  "subformat": {
+    "level": "dense",
+    "rank": 1,
+    "subformat": {
+      "level": "sparse",
+      "rank": 1,
+      "subformat": {
+        "level": "element",
+      }
+    }
+  }
+}
+
+
3.4.3.6. CSC
+
"format": {
+  "transpose": [1, 0],
+  "subformat": {
+    "level": "dense",
+    "rank": 1,
+    "subformat": {
+      "level": "sparse",
+      "rank": 1,
+      "subformat": {
+        "level": "element",
+      }
+    }
+  }
+}
+
+
3.4.3.7. DCSR
+
"format": {
+  "subformat": {
+    "level": "sparse",
+    "rank": 1,
+    "subformat": {
+      "level": "sparse",
+      "rank": 1,
+      "subformat": {
+        "level": "element",
+      }
+    }
+  }
+}
+
+
3.4.3.8. DCSC
+
"format": {
+  "transpose": [1, 0],
+  "subformat": {
+    "level": "sparse",
+    "rank": 1,
+    "subformat": {
+      "level": "sparse",
+      "rank": 1,
+      "subformat": {
+        "level": "element",
+      }
+    }
+  }
+}
+
+
3.4.3.9. COOR
+
"format": {
+  "subformat": {
+    "level": "sparse",
+    "rank": 2,
+    "subformat": {
+      "level": "element",
+    }
+  }
+}
+
+
3.4.3.10. COOC
+

Column-wise Coordinate format

+
"format": {
+  "transpose": [1, 0],
+  "subformat": {
+    "level": "sparse",
+    "rank": 2,
+    "subformat": {
+      "level": "element",
+    }
+  }
+}
+
+

3.5. Data Types

+

The data_types key must be present and shall define the data types of all required +arrays based on the § 3.4 Format. The data type declares the type of both the +on-disk array as well as the in-memory array.

+

For a given § 3.4 Format, all named binary arrays for that format shall have a +corresponding name in data_types.

+

The following strings shall be used to describe data types:

+
+
"uint8" +
+

unsigned 8-bit integer

+
"uint16" +
+

unsigned 16-bit integer

+
"uint32" +
+

unsigned 32-bit integer

+
"uint64" +
+

unsigned 64-bit integer

+
"int8" +
+

signed 8-bit integer

+
"int16" +
+

signed 16-bit integer

+
"int32" +
+

signed 32-bit integer

+
"int64" +
+

signed 64-bit integer

+
"float32" +
+

IEEE binary32 floating point number

+
"float64" +
+

IEEE binary64 floating point number

+
"bint8" +
+

An unsigned 8-bit integer, to be reinterpreted as a Boolean number, however +that is represented in the host language. The value 0 shall map to false and the +value 1 shall map to true. When parsing, implementations may choose to interpret +values other than 0 or 1 as true, or throw an error.

+
+

3.6. Value Modifiers

+

When the value array is meant to be reinterpreted before reading, a special bracket syntax is +provided to indicate modifications to the underlying element level.

+

3.6.1. Complex Values (complex)

+

When a value array is composed of alternating real and imaginary components of +complex numbers, the type is written as complex[<type>]. For example, a value +array of complex float64 would have a datatype of complex[float64] The real +component of the ith element in the modified array shall be stored at position 2i in the original array, and the imaginary component of the ith element in +the modified array shall be at position 2i + 1 in the underlying array. +The complex value modifier may only be used with the types float32 and float64.

+

3.6.2. All Values the Same (ISO)

+

When all values of a sparse array are the same identical value, the type is +written as iso[<type>]. This indicates that the array will store only a single +element which is common to all stored indices. All elements in the modified +array shall be stored at position 0 of the underlying array.

+
+ +

Example of a CSR Matrix whose values are all 7.

+ + + + + + + + + +
+ 0 + 1 + 2 + 3 + 4 +
0 + . + . + . + 7 + . +
1 + . + 7 + . + . + 7 +
2 + . + . + . + . + . +
3 + . + 7 + 7 + . + . +
4 + . + . + . + 7 + . +
+
{
+  "version": "0.1",
+  "format": "CSR",
+  "shape": [5, 5],
+  "data_types": {
+    "pointers_to_1": "uint64",
+    "indices_1": "uint64",
+    "values": "iso[int8]"
+  }
+}
+
+ +
+

Note: Structure-only matrices (allowed in matrix market format) can be stored + using this technique with a value of 1. This adds only a small amount of + overhead while describing essentially the same matrix.

+

3.7. Structure

+ The structure key, if present, denotes a special matrix structure in which +only one triangle of the matrix is stored and the structure and values in the +other triangle are inferred. +

3.7.1. Pre-Defined Structures

+

The follow pre-defined values can be supplied for the structure key to indicate +the structure of the matrix.

+
3.7.1.1. symmetric_lower
+

The symmetric_lower value indicates that the matrix has a symmetric structure +with only the lower triangle stored. For all matrix entries with row and column +indices i,j and value v, i >= j. If i != j, the entry implies the +presence of an entry at row and column index j,i with value v.

+
3.7.1.2. symmetric_upper
+

The symmetric_upper value indicates that the matrix has a symmetric structure +with only the upper triangle stored. For all matrix entries with row and column +indices i,j and value v, i <= j. If i != j, the entry implies the +presence of an entry at row and column index j,i with value v.

+
3.7.1.3. hermitian_lower
+

The hermitian_lower value indicates that the matrix has a Hermitian structure +with only the lower triangle stored. For all matrix entries with row and column +indices i,j and value v, i >= j. If i != j, the entry implies the +presence of an entry at row and column index j,i with a value equal to the +complex conjugate of v. The matrix’s value type must be complex.

+
3.7.1.4. hermitian_upper
+

The hermitian_upper value indicates that the matrix has a Hermitian structure +with only the upper triangle stored. For all matrix entries with row and column +indices i,j and value v, i <= j. If i != j, the entry implies the +presence of an entry at row and column index j,i with a value equal to the +complex conjugate of v. The matrix’s value type must be complex.

+
3.7.1.5. skew_symmetric_lower
+

The skew_symmetric_lower value indicates that the matrix has a skew-symmetric structure +with only the lower triangle stored. For all matrix entries with row and column +indices i,j and value v, i >= j. If i != j, the entry implies the +presence of an entry at row and column index j,i with value -v.

+
3.7.1.6. skew_symmetric_upper
+

The symmetric_upper value indicates that the matrix has a skew-symmetric structure +with only the upper triangle stored. For all matrix entries with row and column +indices i,j and value v, i <= j. If i != j, the entry implies the +presence of an entry at row and column index j,i with value -v.

+
+ +

Example of a symmetric CSR matrix.

+ + + + + + + + + +
+ 0 + 1 + 2 + 3 + 4 +
0 + 1 + . + . + . + . +
1 + 2 + 9 + . + . + . +
2 + 7 + . + 2 + . + . +
3 + . + 2 + . + 3 + . +
4 + . + . + 3 + . + 7 +
+
{
+  "version": "0.1",
+  "format": "CSR",
+  "shape": [5, 5],
+  "structure": "symmetric_lower",
+  "data_types": {
+    "pointers_to_1": "uint64",
+    "indices_1": "uint64",
+    "values": "int8"
+  }
+}
+
+ +
+

4. Binary Containers

+ Binary containers must store binary arrays in a standardized, cross-platform +manner, using the corresponding dataset names previously defined. +

4.1. Supported Binary Containers

+

Currently supported binary containers include HDF5 and NetCDF (but should include more).

+
+
+

Conformance

+

Document conventions

+

Conformance requirements are expressed + with a combination of descriptive assertions + and RFC 2119 terminology. + The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” + in the normative parts of this document + are to be interpreted as described in RFC 2119. + However, for readability, + these words do not appear in all uppercase letters in this specification.

+

All of the text of this specification is normative + except sections explicitly marked as non-normative, examples, and notes. [RFC2119]

+

Examples in this specification are introduced with the words “for example” + or are set apart from the normative text + with class="example", + like this:

+
+ +

This is an example of an informative example.

+
+

Informative notes begin with the word “Note” + and are set apart from the normative text + with class="note", + like this:

+

Note, this is an informative note.

+

Conformant Algorithms

+

Requirements phrased in the imperative as part of algorithms + (such as "strip any leading space characters" + or "return false and abort these steps") + are to be interpreted with the meaning of the key word + ("must", "should", "may", etc) + used in introducing the algorithm.

+

Conformance requirements phrased as algorithms or specific steps + can be implemented in any manner, + so long as the end result is equivalent. + In particular, the algorithms defined in this specification + are intended to be easy to understand + and are not intended to be performant. + Implementers are encouraged to optimize.

+
+ +

References

+

Normative References

+
+
[RFC2119] +
S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. March 1997. Best Current Practice. URL: https://datatracker.ietf.org/doc/html/rfc2119 +
\ No newline at end of file diff --git a/minutes/2022-08-10.md b/minutes/2022-08-10.md new file mode 100644 index 0000000..7da8b84 --- /dev/null +++ b/minutes/2022-08-10.md @@ -0,0 +1,86 @@ +# Binary Sparse Format Working Group Meeting #1 - August 10, 2022 + +## Attendees +- [X] Ben Brock +- [X] Tim Davis +- [X] Jim Kitchen +- [X] Tim Mattson +- [ ] Scott McMillan +- [X] Erik Welch +- [X] Isaac Virshup + +## Agenda + +- Discuss the possibility of creating a binary storage format for sparse data. +- Establish a general course of direction for creating a spec, enumerate desired features. + +## Summary of Discussion + +It was pointed out that there are two components that need to be created, based +on the proposed approach in Erik Welch's HPEC keynote, which proposed JSON metadata +segment describing the sparse matrix layout combined with a series of binary +blobs. + +1. The specification for valid metadata. This includes supported formats (CSR, + COO, Dense, etc.), as well as which types of data are supported (vectors, matrices, + n-dimensional tensors) and the specific syntax to be used. + +2. How this metadata maps on to the stored binary blobs, as well as how they are + actually stored. + This gets into implementation details (are we using HDF5, Zarr, or some other + storage format). + +We began by enumerating some of the storage options available. + +- HDF5 +- Zarr +- ASDF +- Possibly others + +As well as the features we would like to see supported by any future spec. +We established that a version 1.0 of any spec would likely support storing: + +- Vectors, presumably with sparse and dense formats +- Matrices with a variety of sparse storage formats +- N-D Tensors, initially limited to COO, but likely CSF in future versions + +The following matrix formats were discussed: +- COO +- CSR +- CSR +- Hyper CSR (DCSR) +- Hyper COO (DCSC) +- ISO or single-value matrix +- Dense mask (?) + +We discussed various implementation complexities of a dense mask format, which +may leave it to be left out of an initial spec. + +We discussed the important of supporting blocked formats, which could potentially +allow for very efficient loading and storing on distributed memory systems. + +We discussed the complexities of supporting user-defined (and even built-in) types. +We concluded that we should depend on a binary storage library like HDF5 to handle +this for us. Some storage formats, like potentially Zarr, may allow the use of +user-defined types. + +We discussed the need to support different varieties of index types, at least +encompassing C integer types. + +We discussed TileDB's sparse storage format, acknowledging that we should perhaps +take its design into consideration, but that certain aspects are not compatible +with our vision for supporting multiple sparse matrix formats. + +Ben expressed interest in developing a prototype implementation for C++. Jim Kitchen +expressed interest in expanding on his prototype implementation in Python. Tim Davis +expressed interest in supporting a cross-platform binary spec in SuiteSparse and +possibly providing the format in the SuiteSparse Collection once the spec becomes mature. + +## Outcomes +- Ben to open new GitHub repo for developing and discussing binary sparse format specification. + +- We will begin by agreeing on a feature set on GitHub, then working on the spec + as prototype implementations develop. + +- The calendar invite will be updated to once monthly, with the possibility of + meeting sooner if there is progress on the GitHub. diff --git a/minutes/2022-09-07-strawman.html b/minutes/2022-09-07-strawman.html new file mode 100755 index 0000000..f891761 --- /dev/null +++ b/minutes/2022-09-07-strawman.html @@ -0,0 +1,15460 @@ + + + + + +2022-09-07-strawman + + + + + + + + + + + + + + + + + + + + + +
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+ + + + + + + + + diff --git a/minutes/2022-09-07-strawman.ipynb b/minutes/2022-09-07-strawman.ipynb new file mode 100644 index 0000000..5b37336 --- /dev/null +++ b/minutes/2022-09-07-strawman.ipynb @@ -0,0 +1,962 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "a943b110-2ee1-47d1-93d6-f040f8f63041", + "metadata": {}, + "source": [ + "- **Author:** [Erik Welch](https://github.com/eriknw)\n", + "- **Date:** 2022-09-07\n", + "- **Purpose:** Strawman proposal to help discuss [PR #3](https://github.com/GraphBLAS/binsparse-specification/pull/3)\n", + "and its [proposal](https://github.com/GraphBLAS/binsparse-specification/blob/main/design_docs/01_rankN_arrays.md)\n", + "- https://github.com/GraphBLAS/binsparse-specification" + ] + }, + { + "cell_type": "markdown", + "id": "506a97f3", + "metadata": {}, + "source": [ + "# High level perspective\n", + "\n", + "Let's call our binary sparse storage format `binsparse` in this document.\n", + "\n", + "For high level design, let's assume we will use existing data storage formats that can store **metadata** and **arrays** including the shape and data type of arrays:\n", + "```mermaid\n", + "flowchart TB\n", + " high[binsparse: high level metadata]-->mid[containers for metadata and arrays]-->low[(files)]\n", + "```\n", + "Example data storage formats:\n", + "```mermaid\n", + "flowchart TB\n", + " binsparse-->NetCDF4\n", + " binsparse-->HDF5\n", + " binsparse-->Zarr\n", + " binsparse-->n5\n", + " binsparse-->ASDF\n", + " binsparse<-->anndata\n", + "```\n", + "These containers are higher level than e.g. ZIP, LMDB, and Tar files, and handle data types, multidimensional arrays, endianness, compression, etc.\n", + "\n", + "Our current design goal, then, is to determine the high level metadata and arrays for sparse arrays.\n", + "\n", + "We should also consider using `binsparse` as an _embedded_ spec to be used as components in other storage formats.\n", + "```mermaid\n", + "flowchart LR\n", + " subgraph Container\n", + " a[embedded binsparse 'foo']\n", + " b[embedded binsparse 'bar']\n", + " c[dense array 'baz']\n", + " d[other stuff]\n", + " end\n", + "```" + ] + }, + { + "cell_type": "markdown", + "id": "8ef2e9ec-3752-444e-bf3f-bcd99aea4cb5", + "metadata": {}, + "source": [ + "# Version 1.0\n", + "- Very limited scope\n", + " - Simple and opinionated with no options\n", + " - Easy to explain and understand\n", + " - Smooth transition to version 2.0\n", + " - Cover most of MatrixMarket format\n", + "- Sparse formats: COO, CSR, CSC, DCSR, DCSC, sparse vector (VEC)\n", + "- Indices must be lexicographically sorted by dim0, dim1\n", + "- No duplicate indices allowed\n", + " - Applies to COO\n", + " - Applies to row indices in DCSR\n", + "- May support dense and bitmap formats\n", + "- May allow attributes such as `is_symmetric`, `ndiag`, etc.\n", + "\n", + "Assume all metadata contains format type and version, such as:\n", + "```json\n", + "{\n", + " \"spec_version\": \"https://purl.org/binsparse/spec/core/1.0\"\n", + "}\n", + "```\n", + "\n", + "\n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "
CSR CSC DCSR DCSC COO VEC
\n", + "\n", + "```json\n", + "{\n", + " \"format\": \"CSR\",\n", + " \"shape\": [m, n]\n", + "}\n", + "```\n", + "\n", + "\n", + "\n", + "```json\n", + "{\n", + " \"format\": \"CSC\",\n", + " \"shape\": [m, n]\n", + "}\n", + "```\n", + "\n", + "\n", + "\n", + "```json\n", + "{\n", + " \"format\": \"DCSR\",\n", + " \"shape\": [m, n]\n", + "}\n", + "```\n", + "\n", + "\n", + "\n", + "```json\n", + "{\n", + " \"format\": \"DCSC\",\n", + " \"shape\": [m, n]\n", + "}\n", + "```\n", + "\n", + "\n", + "\n", + "```json\n", + "{\n", + " \"format\": \"COO\",\n", + " \"shape\": [m, n]\n", + "}\n", + "```\n", + "\n", + "\n", + "\n", + "```json\n", + "{\n", + " \"format\": \"COO\",\n", + " \"shape\": [n]\n", + "}\n", + "```\n", + "\n", + "
\n", + "\n", + "```\n", + "Data:\n", + " - pointers_0\n", + " - indices_1\n", + " - values\n", + "\n", + "```\n", + "\n", + "\n", + "\n", + "```\n", + "Data:\n", + " - pointers_0\n", + " - indices_1\n", + " - values\n", + "\n", + "```\n", + "\n", + "\n", + "\n", + "```\n", + "Data:\n", + " - indices_0\n", + " - pointers_0\n", + " - indices_1\n", + " - values\n", + "```\n", + "\n", + "\n", + "\n", + "```\n", + "Data:\n", + " - indices_0\n", + " - pointers_0\n", + " - indices_1\n", + " - values\n", + "```\n", + "\n", + "\n", + "\n", + "```\n", + "Data:\n", + " - indices_0\n", + " - indices_1\n", + " - values\n", + "\n", + "```\n", + "\n", + "\n", + "\n", + "```\n", + "Data:\n", + " - indices_0\n", + " - values\n", + "\n", + "\n", + "```\n", + "\n", + "
" + ] + }, + { + "cell_type": "markdown", + "id": "2c41d74a-3b8c-479e-bf47-4a45e424f82b", + "metadata": {}, + "source": [ + "### Questions\n", + "Inluding some reactions from the September 7 meeting:\n", + "\n", + "- Should we save datatypes or defer to the storage container?\n", + " - e.g., `{\"data_types\": {\"indices_0\": \"uint64\", \"values\": \"float64\"}`\n", + " - *Jim says yes*\n", + " - *Keep v1 simple*\n", + " - *Researching data types is an action item*\n", + " - If so, should we indicate endianness such as `\"\n", + " \n", + " CSR CSC \n", + "\n", + "\n", + "\n", + "```json\n", + "{\n", + " \"format\": \"CSR\",\n", + " \"shape\": [m, n],\n", + "\n", + " \"dim_types\": [\"compressed\", \"sparse\"],\n", + " \"dim_order\": [0, 1],\n", + "\n", + " \"dim_properties\": {\"1\": {\"is_ordered\": true}},\n", + " \"properties\": {\"has_duplicates\": false},\n", + "\n", + " \"dim_sizes\": [m, n],\n", + " \"dim_taco\": [\"dense\", \"compressed\"]\n", + "}\n", + "```\n", + "\n", + "\n", + "\n", + "\n", + "```json\n", + "{\n", + " \"format\": \"CSC\",\n", + " \"shape\": [m, n],\n", + "\n", + " \"dim_types\": [\"compressed\", \"sparse\"],\n", + " \"dim_order\": [1, 0],\n", + "\n", + " \"dim_properties\": {\"1\": {\"is_ordered\": true}},\n", + " \"properties\": {\"has_duplicates\": false},\n", + "\n", + " \"dim_sizes\": [n, m],\n", + " \"dim_taco\": [\"dense\", \"compressed\"]\n", + "}\n", + "```\n", + "\n", + "\n", + "\n", + " DCSR DCSC \n", + "\n", + "\n", + "\n", + "```json\n", + "{\n", + " \"format\": \"DCSR\",\n", + " \"shape\": [m, n],\n", + "\n", + " \"dim_types\": [\"doubly_compressed\", \"sparse\"],\n", + " \"dim_order\": [0, 1],\n", + "\n", + " \"dim_properties\": {\n", + " \"0\": {\"is_ordered\": true, \"is_unique\": true},\n", + " \"1\": {\"is_ordered\": true}\n", + " },\n", + " \"properties\": {\"has_duplicates\": false},\n", + "\n", + " \"dim_sizes\": [m, n],\n", + " \"dim_taco\": [\"compressed\", \"compressed\"]\n", + "}\n", + "```\n", + "\n", + "\n", + "\n", + "\n", + "```json\n", + "{\n", + " \"format\": \"DCSC\",\n", + " \"shape\": [m, n],\n", + "\n", + " \"dim_types\": [\"doubly_compressed\", \"sparse\"],\n", + " \"dim_order\": [1, 0],\n", + "\n", + " \"dim_properties\": {\n", + " \"0\": {\"is_ordered\": true, \"is_unique\": true},\n", + " \"1\": {\"is_ordered\": true}\n", + " },\n", + " \"properties\": {\"has_duplicates\": false},\n", + "\n", + " \"dim_sizes\": [n, m],\n", + " \"dim_taco\": [\"compressed\", \"compressed\"]\n", + "}\n", + "```\n", + "\n", + "\n", + "\n", + " COO Vector \n", + "\n", + "\n", + "\n", + "```json\n", + "{\n", + " \"format\": \"COO\",\n", + " \"shape\": [m, n],\n", + "\n", + " \"dim_types\": [\"sparse\", \"sparse\"],\n", + " \"dim_order\": [0, 1],\n", + "\n", + " \"dim_properties\": {\n", + " \"0\": {\"is_ordered\": true},\n", + " \"1\": {\"is_ordered\": true}\n", + " },\n", + " \"properties\": {\"has_duplicates\": false},\n", + "\n", + " \"dim_sizes\": [m, n],\n", + " \"dim_taco\": [\"compressed-nonunique\", \"singleton\"]\n", + "}\n", + "```\n", + "\n", + "\n", + "\n", + "\n", + "```json\n", + "{\n", + " \"format\": \"COO\",\n", + " \"shape\": [n],\n", + "\n", + " \"dim_types\": [\"sparse\"],\n", + " \"dim_order\": [0],\n", + "\n", + " \"dim_properties\": {\n", + " \"0\": {\"is_ordered\": true}\n", + " },\n", + " \"properties\": {\"has_duplicates\": false},\n", + "\n", + " \"dim_sizes\": [n],\n", + " \"dim_taco\": [\"compressed\"]\n", + "}\n", + "\n", + "```\n", + "\n", + "\n", + "\n", + "" + ] + }, + { + "cell_type": "markdown", + "id": "4258ac88-a5fe-4552-80a4-cb286564ebe3", + "metadata": {}, + "source": [ + "### `dim_types`\n", + " - Each dimension is one of `\"sparse\"`, `\"compressed\"`, or `\"doubly_compressed\"` as described here:\n", + " - https://github.com/GraphBLAS/binsparse-specification/blob/main/design_docs/01_rankN_arrays.md\n", + " - Design choices\n", + " - required, even in version 1.0\n", + " - required _except_ for formats in version 1.0\n", + " - not required if it can be inferred from the format name\n", + " - Example: `\"format\": \"SCSR\"` --> `\"dim_types\": [\"sparse\", \"compressed\", \"sparse\"]`\n", + " - make `format` optional if `dim_types` is given?\n", + "\n", + "### `dim_order`\n", + " - Logically reorders dimensions\n", + " - Like `dimOrdering` in [MLIR sparse tensor](https://mlir.llvm.org/docs/Dialects/SparseTensorOps/)\n", + " - `shape = [dim_sizes[i] for i in dim_order]`\n", + " - `dim_sizes = [shape[i] for i in argsort(dim_order)]`\n", + " - Optional; defaults to `[0, 1, ..., N-1]`\n", + " - _(choice)_ May infer from last character in `format` if `dim_types` can also be inferred:\n", + " - `\"R\"` results in `[0, 1, ..., N-1]`\n", + " - `\"C\"` results in `[N-1, ..., 1, 0]`\n", + " - otherwise `dim_order` is required (or choose a character like `\"X\"` to mean this)\n", + " - _(choice)_ Make required like `dim_types`?\n", + "\n", + "### `dim_properties`\n", + " - Optional; dictionary of properties for specified dimensions\n", + " - Default properties:\n", + " - `\"compressed\"`: `{}`\n", + " - `\"sparse\"`: `{\"is_ordered\": true}`\n", + " - `\"doubly_compressed\"`: `{\"is_ordered\": true, \"is_unique\": true}`\n", + " - `is_ordered` property\n", + " - Are the indices in `indices_i` in order for `\"sparse\"` or `\"doubly_compressed\"` dimensions?\n", + " - Indicates whether `indices_0` is sorted\n", + " - Indicates whether `indices_i` with the same previous indices (i.e., between `pointers_{i-1}` boundaries) is sorted\n", + " - TACO (paper) _may_ call this `ordered`\n", + " - SuiteSparse:GraphBLAS uses `jumbled`\n", + " - `is_unique` property\n", + " - Indicates whether `indices_i` has no duplicates for `\"doubly_compressed\"` dimensions\n", + " - TACO (paper) _may_ call this `unique`\n", + " - If `false`, then this conceptually splits a single index tree into multiple trees\n", + "\n", + "### `properties`\n", + " - Overall properties of the entire sparse index structure\n", + " - Optional; defaults to `{\"has_duplicates\": false}`\n", + " - `has_duplicates` property\n", + " - Indicates whether the sparse array has values with the same indices\n", + " - May add `is_symmetric`, `ndiag`, `fill_value`, etc\n", + "\n", + "### `dim_sizes`\n", + " - Optional; allowed for clarity\n", + " - Determined from `dim_order` and `shape`\n", + " - `shape = [dim_sizes[i] for i in dim_order]`\n", + " - `dim_sizes = [shape[i] for i in argsort(dim_order)]`\n", + "\n", + "### `dim_taco`\n", + " - Dimension names for TACO and MLIR sparse\n", + " - Optional; allowed for clarity\n", + " - Determined by `dim_types` (when possible)\n", + " - Each dimension is one of `\"compressed\"`, `\"dense\"`, `\"singleton\"`, or `\"compressed-nonunique\"`" + ] + }, + { + "cell_type": "markdown", + "id": "62b793d3-8ca7-4a01-9c6f-17081115106c", + "metadata": {}, + "source": [ + "## Value arrays\n", + "\n", + "Still being explored; don't yet have a complete strawman proposal.\n", + "\n", + "Some ideas:\n", + "\n", + " \n", + " \n", + "\n", + "\n", + "\n", + "\n", + " \n", + "\n", + "\n", + "\n", + "\n", + " \n", + "\n", + "\n", + "\n", + "\n", + " \n", + "\n", + "\n", + "\n", + "\n", + " \n", + "\n", + "\n", + "\n", + "\n", + " \n", + "\n", + "\n", + "\n", + "\n", + " \n", + "\n", + "\n", + "\n", + "\n", + " \n", + "\n", + "\n", + "\n", + "\n", + " \n", + "\n", + "\n", + "\n", + "\n", + " \n", + "\n", + "\n", + "\n", + "\n", + " \n", + "\n", + "\n", + "\n", + "\n", + " \n", + "\n", + "\n", + "\n", + "\n", + "
Full v1 Bitmap v1
\n", + "\n", + "```json\n", + "{\n", + " \"format\": \"Full\",\n", + " \"shape\": [m, n],\n", + "}\n", + "```\n", + "\n", + "\n", + "\n", + "```json\n", + "{\n", + " \"format\": \"Bitmap\",\n", + " \"shape\": [m, n],\n", + "}\n", + "```\n", + "\n", + "
\n", + "\n", + "```\n", + "Data:\n", + " - values\n", + "\n", + "```\n", + "\n", + "\n", + "\n", + "```\n", + "Data:\n", + " - values\n", + " - bitmap\n", + "```\n", + "\n", + "
Full v2 Bitmap v2
\n", + "\n", + "```json\n", + "{\n", + " \"format\": \"Full\",\n", + " \"shape\": [m, n],\n", + "\n", + " \"dim_types\": [\"full\", \"full\"],\n", + " \"dim_order\": [0, 1],\n", + "\n", + " \"dim_properties\": {},\n", + " \"properties\": {\"has_duplicates\": false},\n", + "\n", + " \"dim_sizes\": [m, n],\n", + " \"dim_taco\": [\"dense\", \"dense\"]\n", + "}\n", + "\n", + "\n", + "```\n", + "\n", + "\n", + "\n", + "```json\n", + "{\n", + " \"format\": \"Bitmap\",\n", + " \"shape\": [m, n],\n", + "\n", + " \"dim_types\": [\"full\", \"full\"],\n", + " \"dim_order\": [0, 1],\n", + "\n", + " \"dim_properties\": {},\n", + " \"properties\": {\"has_duplicates\": false},\n", + "\n", + " \"dim_sizes\": [m, n],\n", + " \"dim_taco\": [\"dense\", \"dense\"],\n", + "\n", + " \"value_bitmaps\": {\"values\": \"bitmap\"}\n", + "}\n", + "```\n", + "\n", + "
\n", + "\n", + "```\n", + "Data:\n", + " - values\n", + "\n", + "```\n", + "\n", + "\n", + "\n", + "```\n", + "Data:\n", + " - values\n", + " - bitmap\n", + "```\n", + "\n", + "
CSR (bitmap) DCSC (iso)
\n", + "\n", + "```json\n", + "{\n", + " \"format\": \"CSR\",\n", + " \"shape\": [m, n],\n", + "\n", + " \"dim_types\": [\"compressed\", \"sparse\"],\n", + " \"dim_order\": [0, 1],\n", + "\n", + " \"dim_properties\": {\"1\": {\"is_ordered\": true}},\n", + " \"properties\": {\"has_duplicates\": false},\n", + "\n", + " \"dim_sizes\": [m, n],\n", + " \"dim_taco\": [\"dense\", \"compressed\"],\n", + "\n", + " \"value_bitmaps\": {\"values\": \"bitmap\"}\n", + "}\n", + "\n", + "\n", + "\n", + "```\n", + "\n", + "\n", + "\n", + "```json\n", + "{\n", + " \"format\": \"DCSC\",\n", + " \"shape\": [m, n],\n", + "\n", + " \"dim_types\": [\"doubly_compressed\", \"sparse\"],\n", + " \"dim_order\": [1, 0],\n", + "\n", + " \"dim_properties\": {\n", + " \"0\": {\"is_ordered\": true, \"is_unique\": true},\n", + " \"1\": {\"is_ordered\": true}\n", + " },\n", + " \"properties\": {\"has_duplicates\": false},\n", + "\n", + " \"dim_sizes\": [n, m],\n", + " \"dim_taco\": [\"compressed\", \"compressed\"],\n", + "\n", + " \"value_isovalues\": {\"values\": 0} // needs data_type!\n", + "}\n", + "```\n", + "\n", + "
\n", + "\n", + "```\n", + "Data:\n", + " - pointers_0\n", + " - indices_1\n", + " - values\n", + " - bitmap\n", + "```\n", + "\n", + "\n", + "\n", + "```\n", + "Data:\n", + " - indices_0\n", + " - pointers_0\n", + " - indices_1\n", + "\n", + "```\n", + "\n", + "
CSC (many value arrays) DCSC (structure-only)
\n", + "\n", + "```json\n", + "{\n", + " \"format\": \"CSC\",\n", + " \"shape\": [m, n],\n", + "\n", + " \"dim_types\": [\"compressed\", \"sparse\"],\n", + " \"dim_order\": [1, 0],\n", + "\n", + " \"dim_properties\": {\"1\": {\"is_ordered\": true}},\n", + " \"properties\": {\"has_duplicates\": false},\n", + "\n", + " \"dim_sizes\": [n, m],\n", + " \"dim_taco\": [\"dense\", \"compressed\"],\n", + "\n", + " \"value_names\": [\"foo\", \"bar\"],\n", + "}\n", + "\n", + "\n", + "\n", + "```\n", + "\n", + "\n", + "\n", + "```json\n", + "{\n", + " \"format\": \"DCSR\",\n", + " \"shape\": [m, n],\n", + "\n", + " \"dim_types\": [\"doubly_compressed\", \"sparse\"],\n", + " \"dim_order\": [0, 1],\n", + "\n", + " \"dim_properties\": {\n", + " \"0\": {\"is_ordered\": true, \"is_unique\": true},\n", + " \"1\": {\"is_ordered\": true}\n", + " },\n", + " \"properties\": {\"has_duplicates\": false},\n", + "\n", + " \"dim_sizes\": [m, n],\n", + " \"dim_taco\": [\"compressed\", \"compressed\"],\n", + "\n", + " \"value_names\": [],\n", + "}\n", + "```\n", + "\n", + "
\n", + "\n", + "```\n", + "Data:\n", + " - pointers_0\n", + " - indices_1\n", + " - foo\n", + " - bar\n", + "```\n", + "\n", + "\n", + "```\n", + "Data:\n", + " - indices_0\n", + " - pointers_0\n", + " - indices_1\n", + "\n", + "```\n", + "\n", + "
semi-COO CSR (array values)
\n", + "\n", + "```json\n", + "{\n", + " \"format\": \"SFR\",\n", + " \"shape\": [m, n],\n", + "\n", + " \"dim_types\": [\"sparse\", \"full\"],\n", + " \"dim_order\": [0, 1],\n", + "\n", + " \"dim_properties\": {\"0\": {\"is_ordered\": true}},\n", + " \"properties\": {\"has_duplicates\": false},\n", + "\n", + " \"dim_sizes\": [m, n],\n", + " \"dim_taco\": [\"compressed-nonunique\", \"dense\"]\n", + "}\n", + "\n", + "\n", + "\n", + "```\n", + "\n", + "\n", + "\n", + "```json\n", + "{\n", + " \"format\": \"CSFR\",\n", + " \"shape\": [m, n, o],\n", + "\n", + " \"dim_types\": [\"compressed\", \"sparse\", \"full\"],\n", + " \"dim_order\": [0, 1, 2],\n", + "\n", + " \"dim_properties\": {\n", + " \"0\": {\"is_ordered\": true},\n", + " \"1\": {\"is_ordered\": true}\n", + " },\n", + " \"properties\": {\"has_duplicates\": false},\n", + "\n", + " \"dim_sizes\": [m, n, o],\n", + " \"dim_taco\": [\"dense\", \"compressed\", \"dense\"],\n", + "}\n", + "```\n", + "\n", + "
\n", + "\n", + "```C\n", + "Data:\n", + " - indices_0\n", + " - values // shape = [len(indices_0), n]\n", + "\n", + "```\n", + "\n", + "\n", + "\n", + "```C\n", + "Data:\n", + " - pointers_0\n", + " - indices_1\n", + " - values // shape = [len(indices_1), o]\n", + "```\n", + "\n", + "
CSR (multigraph) CSR (variable-size datatype)
\n", + "\n", + "```json\n", + "{\n", + " \"format\": \"CSR\",\n", + " \"shape\": [m, n],\n", + "\n", + " \"dim_types\": [\"compressed\", \"doubly_compressed\"],\n", + " \"dim_order\": [0, 1],\n", + "\n", + " \"dim_properties\":\n", + " {\"1\": {\"is_ordered\": true, \"is_unique\": true}\n", + " },\n", + " \"properties\": {\"has_duplicates\": true},\n", + "\n", + " \"dim_sizes\": [m, n],\n", + " \"dim_taco\": null,\n", + "}\n", + "\n", + "```\n", + "\n", + "\n", + "\n", + "```json\n", + "{\n", + " \"format\": \"CSR\",\n", + " \"shape\": [m, n],\n", + "\n", + " \"dim_types\": [\"compressed\", \"sparse\"],\n", + " \"dim_order\": [0, 1],\n", + "\n", + " \"dim_properties\": {\"1\": {\"is_ordered\": true}},\n", + " \"properties\": {\"has_duplicates\": false},\n", + "\n", + " \"dim_sizes\": [m, n],\n", + " \"dim_taco\": [\"dense\", \"compressed\"],\n", + "\n", + " \"value_pointers\": {\"values\": \"valptr\"}\n", + "}\n", + "\n", + "```\n", + "\n", + "
\n", + "\n", + "```\n", + "Data:\n", + " - pointers_0\n", + " - indices_1\n", + " - pointers_1\n", + " - values\n", + "```\n", + "\n", + "\n", + "\n", + "```\n", + "Data:\n", + " - pointers_0\n", + " - indices_1\n", + " - values\n", + " - valptr\n", + "```\n", + "\n", + "
" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.13" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/minutes/2022-09-07-strawman.md b/minutes/2022-09-07-strawman.md new file mode 100755 index 0000000..da13639 --- /dev/null +++ b/minutes/2022-09-07-strawman.md @@ -0,0 +1,888 @@ +- **Author:** [Erik Welch](https://github.com/eriknw) +- **Date:** 2022-09-07 +- **Purpose:** Strawman proposal to help discuss [PR #3](https://github.com/GraphBLAS/binsparse-specification/pull/3) +and its [proposal](https://github.com/GraphBLAS/binsparse-specification/blob/main/design_docs/01_rankN_arrays.md) +- https://github.com/GraphBLAS/binsparse-specification + +# High level perspective + +Let's call our binary sparse storage format `binsparse` in this document. + +For high level design, let's assume we will use existing data storage formats that can store **metadata** and **arrays** including the shape and data type of arrays: +```mermaid +flowchart TB + high[binsparse: high level metadata]-->mid[containers for metadata and arrays]-->low[(files)] +``` +Example data storage formats: +```mermaid +flowchart TB + binsparse-->NetCDF4 + binsparse-->HDF5 + binsparse-->Zarr + binsparse-->n5 + binsparse-->ASDF + binsparse<-->anndata +``` +These containers are higher level than e.g. ZIP, LMDB, and Tar files, and handle data types, multidimensional arrays, endianness, compression, etc. + +Our current design goal, then, is to determine the high level metadata and arrays for sparse arrays. + +We should also consider using `binsparse` as an _embedded_ spec to be used as components in other storage formats. +```mermaid +flowchart LR + subgraph Container + a[embedded binsparse 'foo'] + b[embedded binsparse 'bar'] + c[dense array 'baz'] + d[other stuff] + end +``` + +# Version 1.0 +- Very limited scope + - Simple and opinionated with no options + - Easy to explain and understand + - Smooth transition to version 2.0 + - Cover most of MatrixMarket format +- Sparse formats: COO, CSR, CSC, DCSR, DCSC, sparse vector (VEC) +- Indices must be lexicographically sorted by dim0, dim1 +- No duplicate indices allowed + - Applies to COO + - Applies to row indices in DCSR +- May support dense and bitmap formats +- May allow attributes such as `is_symmetric`, `ndiag`, etc. + +Assume all metadata contains format type and version, such as: +```json +{ + "spec_version": "https://purl.org/binsparse/spec/core/1.0" +} +``` + + + + + + + + + + + + + + + + + + + + +
CSR CSC DCSR DCSC COO VEC
+ +```json +{ + "format": "CSR", + "shape": [m, n] +} +``` + + + +```json +{ + "format": "CSC", + "shape": [m, n] +} +``` + + + +```json +{ + "format": "DCSR", + "shape": [m, n] +} +``` + + + +```json +{ + "format": "DCSC", + "shape": [m, n] +} +``` + + + +```json +{ + "format": "COO", + "shape": [m, n] +} +``` + + + +```json +{ + "format": "COO", + "shape": [n] +} +``` + +
+ +``` +Data: + - pointers_0 + - indices_1 + - values + +``` + + + +``` +Data: + - pointers_0 + - indices_1 + - values + +``` + + + +``` +Data: + - indices_0 + - pointers_0 + - indices_1 + - values +``` + + + +``` +Data: + - indices_0 + - pointers_0 + - indices_1 + - values +``` + + + +``` +Data: + - indices_0 + - indices_1 + - values + +``` + + + +``` +Data: + - indices_0 + - values + + +``` + +
+ +### Questions +Inluding some reactions from the September 7 meeting: + +- Should we save datatypes or defer to the storage container? + - e.g., `{"data_types": {"indices_0": "uint64", "values": "float64"}` + - *Jim says yes* + - *Keep v1 simple* + - *Researching data types is an action item* + - If so, should we indicate endianness such as `" + + CSR CSC + + + +```json +{ + "format": "CSR", + "shape": [m, n], + + "dim_types": ["compressed", "sparse"], + "dim_order": [0, 1], + + "dim_properties": {"1": {"is_ordered": true}}, + "properties": {"has_duplicates": false}, + + "dim_sizes": [m, n], + "dim_taco": ["dense", "compressed"] +} +``` + + + + +```json +{ + "format": "CSC", + "shape": [m, n], + + "dim_types": ["compressed", "sparse"], + "dim_order": [1, 0], + + "dim_properties": {"1": {"is_ordered": true}}, + "properties": {"has_duplicates": false}, + + "dim_sizes": [n, m], + "dim_taco": ["dense", "compressed"] +} +``` + + + + DCSR DCSC + + + +```json +{ + "format": "DCSR", + "shape": [m, n], + + "dim_types": ["doubly_compressed", "sparse"], + "dim_order": [0, 1], + + "dim_properties": { + "0": {"is_ordered": true, "is_unique": true}, + "1": {"is_ordered": true} + }, + "properties": {"has_duplicates": false}, + + "dim_sizes": [m, n], + "dim_taco": ["compressed", "compressed"] +} +``` + + + + +```json +{ + "format": "DCSC", + "shape": [m, n], + + "dim_types": ["doubly_compressed", "sparse"], + "dim_order": [1, 0], + + "dim_properties": { + "0": {"is_ordered": true, "is_unique": true}, + "1": {"is_ordered": true} + }, + "properties": {"has_duplicates": false}, + + "dim_sizes": [n, m], + "dim_taco": ["compressed", "compressed"] +} +``` + + + + COO Vector + + + +```json +{ + "format": "COO", + "shape": [m, n], + + "dim_types": ["sparse", "sparse"], + "dim_order": [0, 1], + + "dim_properties": { + "0": {"is_ordered": true}, + "1": {"is_ordered": true} + }, + "properties": {"has_duplicates": false}, + + "dim_sizes": [m, n], + "dim_taco": ["compressed-nonunique", "singleton"] +} +``` + + + + +```json +{ + "format": "COO", + "shape": [n], + + "dim_types": ["sparse"], + "dim_order": [0], + + "dim_properties": { + "0": {"is_ordered": true} + }, + "properties": {"has_duplicates": false}, + + "dim_sizes": [n], + "dim_taco": ["compressed"] +} + +``` + + + + + +### `dim_types` + - Each dimension is one of `"sparse"`, `"compressed"`, or `"doubly_compressed"` as described here: + - https://github.com/GraphBLAS/binsparse-specification/blob/main/design_docs/01_rankN_arrays.md + - Design choices + - required, even in version 1.0 + - required _except_ for formats in version 1.0 + - not required if it can be inferred from the format name + - Example: `"format": "SCSR"` --> `"dim_types": ["sparse", "compressed", "sparse"]` + - make `format` optional if `dim_types` is given? + +### `dim_order` + - Logically reorders dimensions + - Like `dimOrdering` in [MLIR sparse tensor](https://mlir.llvm.org/docs/Dialects/SparseTensorOps/) + - `shape = [dim_sizes[i] for i in dim_order]` + - `dim_sizes = [shape[i] for i in argsort(dim_order)]` + - Optional; defaults to `[0, 1, ..., N-1]` + - _(choice)_ May infer from last character in `format` if `dim_types` can also be inferred: + - `"R"` results in `[0, 1, ..., N-1]` + - `"C"` results in `[N-1, ..., 1, 0]` + - otherwise `dim_order` is required (or choose a character like `"X"` to mean this) + - _(choice)_ Make required like `dim_types`? + +### `dim_properties` + - Optional; dictionary of properties for specified dimensions + - Default properties: + - `"compressed"`: `{}` + - `"sparse"`: `{"is_ordered": true}` + - `"doubly_compressed"`: `{"is_ordered": true, "is_unique": true}` + - `is_ordered` property + - Are the indices in `indices_i` in order for `"sparse"` or `"doubly_compressed"` dimensions? + - Indicates whether `indices_0` is sorted + - Indicates whether `indices_i` with the same previous indices (i.e., between `pointers_{i-1}` boundaries) is sorted + - TACO (paper) _may_ call this `ordered` + - SuiteSparse:GraphBLAS uses `jumbled` + - `is_unique` property + - Indicates whether `indices_i` has no duplicates for `"doubly_compressed"` dimensions + - TACO (paper) _may_ call this `unique` + - If `false`, then this conceptually splits a single index tree into multiple trees + +### `properties` + - Overall properties of the entire sparse index structure + - Optional; defaults to `{"has_duplicates": false}` + - `has_duplicates` property + - Indicates whether the sparse array has values with the same indices + - May add `is_symmetric`, `ndiag`, `fill_value`, etc + +### `dim_sizes` + - Optional; allowed for clarity + - Determined from `dim_order` and `shape` + - `shape = [dim_sizes[i] for i in dim_order]` + - `dim_sizes = [shape[i] for i in argsort(dim_order)]` + +### `dim_taco` + - Dimension names for TACO and MLIR sparse + - Optional; allowed for clarity + - Determined by `dim_types` (when possible) + - Each dimension is one of `"compressed"`, `"dense"`, `"singleton"`, or `"compressed-nonunique"` + +## Value arrays + +Still being explored; don't yet have a complete strawman proposal. + +Some ideas: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Full v1 Bitmap v1
+ +```json +{ + "format": "Full", + "shape": [m, n], +} +``` + + + +```json +{ + "format": "Bitmap", + "shape": [m, n], +} +``` + +
+ +``` +Data: + - values + +``` + + + +``` +Data: + - values + - bitmap +``` + +
Full v2 Bitmap v2
+ +```json +{ + "format": "Full", + "shape": [m, n], + + "dim_types": ["full", "full"], + "dim_order": [0, 1], + + "dim_properties": {}, + "properties": {"has_duplicates": false}, + + "dim_sizes": [m, n], + "dim_taco": ["dense", "dense"] +} + + +``` + + + +```json +{ + "format": "Bitmap", + "shape": [m, n], + + "dim_types": ["full", "full"], + "dim_order": [0, 1], + + "dim_properties": {}, + "properties": {"has_duplicates": false}, + + "dim_sizes": [m, n], + "dim_taco": ["dense", "dense"], + + "value_bitmaps": {"values": "bitmap"} +} +``` + +
+ +``` +Data: + - values + +``` + + + +``` +Data: + - values + - bitmap +``` + +
CSR (bitmap) DCSC (iso)
+ +```json +{ + "format": "CSR", + "shape": [m, n], + + "dim_types": ["compressed", "sparse"], + "dim_order": [0, 1], + + "dim_properties": {"1": {"is_ordered": true}}, + "properties": {"has_duplicates": false}, + + "dim_sizes": [m, n], + "dim_taco": ["dense", "compressed"], + + "value_bitmaps": {"values": "bitmap"} +} + + + +``` + + + +```json +{ + "format": "DCSC", + "shape": [m, n], + + "dim_types": ["doubly_compressed", "sparse"], + "dim_order": [1, 0], + + "dim_properties": { + "0": {"is_ordered": true, "is_unique": true}, + "1": {"is_ordered": true} + }, + "properties": {"has_duplicates": false}, + + "dim_sizes": [n, m], + "dim_taco": ["compressed", "compressed"], + + "value_isovalues": {"values": 0} // needs data_type! +} +``` + +
+ +``` +Data: + - pointers_0 + - indices_1 + - values + - bitmap +``` + + + +``` +Data: + - indices_0 + - pointers_0 + - indices_1 + +``` + +
CSC (many value arrays) DCSC (structure-only)
+ +```json +{ + "format": "CSC", + "shape": [m, n], + + "dim_types": ["compressed", "sparse"], + "dim_order": [1, 0], + + "dim_properties": {"1": {"is_ordered": true}}, + "properties": {"has_duplicates": false}, + + "dim_sizes": [n, m], + "dim_taco": ["dense", "compressed"], + + "value_names": ["foo", "bar"], +} + + + +``` + + + +```json +{ + "format": "DCSR", + "shape": [m, n], + + "dim_types": ["doubly_compressed", "sparse"], + "dim_order": [0, 1], + + "dim_properties": { + "0": {"is_ordered": true, "is_unique": true}, + "1": {"is_ordered": true} + }, + "properties": {"has_duplicates": false}, + + "dim_sizes": [m, n], + "dim_taco": ["compressed", "compressed"], + + "value_names": [], +} +``` + +
+ +``` +Data: + - pointers_0 + - indices_1 + - foo + - bar +``` + + +``` +Data: + - indices_0 + - pointers_0 + - indices_1 + +``` + +
semi-COO CSR (array values)
+ +```json +{ + "format": "SFR", + "shape": [m, n], + + "dim_types": ["sparse", "full"], + "dim_order": [0, 1], + + "dim_properties": {"0": {"is_ordered": true}}, + "properties": {"has_duplicates": false}, + + "dim_sizes": [m, n], + "dim_taco": ["compressed-nonunique", "dense"] +} + + + +``` + + + +```json +{ + "format": "CSFR", + "shape": [m, n, o], + + "dim_types": ["compressed", "sparse", "full"], + "dim_order": [0, 1, 2], + + "dim_properties": { + "0": {"is_ordered": true}, + "1": {"is_ordered": true} + }, + "properties": {"has_duplicates": false}, + + "dim_sizes": [m, n, o], + "dim_taco": ["dense", "compressed", "dense"], +} +``` + +
+ +```C +Data: + - indices_0 + - values // shape = [len(indices_0), n] + +``` + + + +```C +Data: + - pointers_0 + - indices_1 + - values // shape = [len(indices_1), o] +``` + +
CSR (multigraph) CSR (variable-size datatype)
+ +```json +{ + "format": "CSR", + "shape": [m, n], + + "dim_types": ["compressed", "doubly_compressed"], + "dim_order": [0, 1], + + "dim_properties": + {"1": {"is_ordered": true, "is_unique": true} + }, + "properties": {"has_duplicates": true}, + + "dim_sizes": [m, n], + "dim_taco": null, +} + +``` + + + +```json +{ + "format": "CSR", + "shape": [m, n], + + "dim_types": ["compressed", "sparse"], + "dim_order": [0, 1], + + "dim_properties": {"1": {"is_ordered": true}}, + "properties": {"has_duplicates": false}, + + "dim_sizes": [m, n], + "dim_taco": ["dense", "compressed"], + + "value_pointers": {"values": "valptr"} +} + +``` + +
+ +``` +Data: + - pointers_0 + - indices_1 + - pointers_1 + - values +``` + + + +``` +Data: + - pointers_0 + - indices_1 + - values + - valptr +``` + +
diff --git a/minutes/2022-09-07.md b/minutes/2022-09-07.md new file mode 100644 index 0000000..7c0a450 --- /dev/null +++ b/minutes/2022-09-07.md @@ -0,0 +1,59 @@ +# Binary Sparse Format Working Group Meeting #2 - September 7, 2022 + +## Attendees +- [X] Ben Brock +- [ ] Tim Davis +- [X] Jim Kitchen +- [ ] Tim Mattson +- [X] Scott McMillan +- [X] Erik Welch +- [X] Isaac Virshup +- [ ] Will Kimmerer + +## Agenda + +- Discuss Erik Welch's strawman proposal for v1.0 and v2.0 specs. + +## Summary of Discussion + +- Discussed stacking indices/pointers arrays vs. keeping them as separate arrays. + * Stacking potentially reduces overhead associated with having multiple arrays + * Stacking arrays requires that they be the same type + * Jim: perhaps stacking vs. independent arrays can be handled by the binary storage library. + * Isaac: one library seems to represent multiple Arrow arrays as a single array. + +- Add "comments" fields, perhaps some additional "attributes," or even allow users to provide arbitrary keys. + +- Discussed data types. Consensus seems to be to list datatypes of individual arrays. + * What types should we support? + * int8, 16, 32, 64, etc., as well as unsigned versions + * float, double, complex + * Isaac: what about user-defined types through Arrow? + * More investigation necessary, but can potentially use third-party library like + Arrow. + +- Discussed formats to support in v1. + * Sorted, no duplicated indices. + * COO, CSR, CSC, DCSR, DCSC, (COOR and COOC sorted by row, column, with COO + an alias to COOR) + * Format name "custom" or similar will indicate explicit tensor descriptor + in v2. + +Isaac: in-memory or memory-mapped usability is a big priority. +Ben: memory-mapping is also important in distributed memory, as it can allow + different processes to read independently in an efficient way. Hopefully + a binary storage library will allow us to do this. + +## Outcomes + +Consensus on the outline of features for v1, v2. + +Deliverables: +- Ben to set up a when2meet / whenisgood to establish new meeting time. + +- Erik to update his design document based on our discussion + +- Ben, Jim, and Tim to implement experimental reader/writers based on the design + document for C++, Python, C. + +- Isaac to examine binary storage libraries, particularly Arrow and user-defined types diff --git a/minutes/2022-09-26.md b/minutes/2022-09-26.md new file mode 100644 index 0000000..5298328 --- /dev/null +++ b/minutes/2022-09-26.md @@ -0,0 +1,63 @@ +# Binary Sparse Format Working Group Meeting #3 - September 26, 2022 + +## Attendees +- [X] Ben Brock +- [ ] Tim Davis +- [X] Jim Kitchen +- [ ] Tim Mattson +- [ ] Scott McMillan +- [X] Erik Welch +- [X] Isaac Virshup +- [ ] Will Kimmerer + +## Agenda + +- Discuss prototype implementations by Ben, Jim + * What binary container library should we use? + Goal: develop plan for evaluating options + Goal: define what we need to specify vs. container library + +- Discuss Erik's progress on V2.0 + +## Summary of Discussion + +- Ben: HDF5 has some pain points + * Have to pick standard types for disk storage, which can be somewhat arbitrary + * Currently storing strings as a datset, which is not quite satisfactory + * Others in issue #9 + +- Groups can have string attributes + * Files should have an implicit root group + +- Jim: NetCDF sits on top of HDF5 and likely handles some of these issues. + +- Jim: should make sure that a library picking different defaults in different + languages does not prevent some language (e.g. Julia) from inter-operating. + +- Erik: V2 update, + +Isaac: How does chunking work? + +### Resources and Links +Data type for storing strings in HDF5: +``` +DATATYPE H5T_STRING { + STRSIZE H5T_VARIABLE; + STRPAD H5T_STR_NULLTERM; + CSET H5T_CSET_UTF8; + CTYPE H5T_C_S1; + } +``` + +CDF to HDF5 Converter +https://github.com/h5netcdf/h5netcdf + +TensorStore - Google thing built on top of Zarr/HDF5 + +conda install -c jim22k sscdf + +## Outcomes + +- Ben will try using NetCDF in his C++ implementation, looking some of SSCDF's outputs. + +- We will meet next week to discuss Erik's updates on V2 in detail. diff --git a/minutes/2022-10-03.md b/minutes/2022-10-03.md new file mode 100644 index 0000000..1c01c5c --- /dev/null +++ b/minutes/2022-10-03.md @@ -0,0 +1,56 @@ +# Binary Sparse Format Working Group Meeting #4 - October 3, 2022 + +## Attendees +- [X] Ben Brock +- [ ] Tim Davis +- [X] Jim Kitchen +- [ ] Tim Mattson +- [ ] Scott McMillan +- [X] Erik Welch +- [X] Isaac Virshup +- [ ] Will Kimmerer + +## Agenda + +- Discuss Erik's work on V2 spec/implementation + +## Summary of Discussion + +Short discussion about Zarr. Community seems to be migrating away from HDF5, +toward Zarr. + +Question: does Zarr have good support outside of Python? + +Jim: Zarr has some support in NetCDF. + +Erik: the V2 proposal has keywords to represent the storage format of each + dimension: +- "Sparse" or "full" for sparse or dense values in the inner dimension +- "compressed" or "doubly_compressed" to represent an outer dimension that + points to another inner dimension + +- Could potentially add "uncompressed" to an inner dimension to reference + an inner dimension that is full and uncompressed. + +### Resources and Links + +Discussion of C support for Zarr +https://github.com/zarr-developers/community/issues/9 +https://github.com/zarr-developers/zarr-specs/issues/41 + +Chunking Support +https://github.com/fsspec/kerchunk + +## Outcomes +- Ben will continue to investigate NetCDF +- Ben will investigate C/C++ support for Zarr + +- Jim will talk about awkward array + +Consider if there are additional values we need to support from SuiteSparse Matrix Collection's Matrix Market +- Symmetric (structure and with values) +- Are there others? +- Jim: Matrix Market has a bunch of unusual formats like Hermetian, skew symmetric, etc. +- We can potentially just store these all explicitly, without too much overhead (since we are a binary format). +- Or we could add additional attributes (e.g. "symmetric") to change the interpretation of the + formats we already have (essentially what MM does). diff --git a/minutes/2022-10-31.md b/minutes/2022-10-31.md new file mode 100644 index 0000000..521ff91 --- /dev/null +++ b/minutes/2022-10-31.md @@ -0,0 +1,53 @@ +# Binary Sparse Format Working Group Meeting #5 - October 31, 2022 + +## Attendees +- [X] Ben Brock +- [X] Tim Davis +- [X] Jim Kitchen +- [ ] Tim Mattson +- [ ] Scott McMillan +- [X] Erik Welch +- [X] Isaac Virshup +- [ ] Will Kimmerer + +## Agenda + +- Discuss auxiliary data, as well as next steps for formalizing the API. + +## Summary of Discussion + +- Tim presented the auxiliary data used in the SuiteSparse Matrix Collection. + * These consist of various bits of metadata associated with one of + 1) The matrix as a whole (i.e. arbitrary ASCII) + 2) Rows/columns/vertices + 3) Edges (individual nonzeros) + * In SuiteSparse, these are stored as separate documents within a tarball + * Based on standardized data in MatrixMarket file, look for files (text, MatrixMarket) + storing additional data. + +Do we want to support auxiliary data? + +Jim: yes, we can store these by nature of using a binary data container. Auxiliary +data can simply be additional datasets in a nested namespace. + +Isaac: one exception is data associated with individual edges, which is more +tightly associated with nonzeros, so needs to be associated with matrix structure. + +Erik's 2.0 proposal supports edge properties, essentially by allowing additional +values arrays. + +User-defined types: Tim presented SuiteSparse's user-defined type mechanism, which +essentially stores the C struct along with metadata. + +Should we store the types of indices/values in metadata? +Jim: if container does not support all types, it becomes necessary to store +additional type information. Example: bool (HDF5/NetCDF have no bool). + +Are we ready to begin drafting spec document with some of the 1.0 details we +have mostly crystallized? Yes. + +## Outcomes +- Ben will create independent GitHub repo with binary sparse prototype parser. +- Ben will continue to investigate NetCDF + +- Isaac will set up spec document using Bikeshed diff --git a/minutes/2022-11-28.md b/minutes/2022-11-28.md new file mode 100644 index 0000000..4f3964a --- /dev/null +++ b/minutes/2022-11-28.md @@ -0,0 +1,61 @@ +# Binary Sparse Format Working Group Meeting #6 - November 28, 2022 + +## Attendees +- [X] Ben Brock +- [X] Tim Davis +- [X] Jim Kitchen +- [ ] Tim Mattson +- [ ] Scott McMillan +- [X] Erik Welch +- [X] Isaac Virshup +- [ ] Will Kimmerer + +## Agenda + +- Discuss specification document infrastructure, layout outline for proceeding with spec doc + +- Discuss structure of C/C++ bindings + +## Summary of Discussion + +- Isaac presented infrastructure for spec draft. +- GitHub bot is set up to render spec, will post comment on PR with link to spec +- Can set up to produce render of `main`, will require some hosting (e.g. GitHub Pages) + +- Ben: what should the interface be for C reference API? +- Tim: supporting custom malloc/free is important + +Ben will produce draft C bindings that allow providing a custom malloc/free, +providing sparse matrix data using a C struct. It will be the user's responsibility +to free data using the same allocation method they provided. + +- How to store value in iso-valued matrix? + * We could store directly using JSON + * However, using JSON has problems, since types may not exactly match those + in C, or supported by binary storage container. + +Set out outline: + +1. Introduction / motivation + +2. Metadata keys and values + a. dimensions + b. format + c. extra user-defined metadata + d. types + +3. How arrays are stored in memory + +4. Description of how arrays are stored in data container (e.g. HDF5) + - Reader/writer reference implementation? + +Specifying HDF5 vs. Zarr vs. both + + +## Outcomes +- Ben will continue work on C/C++ bindings +- Jim will take a stab at drafting Section 2 +- Ben will begin draft of Section 1 + +- This is a busy period, so progress will likely be a bit slow. + Next meeting tentatively planned for December 19. diff --git a/minutes/2023-01-09.md b/minutes/2023-01-09.md new file mode 100644 index 0000000..ccff3ca --- /dev/null +++ b/minutes/2023-01-09.md @@ -0,0 +1,38 @@ +# Binary Sparse Format Working Group Meeting #7 - January 9, 2023 + +## Attendees +- [X] Ben Brock +- [X] Tim Davis +- [X] Jim Kitchen +- [ ] Tim Mattson +- [ ] Scott McMillan +- [X] Erik Welch +- [ ] Isaac Virshup +- [ ] Will Kimmerer + +## Agenda + +- Discuss Tim Davis' matrix C struct + +- Discuss Ben's work on HDF5 bindings, as well as issues with HDF5. + * It is not straightforward to determine the type of an HDF5 dataset. + +## Summary of Discussion + +Tim discussed the [C matrix](https://github.com/GraphBLAS/binsparse-reference-impl/blob/main/include/binsparse/c_bindings/binsparse_matrix.h) he defined for binsparse. This consists of the following: + - Matrix dimensions and number of values + - Types in the matrix + - Number of axes + - Values pointer + - A pointer to multiple axes + * Each axis contains a "pointer" or "index" + +Ben discussed his implementation of [C bindings](https://github.com/GraphBLAS/binsparse-reference-impl/blob/main/include/binsparse/c_bindings/bc_read_matrix.hpp). + + - One major issue is that HDF5 does not have an easy mechanism in C/C++ to determine the type of a dataset. + * You are limited to individual queries like type class (e.g. integer, float), endianness, and size. + * Ben implemented a [helper function](https://github.com/GraphBLAS/binsparse-reference-impl/blob/main/include/binsparse/hdf5_tools.hpp#L77) that does some of this work on top of HDF5. + * To help with this issue, we should list the types in JSON. + * Users could specify what types to store the matrix to disk with, even if those don't necessarily match the types stored in memory. HDF5 should handle this automatically. + +## Outcomes diff --git a/minutes/2023-01-23.md b/minutes/2023-01-23.md new file mode 100644 index 0000000..babf586 --- /dev/null +++ b/minutes/2023-01-23.md @@ -0,0 +1,37 @@ +--- +tags: meeting +--- + +# 2023-01-23: graphblas binsparse meeting + +*Attendees: Willow Ahrens, Jim Kitchen, Benjamin Brock, Erik Welch, Isaac Virshup* + +## Agenda + +* Recap of hdf5 pains (Ben) +* Zarr conventions (Isaac) (https://github.com/zarr-developers/zeps/pull/28) +* 2.0 plan (Willow + Erik) +* May scientific python meeting (Isaac) (https://scientific-python.org/summits/developer/2023/) + +## Notes + +* hdf5 pains + * Figuring out what dtypes are present in an HDF5 dataset + * +* C structure (from last meeting) – [link](https://github.com/GraphBLAS/binsparse-reference-impl/blob/main/include/binsparse/c_bindings/binsparse_matrix.h) +* 2.0 + * "Bundled" levels: https://mybinder.org/v2/gh/GraphBLAS/binsparse-specification/main?filepath=sparsetensorviz/notebooks/Example_Rank4-bundled.ipynb + * Discussion: https://github.com/GraphBLAS/binsparse-reference-impl/pull/1 +* v1 + * What does the in memory implementation need to do? + * Could we go for a fairly simple file format, npz + * If high level, should we define a structure that isn't used? + * E.g. MLIR, TACO – and are these optimizing for the same thing + * Willow: they are all using the same buffers + * Maybe not 1-indexed languages, but basically the same +* TODO + * Move from design docs to spec + * Willow can follow up on interoprability with Finch + * NASA Grant + * https://science.nasa.gov/researchers/solicitations/roses-2022/amendment-73-f15-high-priority-open-source-science-final-text + * https://nspires.nasaprs.com/external/viewrepositorydocument/cmdocumentid=860825/solicitationId=%7BB364DBB8-390B-744D-013F-8F4C304B9A63%7D/viewSolicitationDocument=1/F.15%20HPOSS_Amend73.pdf diff --git a/sparsetensorviz/.gitattributes b/sparsetensorviz/.gitattributes new file mode 100644 index 0000000..eb38dfc --- /dev/null +++ b/sparsetensorviz/.gitattributes @@ -0,0 +1 @@ +sparsetensorviz/_version.py export-subst diff --git a/sparsetensorviz/LICENSE b/sparsetensorviz/LICENSE new file mode 100644 index 0000000..a0cba38 --- /dev/null +++ b/sparsetensorviz/LICENSE @@ -0,0 +1,29 @@ +BSD 3-Clause License + +Copyright (c) 2022, GraphBLAS +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/sparsetensorviz/MANIFEST.in b/sparsetensorviz/MANIFEST.in new file mode 100644 index 0000000..b11c3e7 --- /dev/null +++ b/sparsetensorviz/MANIFEST.in @@ -0,0 +1,6 @@ +recursive-include sparsetensorviz *.py +include setup.py +include README.md +include LICENSE +include MANIFEST.in +include versioneer.py diff --git a/sparsetensorviz/README.md b/sparsetensorviz/README.md new file mode 100644 index 0000000..e69de29 diff --git a/sparsetensorviz/conftest.py b/sparsetensorviz/conftest.py new file mode 100644 index 0000000..b6f5cc2 --- /dev/null +++ b/sparsetensorviz/conftest.py @@ -0,0 +1,2 @@ +def pytest_addoption(parser): + parser.addoption("--runslow", default=None, action="store_true", help="run slow tests") diff --git a/sparsetensorviz/notebooks/Example_Rank4-bundled.ipynb b/sparsetensorviz/notebooks/Example_Rank4-bundled.ipynb new file mode 100644 index 0000000..b482e50 --- /dev/null +++ b/sparsetensorviz/notebooks/Example_Rank4-bundled.ipynb @@ -0,0 +1,8176 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "36476992", + "metadata": {}, + "source": [ + "# Examples of \"bundling\" dimensions into groups\n", + "\n", + "The diagram below shows valid transitions used to create the sparse structure.\n", + "\n", + "`n1`, `n2`, `n3`, `n4` are how many dimensions are in each group.\n", + "\n", + "### Data of bundled groups\n", + "- `HyperSparse(n1)`\n", + " - indices for `n1` dimensions\n", + " - pointers array (or scalar `k` for ELLPACK-like compression)\n", + "- `Coord(n2)`\n", + " - indices for `n2` dimensions\n", + "- `Sparse(n3)`\n", + " - pointers array (or scalar `k` for ELLPACK-like compression)\n", + "- `Full(n4)`\n", + " - N/A\n", + "\n", + "_Note that indices grouped together in this scheme are all the same length, so they can be stored as separate 1-d arrays or a single 2-d array_" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "c9195d7f", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " Done!\n", + " HyperSparse[n1]\n", + " Full[n4]\n", + " Coord[n2]\n", + " Sparse[n3]\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Valid transitions\n", + "import IPython\n", + "from sphinxcontrib.svgbob._svgbob import to_svg\n", + "\n", + "IPython.display.SVG(\n", + " to_svg(\n", + " r\"\"\"\n", + " .----.\n", + " | |\n", + " | v\n", + " .--+------------.\n", + " |HyperSparse[n1]|\n", + " `-------+-------'\n", + " ^ | .--------.\n", + " | | .-->|Full[n4]|\n", + " | v / `--+-----'\n", + " | .--------+. |\n", + " | |Coord[n2]| |\n", + " | `--------+' v\n", + " | ^ \\ .-----.\n", + " | | `-->|Done!|\n", + " | v `-----' \n", + " .--+-------.\n", + " |Sparse[n3]|\n", + " `----------'\n", + " \"\"\"\n", + " )\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "1d023620", + "metadata": {}, + "source": [ + "# Examples for rank 4 array\n", + "\n", + "Pass COO-like data to `SparseTensor` with one array of indices for each dimension.\n", + "\n", + "The default is to create CSF sparse data structure where all but the last dimension are doubly compressed." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "56701aef", + "metadata": {}, + "outputs": [], + "source": [ + "group_indices = True # Whether or not to group indices in diagrams below" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "3f4ad63f", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " i1\n", + " \n", + " i2\n", + " i3\n", + " \n", + " S\n", + " DC\n", + " S\n", + " S\n", + " p1\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 0\n", + " 0\n", + " 0\n", + " 2\n", + " 1\n", + " 0\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|S DC ----|S S -|\n", + ".------. .------.\n", + "|i0 i1 |p1 |i2 i3 |\n", + "`------' `------'\n", + "===================\n", + ".-----. 0 .-----.\n", + "|0 0 |-+--|0 1 |\n", + "`-----' | `-----'\n", + " | .-----.\n", + " `--|0 2 |\n", + " 2 `-----'\n", + ".-----. .-----.\n", + "|0 1 |-+--|0 0 |\n", + "`-----' | `-----'\n", + " | .-----.\n", + " |--|0 2 |\n", + " | `-----'\n", + " | .-----.\n", + " `--|1 0 |\n", + " 5 `-----'\n", + ".-----. .-----.\n", + "|1 1 |-+--|1 0 |\n", + "`-----' | `-----'\n", + " | .-----.\n", + " |--|1 1 |\n", + " | `-----'\n", + " | .-----.\n", + " `--|1 2 |\n", + " 8 `-----'" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from sparsetensorviz import SparseTensor\n", + "import itertools\n", + "import IPython\n", + "\n", + "indices = [\n", + " [0, 0, 0, 0, 0, 1, 1, 1],\n", + " [0, 0, 1, 1, 1, 1, 1, 1],\n", + " [0, 0, 0, 0, 1, 1, 1, 1],\n", + " [1, 2, 0, 2, 0, 0, 1, 2],\n", + "]\n", + "sp = SparseTensor(indices, structure=\"S-DC-S-S\", group_indices=group_indices)\n", + "# Display as SVG diagram\n", + "sp" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "833d4e98", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[array([0, 0, 1]),\n", + " array([0, 1, 1]),\n", + " array([0, 0, 0, 0, 1, 1, 1, 1]),\n", + " array([1, 2, 0, 2, 0, 0, 1, 2])]" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sp.indices" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "e3399807", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[None, array([0, 2, 5, 8]), None]" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sp.pointers" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "e0bdf4f2", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "|S DC ----|S S -|\n", + ".------. .------.\n", + "|i0 i1 |p1 |i2 i3 |\n", + "`------' `------'\n", + "===================\n", + ".-----. 0 .-----.\n", + "|0 0 |-+--|0 1 |\n", + "`-----' | `-----'\n", + " | .-----.\n", + " `--|0 2 |\n", + " 2 `-----'\n", + ".-----. .-----.\n", + "|0 1 |-+--|0 0 |\n", + "`-----' | `-----'\n", + " | .-----.\n", + " |--|0 2 |\n", + " | `-----'\n", + " | .-----.\n", + " `--|1 0 |\n", + " 5 `-----'\n", + ".-----. .-----.\n", + "|1 1 |-+--|1 0 |\n", + "`-----' | `-----'\n", + " | .-----.\n", + " |--|1 1 |\n", + " | `-----'\n", + " | .-----.\n", + " `--|1 2 |\n", + " 8 `-----'\n" + ] + } + ], + "source": [ + "# Can also display as ASCII diagram\n", + "print(sp)" + ] + }, + { + "cell_type": "markdown", + "id": "1092fc4b", + "metadata": {}, + "source": [ + "This diagram forms a tree-like structure where the first dimension is on the left and last dimension is on the right.\n", + "\n", + "Index values are in boxes, and pointer values are next to edges.\n", + "\n", + "We can choose how each dimension is compressed with any of the following:\n", + "- **`S`, \"sparse\"**: like COO; indices are \"aligned\" to the following dimension indices or values.\n", + " - Uses: `indices_i`\n", + "- **`C`, \"compressed\"**: like CSR; fast lookup by index into pointers to the next dimension.\n", + " - Uses: `pointers_i`\n", + " - Makes `pointers_{i-1}` unnecessary\n", + "- **`DC`, \"doubly compressed\"**: like DCSR; store unique index values and pointers to the next dimension.\n", + " - Uses: `pointers_i`, `indices_i`\n", + "\n", + "Currently, the final dimension must be sparse, **`S`**.\n", + "\n", + "Hence, describing the structures of **CSR, CSC, DCSR, and DCSC** give us... CSR, CSC, DCSR, and DCSC (let's address the final \"R\" and \"C\" later)." + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "917fc617", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['HyperSparse(2)', 'Coord(2)']" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sp.bundled_groups" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "b8253a23", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[sparse, doubly_compressed, sparse, sparse]" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sp.structure" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "ec61aa11", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'S-DC-S-S'" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sp.abbreviation" + ] + }, + { + "cell_type": "markdown", + "id": "51842351", + "metadata": {}, + "source": [ + "## Display all sparse structures that are independent of shape\n", + "\n", + "This includes sparse structures that have no \"compressed sparse\" (**`C`**) dimensions.\n", + "\n", + "Hyphonated connecting lines indicate pointers that don't need stored." + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "03f416ee-3b94-4044-8f4f-6e6f5d76b199", + "metadata": {}, + "outputs": [], + "source": [ + "# Helper function\n", + "seen_taco = {}\n", + "\n", + "\n", + "def to_tim(st):\n", + " rv = []\n", + " for gp in st.bundled_groups:\n", + " if \"expanded=\" in gp:\n", + " return\n", + " num = int(gp[:-1].split(\"(\", 1)[1])\n", + " if gp.startswith(\"Coord\"):\n", + " rv.extend([\"index\"] * num)\n", + " elif gp.startswith(\"Full\"):\n", + " rv.extend([\"full\"] * num)\n", + " elif gp.startswith(\"Sparse\"):\n", + " rv.extend([\"sparse\"] * num)\n", + " elif gp.startswith(\"Hyper\"):\n", + " rv.extend([\"index\"] * (num - 1))\n", + " rv.append(\"hyper\")\n", + " else:\n", + " raise ValueError(f\"Bad group: {gp}\")\n", + " return rv\n", + "\n", + "\n", + "def display_header(st, *, align=False, seen_taco=None):\n", + " key = tuple(st.taco_structure)\n", + " if seen_taco and key in seen_taco:\n", + " seen_text = \" # (seen)\"\n", + " else:\n", + " seen_text = \"\"\n", + " if seen_taco is not None:\n", + " seen_taco[key] = st.structure\n", + " bundled = \", \".join(st.bundled_groups)\n", + " tim_structure = to_tim(st)\n", + " if align:\n", + " if tim_structure is not None:\n", + " widths = [\n", + " max(len(str(x)), len(y), len(z))\n", + " for x, y, z in zip(st.structure, st.taco_structure, tim_structure)\n", + " ]\n", + " else:\n", + " widths = [max(len(str(x)), len(y)) for x, y in zip(st.structure, st.taco_structure)]\n", + " structure = \", \".join(\n", + " str(sparse).rjust(width) for sparse, width in zip(st.structure, widths)\n", + " )\n", + " if tim_structure is None:\n", + " tim_structure = \"N/A\"\n", + " else:\n", + " tim_structure = (\n", + " \"[\"\n", + " + \", \".join(sparse.rjust(width) for sparse, width in zip(tim_structure, widths))\n", + " + \"]\"\n", + " )\n", + " taco_structure = \", \".join(\n", + " sparse.rjust(width) for sparse, width in zip(st.taco_structure, widths)\n", + " )\n", + " text = (\n", + " \"```\\n\"\n", + " f\"bundled_groups = [{bundled}]\\n\\n\"\n", + " f\"tim_structure = {tim_structure}\\n\\n\"\n", + " f\"structure = [{structure}]\\n\\n\"\n", + " f\"taco_structure = [{taco_structure}]{seen_text}\\n\\n\"\n", + " \"```\"\n", + " )\n", + " else:\n", + " taco_structure = \", \".join(st.taco_structure)\n", + " if tim_structure is None:\n", + " tim_structure = \"N/A\"\n", + " else:\n", + " tim_structure = \"[\" + \", \".join(tim_structure) + \"]\"\n", + " text = (\n", + " \"```\\n\"\n", + " f\"bundled_groups = [{bundled}]\\n\\n\"\n", + " f\"tim_structure = {tim_structure}\\n\\n\"\n", + " f\"structure = {st.structure}\\n\\n\"\n", + " f\"taco_structure = [{taco_structure}]{seen_text}\\n\\n\"\n", + " \"```\"\n", + " )\n", + " IPython.display.display(IPython.display.Markdown(text))" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "232210ab", + "metadata": { + "scrolled": false + }, + "outputs": [ + { + "data": { + "text/markdown": [ + "# `S-S-S-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Coord(4)]\n", + "\n", + "tim_structure = [index, index, index, index]\n", + "\n", + "structure = [sparse, sparse, sparse, sparse]\n", + "\n", + "taco_structure = [compressed-nonunique, singleton, singleton, singleton]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " i1\n", + " i2\n", + " i3\n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 2\n", + " \n", + " 0\n", + " 1\n", + " 0\n", + " 0\n", + " \n", + " 0\n", + " 1\n", + " 0\n", + " 2\n", + " \n", + " 0\n", + " 1\n", + " 1\n", + " 0\n", + " \n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " \n", + " 1\n", + " 1\n", + " 1\n", + " 1\n", + " \n", + " 1\n", + " 1\n", + " 1\n", + " 2\n", + " \n", + " S\n", + " S\n", + " S\n", + " S\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|S S S S -|\n", + ".------------.\n", + "|i0 i1 i2 i3 |\n", + "`------------'\n", + "==============\n", + ".-----------.\n", + "|0 0 0 1 |\n", + "`-----------'\n", + ".-----------.\n", + "|0 0 0 2 |\n", + "`-----------'\n", + ".-----------.\n", + "|0 1 0 0 |\n", + "`-----------'\n", + ".-----------.\n", + "|0 1 0 2 |\n", + "`-----------'\n", + ".-----------.\n", + "|0 1 1 0 |\n", + "`-----------'\n", + ".-----------.\n", + "|1 1 1 0 |\n", + "`-----------'\n", + ".-----------.\n", + "|1 1 1 1 |\n", + "`-----------'\n", + ".-----------.\n", + "|1 1 1 2 |\n", + "`-----------'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `S-S-DC-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [HyperSparse(3), Coord(1)]\n", + "\n", + "tim_structure = [index, index, hyper, index]\n", + "\n", + "structure = [sparse, sparse, doubly_compressed, sparse]\n", + "\n", + "taco_structure = [compressed, singleton, singleton, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " i1\n", + " i2\n", + " \n", + " i3\n", + " \n", + " S\n", + " S\n", + " DC\n", + " S\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 4\n", + " 0\n", + " 1\n", + " 1\n", + " 0\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|S S DC ----|S -|\n", + ".---------. .---.\n", + "|i0 i1 i2 |p2 |i3 |\n", + "`---------' `---'\n", + "===================\n", + ".--------. 0 .--.\n", + "|0 0 0 |-+--|1 |\n", + "`--------' `--|2 |\n", + ".--------. 2 |--|\n", + "|0 1 0 |-+--|0 |\n", + "`--------' `--|2 |\n", + ".--------. 4 |--|\n", + "|0 1 1 |----|0 |\n", + "`--------' 5 `--'\n", + ".--------. .--.\n", + "|1 1 1 |-+--|0 |\n", + "`--------' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `S-DC-S-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [HyperSparse(2), Coord(2)]\n", + "\n", + "tim_structure = [index, hyper, index, index]\n", + "\n", + "structure = [sparse, doubly_compressed, sparse, sparse]\n", + "\n", + "taco_structure = [compressed, singleton, compressed-nonunique, singleton]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " i1\n", + " \n", + " i2\n", + " i3\n", + " \n", + " S\n", + " DC\n", + " S\n", + " S\n", + " p1\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 0\n", + " 0\n", + " 0\n", + " 2\n", + " 1\n", + " 0\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|S DC ----|S S -|\n", + ".------. .------.\n", + "|i0 i1 |p1 |i2 i3 |\n", + "`------' `------'\n", + "===================\n", + ".-----. 0 .-----.\n", + "|0 0 |-+--|0 1 |\n", + "`-----' | `-----'\n", + " | .-----.\n", + " `--|0 2 |\n", + " 2 `-----'\n", + ".-----. .-----.\n", + "|0 1 |-+--|0 0 |\n", + "`-----' | `-----'\n", + " | .-----.\n", + " |--|0 2 |\n", + " | `-----'\n", + " | .-----.\n", + " `--|1 0 |\n", + " 5 `-----'\n", + ".-----. .-----.\n", + "|1 1 |-+--|1 0 |\n", + "`-----' | `-----'\n", + " | .-----.\n", + " |--|1 1 |\n", + " | `-----'\n", + " | .-----.\n", + " `--|1 2 |\n", + " 8 `-----'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `S-DC-DC-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [HyperSparse(2), HyperSparse(1), Coord(1)]\n", + "\n", + "tim_structure = [index, hyper, hyper, index]\n", + "\n", + "structure = [sparse, doubly_compressed, doubly_compressed, sparse]\n", + "\n", + "taco_structure = [compressed, singleton, compressed, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " S\n", + " DC\n", + " DC\n", + " S\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|S DC ----|DC ----|S -|\n", + ".------. .---. .---.\n", + "|i0 i1 |p1 |i2 |p2 |i3 |\n", + "`------' `---' `---'\n", + "========================\n", + ".-----. 0 .--. 0 .--.\n", + "|0 0 |----|0 |-+--|1 |\n", + "`-----' 1 `--' `--|2 |\n", + ".-----. .--. 2 |--|\n", + "|0 1 |-+--|0 |-+--|0 |\n", + "`-----' | `--' `--|2 |\n", + " | .--. 4 |--|\n", + " `--|1 |----|0 |\n", + " 3 `--' 5 `--'\n", + ".-----. .--. .--.\n", + "|1 1 |----|1 |-+--|0 |\n", + "`-----' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `DC-S-S-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [HyperSparse(1), Coord(3)]\n", + "\n", + "tim_structure = [hyper, index, index, index]\n", + "\n", + "structure = [doubly_compressed, sparse, sparse, sparse]\n", + "\n", + "taco_structure = [compressed, compressed-nonunique, singleton, singleton]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " i2\n", + " i3\n", + " \n", + " DC\n", + " S\n", + " S\n", + " S\n", + " p0\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 1\n", + " 0\n", + " 2\n", + " 1\n", + " 1\n", + " 0\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 1\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|DC ----|S S S -|\n", + ".---. .---------.\n", + "|i0 |p0 |i1 i2 i3 |\n", + "`---' `---------'\n", + "===================\n", + ".--. 0 .--------.\n", + "|0 |-+--|0 0 1 |\n", + "`--' | `--------'\n", + " | .--------.\n", + " |--|0 0 2 |\n", + " | `--------'\n", + " | .--------.\n", + " |--|1 0 0 |\n", + " | `--------'\n", + " | .--------.\n", + " |--|1 0 2 |\n", + " | `--------'\n", + " | .--------.\n", + " `--|1 1 0 |\n", + " 5 `--------'\n", + ".--. .--------.\n", + "|1 |-+--|1 1 0 |\n", + "`--' | `--------'\n", + " | .--------.\n", + " |--|1 1 1 |\n", + " | `--------'\n", + " | .--------.\n", + " `--|1 1 2 |\n", + " 8 `--------'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `DC-S-DC-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [HyperSparse(1), HyperSparse(2), Coord(1)]\n", + "\n", + "tim_structure = [hyper, index, hyper, index]\n", + "\n", + "structure = [doubly_compressed, sparse, doubly_compressed, sparse]\n", + "\n", + "taco_structure = [compressed, compressed, singleton, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " i2\n", + " \n", + " i3\n", + " \n", + " DC\n", + " S\n", + " DC\n", + " S\n", + " p0\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 4\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|DC ----|S DC ----|S -|\n", + ".---. .------. .---.\n", + "|i0 |p0 |i1 i2 |p2 |i3 |\n", + "`---' `------' `---'\n", + "========================\n", + ".--. 0 .-----. 0 .--.\n", + "|0 |-+--|0 0 |-+--|1 |\n", + "`--' | `-----' `--|2 |\n", + " | .-----. 2 |--|\n", + " |--|1 0 |-+--|0 |\n", + " | `-----' `--|2 |\n", + " | .-----. 4 |--|\n", + " `--|1 1 |----|0 |\n", + " 3 `-----' 5 `--'\n", + ".--. .-----. .--.\n", + "|1 |----|1 1 |-+--|0 |\n", + "`--' 4 `-----' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `DC-DC-S-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [HyperSparse(1), HyperSparse(1), Coord(2)]\n", + "\n", + "tim_structure = [hyper, hyper, index, index]\n", + "\n", + "structure = [doubly_compressed, doubly_compressed, sparse, sparse]\n", + "\n", + "taco_structure = [compressed, compressed, compressed-nonunique, singleton]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " i3\n", + " \n", + " DC\n", + " DC\n", + " S\n", + " S\n", + " p0\n", + " p1\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 0\n", + " 2\n", + " 1\n", + " 0\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 1\n", + " 1\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|DC ----|DC ----|S S -|\n", + ".---. .---. .------.\n", + "|i0 |p0 |i1 |p1 |i2 i3 |\n", + "`---' `---' `------'\n", + "========================\n", + ".--. 0 .--. 0 .-----.\n", + "|0 |-+--|0 |-+--|0 1 |\n", + "`--' | `--' | `-----'\n", + " | | .-----.\n", + " | `--|0 2 |\n", + " | 2 `-----'\n", + " | .--. .-----.\n", + " `--|1 |-+--|0 0 |\n", + " 2 `--' | `-----'\n", + " | .-----.\n", + " |--|0 2 |\n", + " | `-----'\n", + " | .-----.\n", + " `--|1 0 |\n", + " 5 `-----'\n", + ".--. .--. .-----.\n", + "|1 |----|1 |-+--|1 0 |\n", + "`--' 3 `--' | `-----'\n", + " | .-----.\n", + " |--|1 1 |\n", + " | `-----'\n", + " | .-----.\n", + " `--|1 2 |\n", + " 8 `-----'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `DC-DC-DC-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [HyperSparse(1), HyperSparse(1), HyperSparse(1), Coord(1)]\n", + "\n", + "tim_structure = [hyper, hyper, hyper, index]\n", + "\n", + "structure = [doubly_compressed, doubly_compressed, doubly_compressed, sparse]\n", + "\n", + "taco_structure = [compressed, compressed, compressed, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " DC\n", + " DC\n", + " DC\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|DC ----|DC ----|DC ----|S -|\n", + ".---. .---. .---. .---.\n", + "|i0 |p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`---' `---' `---' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .--. 0 .--.\n", + "|0 |-+--|0 |----|0 |-+--|1 |\n", + "`--' | `--' 1 `--' `--|2 |\n", + " | .--. .--. 2 |--|\n", + " `--|1 |-+--|0 |-+--|0 |\n", + " 2 `--' | `--' `--|2 |\n", + " | .--. 4 |--|\n", + " `--|1 |----|0 |\n", + " 3 `--' 5 `--'\n", + ".--. .--. .--. .--.\n", + "|1 |----|1 |----|1 |-+--|0 |\n", + "`--' 3 `--' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "sparsities = [\"S\", \"DC\"]\n", + "for sparsity in itertools.product(sparsities, sparsities, sparsities, [\"S\"]):\n", + " structure = \"-\".join(sparsity)\n", + " IPython.display.display(IPython.display.Markdown(f\"# `{structure}`\"))\n", + " st = SparseTensor(indices, structure=structure, group_indices=group_indices)\n", + " display_header(st, seen_taco=seen_taco)\n", + " IPython.display.display(st)" + ] + }, + { + "cell_type": "markdown", + "id": "eec6fad5", + "metadata": {}, + "source": [ + "## Display sparse structures, `shape=(2, 2, 2, 3)`\n", + "\n", + "Hyphonated boxes indicate indices that don't need stored.\n", + "\n", + "For compressed sparse dimensions, `C`, some repeated pointer values may be skipped if there is no room" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "c8e1d2a7", + "metadata": { + "scrolled": false + }, + "outputs": [ + { + "data": { + "text/markdown": [ + "# `S-S-C-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Coord(2, expanded=1), Sparse(1), Coord(1)]\n", + "\n", + "tim_structure = N/A\n", + "\n", + "structure = [sparse, sparse, compressed, sparse]\n", + "\n", + "taco_structure = [compressed-nonunique, singleton, dense, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " S\n", + " S\n", + " C\n", + " S\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 0\n", + " 3\n", + " 2\n", + " 4\n", + " 0\n", + " 1\n", + " 0\n", + " 4\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 6\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|S S -----|C -----|S -|\n", + ".------. .~~~. .---.\n", + "|i0 i1 |p1 ┊i2 ┊p2 |i3 |\n", + "`------' `~~~' `---'\n", + "========================\n", + ".-----. 0 .~~. 0 .--.\n", + "|0 0 |~~~~┊0 ┊-+--|1 |\n", + "`-----' 1 `~~' `--|2 |\n", + ".-----. .~~. 2 `--'\n", + "|0 0 |~~~~┊1 ┊)\n", + "`-----' 2 `~~'\n", + ".-----. .~~. 2 .--.\n", + "|0 1 |~~~~┊0 ┊-+--|0 |\n", + "`-----' 3 `~~' `--|2 |\n", + ".-----. .~~. 4 |--|\n", + "|0 1 |~~~~┊1 ┊----|0 |\n", + "`-----' 4 `~~' 5 `--'\n", + ".-----. .~~.\n", + "|1 1 |~~~~┊0 ┊)\n", + "`-----' 5 `~~'\n", + ".-----. .~~. 5 .--.\n", + "|1 1 |~~~~┊1 ┊-+--|0 |\n", + "`-----' 6 `~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `S-C-S-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Coord(1, expanded=1), Sparse(1), Coord(2)]\n", + "\n", + "tim_structure = N/A\n", + "\n", + "structure = [sparse, compressed, sparse, sparse]\n", + "\n", + "taco_structure = [compressed-nonunique, dense, compressed-nonunique, singleton]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " S\n", + " C\n", + " S\n", + " S\n", + " p0\n", + " p1\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 0\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 3\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 4\n", + " 1\n", + " 1\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|S -----|C -----|S S -|\n", + ".---. .~~~. .------.\n", + "|i0 |p0 ┊i1 ┊p1 |i2 i3 |\n", + "`---' `~~~' `------'\n", + "========================\n", + ".--. 0 .~~. 0 .-----.\n", + "|0 |~~~~┊0 ┊-+--|0 1 |\n", + "`--' 1 `~~' | `-----'\n", + " | .-----.\n", + " `--|0 2 |\n", + " 2 `-----'\n", + ".--. .~~. .-----.\n", + "|0 |~~~~┊1 ┊-+--|0 0 |\n", + "`--' 2 `~~' | `-----'\n", + ".--. .~~. | .-----.\n", + "|1 |~~~~┊0 ┊)|--|0 2 |\n", + "`--' 3 `~~' | `-----'\n", + " | .-----.\n", + " `--|1 0 |\n", + " 5 `-----'\n", + ".--. .~~. 5 .-----.\n", + "|1 |~~~~┊1 ┊-+--|1 0 |\n", + "`--' 4 `~~' | `-----'\n", + " | .-----.\n", + " |--|1 1 |\n", + " | `-----'\n", + " | .-----.\n", + " `--|1 2 |\n", + " 8 `-----'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `S-C-C-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Coord(1, expanded=1), Sparse(2), Coord(1)]\n", + "\n", + "tim_structure = N/A\n", + "\n", + "structure = [sparse, compressed, compressed, sparse]\n", + "\n", + "taco_structure = [compressed-nonunique, dense, dense, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i3\n", + " \n", + " S\n", + " C\n", + " C\n", + " S\n", + " p0\n", + " i1\n", + " i2\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 2\n", + " 0\n", + " 0\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 5\n", + " 0\n", + " 1\n", + " 0\n", + " 5\n", + " 1\n", + " 0\n", + " 1\n", + " 2\n", + " 8\n", + " 0\n", + " 1\n", + " 2\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 1\n", + " 1\n", + " 4\n", + " 5\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|S -----|C C -----|S -|\n", + ".---. .~~ ~~~. .---.\n", + "|i0 |p0 ┊i1 i2 ┊p2 |i3 |\n", + "`---' `~~ ~~~' `---'\n", + "========================\n", + ".--. 0 .~~ ~~. 0 .--.\n", + "|0 |~~~~┊0 0 ┊-+--|1 |\n", + "`--' 1 `~~ ~~' `--|2 |\n", + " ~~. 2 `--'\n", + " 1 ┊)\n", + " ~~'\n", + ".--. .~~ ~~. 2 .--.\n", + "|0 |~~~~┊1 0 ┊-+--|0 |\n", + "`--' 2 `~~ ~~' `--|2 |\n", + " ~~. 4 |--|\n", + " 1 ┊----|0 |\n", + " ~~' 5 `--'\n", + ".--. .~~ ~~.\n", + "|1 |~~~~┊0 0 ┊)\n", + "`--' 3 `~~ ~~'\n", + " ~~. 5\n", + " 1 ┊)\n", + " ~~'\n", + ".--. .~~ ~~. 5\n", + "|1 |~~~~┊1 0 ┊)\n", + "`--' 4 `~~ ~~'\n", + " ~~. 5 .--.\n", + " 1 ┊-+--|0 |\n", + " ~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `S-C-DC-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Coord(1, expanded=1), Sparse(1), HyperSparse(1), Coord(1)]\n", + "\n", + "tim_structure = N/A\n", + "\n", + "structure = [sparse, compressed, doubly_compressed, sparse]\n", + "\n", + "taco_structure = [compressed-nonunique, dense, compressed, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " S\n", + " C\n", + " DC\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 1\n", + " 0\n", + " 3\n", + " 3\n", + " 5\n", + " 3\n", + " 1\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|S -----|C -----|DC ----|S -|\n", + ".---. .~~~. .---. .---.\n", + "|i0 |p0 ┊i1 ┊p1 |i2 |p2 |i3 |\n", + "`---' `~~~' `---' `---'\n", + "=============================\n", + ".--. 0 .~~. 0 .--. 0 .--.\n", + "|0 |~~~~┊0 ┊----|0 |-+--|1 |\n", + "`--' 1 `~~' 1 `--' `--|2 |\n", + ".--. .~~. .--. 2 |--|\n", + "|0 |~~~~┊1 ┊-+--|0 |-+--|0 |\n", + "`--' 2 `~~' | `--' `--|2 |\n", + ".--. .~~. | .--. 4 |--|\n", + "|1 |~~~~┊0 ┊)`--|1 |----|0 |\n", + "`--' 3 `~~' 3 `--' 5 `--'\n", + ".--. .~~. 3 .--. .--.\n", + "|1 |~~~~┊1 ┊----|1 |-+--|0 |\n", + "`--' 4 `~~' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `S-DC-C-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Coord(2), Sparse(1), Coord(1)]\n", + "\n", + "tim_structure = [index, index, sparse, index]\n", + "\n", + "structure = [sparse, doubly_compressed, compressed, sparse]\n", + "\n", + "taco_structure = [compressed, singleton, dense, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " S\n", + " DC\n", + " C\n", + " S\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 0\n", + " 2\n", + " 4\n", + " 0\n", + " 4\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 5\n", + " 0\n", + " 6\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|S DC ----|C -----|S -|\n", + ".------. .~~~. .---.\n", + "|i0 i1 |p1 ┊i2 ┊p2 |i3 |\n", + "`------' `~~~' `---'\n", + "========================\n", + ".-----. 0 .~~. 0 .--.\n", + "|0 0 |~+~~┊0 ┊-+--|1 |\n", + "`-----' ┊ `~~' `--|2 |\n", + " ┊ .~~. 2 `--'\n", + " `~~┊1 ┊)\n", + " 2 `~~'\n", + ".-----. .~~. 2 .--.\n", + "|0 1 |~+~~┊0 ┊-+--|0 |\n", + "`-----' ┊ `~~' `--|2 |\n", + " ┊ .~~. 4 |--|\n", + " `~~┊1 ┊----|0 |\n", + " 4 `~~' 5 `--'\n", + ".-----. .~~.\n", + "|1 1 |~+~~┊0 ┊)\n", + "`-----' ┊ `~~'\n", + " ┊ .~~. 5 .--.\n", + " `~~┊1 ┊-+--|0 |\n", + " 6 `~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-S-S-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Sparse(1), Coord(3)]\n", + "\n", + "tim_structure = [sparse, index, index, index]\n", + "\n", + "structure = [compressed, sparse, sparse, sparse]\n", + "\n", + "taco_structure = [dense, compressed-nonunique, singleton, singleton]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " i2\n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " C\n", + " S\n", + " S\n", + " S\n", + " p0\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 1\n", + " 0\n", + " 2\n", + " 1\n", + " 1\n", + " 0\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 1\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|S S S -|\n", + ".~~~. .---------.\n", + "┊i0 ┊p0 |i1 i2 i3 |\n", + "`~~~' `---------'\n", + "===================\n", + ".~~. 0 .--------.\n", + "┊0 ┊-+--|0 0 1 |\n", + "`~~' | `--------'\n", + " | .--------.\n", + " |--|0 0 2 |\n", + " | `--------'\n", + " | .--------.\n", + " |--|1 0 0 |\n", + " | `--------'\n", + " | .--------.\n", + " |--|1 0 2 |\n", + " | `--------'\n", + " | .--------.\n", + " `--|1 1 0 |\n", + " 5 `--------'\n", + ".~~. .--------.\n", + "┊1 ┊-+--|1 1 0 |\n", + "`~~' | `--------'\n", + " | .--------.\n", + " |--|1 1 1 |\n", + " | `--------'\n", + " | .--------.\n", + " `--|1 1 2 |\n", + " 8 `--------'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-S-C-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Sparse(1), Coord(1, expanded=1), Sparse(1), Coord(1)]\n", + "\n", + "tim_structure = N/A\n", + "\n", + "structure = [compressed, sparse, compressed, sparse]\n", + "\n", + "taco_structure = [dense, compressed-nonunique, dense, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " C\n", + " S\n", + " C\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 3\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 5\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 1\n", + " 0\n", + " 6\n", + " 6\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|S -----|C -----|S -|\n", + ".~~~. .---. .~~~. .---.\n", + "┊i0 ┊p0 |i1 |p1 ┊i2 ┊p2 |i3 |\n", + "`~~~' `---' `~~~' `---'\n", + "=============================\n", + ".~~. 0 .--. 0 .~~. 0 .--.\n", + "┊0 ┊-+--|0 |~~~~┊0 ┊-+--|1 |\n", + "`~~' | `--' 1 `~~' `--|2 |\n", + " | .--. .~~. 2 `--'\n", + " |--|0 |~~~~┊1 ┊)\n", + " | `--' 2 `~~'\n", + " | .--. .~~. 2 .--.\n", + " |--|1 |~~~~┊0 ┊-+--|0 |\n", + " | `--' 3 `~~' `--|2 |\n", + " | .--. .~~. 4 |--|\n", + " `--|1 |~~~~┊1 ┊----|0 |\n", + " 4 `--' 4 `~~' 5 `--'\n", + ".~~. .--. .~~.\n", + "┊1 ┊-+--|1 |~~~~┊0 ┊)\n", + "`~~' | `--' 5 `~~'\n", + " | .--. .~~. 5 .--.\n", + " `--|1 |~~~~┊1 ┊-+--|0 |\n", + " 6 `--' 6 `~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-S-DC-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Sparse(1), HyperSparse(2), Coord(1)]\n", + "\n", + "tim_structure = [sparse, index, hyper, index]\n", + "\n", + "structure = [compressed, sparse, doubly_compressed, sparse]\n", + "\n", + "taco_structure = [dense, compressed, singleton, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " C\n", + " S\n", + " DC\n", + " S\n", + " p0\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 4\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|S DC ----|S -|\n", + ".~~~. .------. .---.\n", + "┊i0 ┊p0 |i1 i2 |p2 |i3 |\n", + "`~~~' `------' `---'\n", + "========================\n", + ".~~. 0 .-----. 0 .--.\n", + "┊0 ┊-+--|0 0 |-+--|1 |\n", + "`~~' | `-----' `--|2 |\n", + " | .-----. 2 |--|\n", + " |--|1 0 |-+--|0 |\n", + " | `-----' `--|2 |\n", + " | .-----. 4 |--|\n", + " `--|1 1 |----|0 |\n", + " 3 `-----' 5 `--'\n", + ".~~. .-----. .--.\n", + "┊1 ┊----|1 1 |-+--|0 |\n", + "`~~' 4 `-----' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-C-S-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Sparse(2), Coord(2)]\n", + "\n", + "tim_structure = [sparse, sparse, index, index]\n", + "\n", + "structure = [compressed, compressed, sparse, sparse]\n", + "\n", + "taco_structure = [dense, dense, compressed-nonunique, singleton]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i2\n", + " i3\n", + " \n", + " C\n", + " C\n", + " S\n", + " S\n", + " i0\n", + " i1\n", + " p1\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 2\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 2\n", + " 8\n", + " 1\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C C -----|S S -|\n", + ".~~ ~~~. .------.\n", + "┊i0 i1 ┊p1 |i2 i3 |\n", + "`~~ ~~~' `------'\n", + "===================\n", + ".~~ ~~. 0 .-----.\n", + "┊0 0 ┊-+--|0 1 |\n", + "`~~ ~~' | `-----'\n", + " | .-----.\n", + " `--|0 2 |\n", + " 2 `-----'\n", + " ~~. .-----.\n", + " 1 ┊-+--|0 0 |\n", + " ~~' | `-----'\n", + ".~~ ~~. | .-----.\n", + "┊1 0 ┊)|--|0 2 |\n", + "`~~ ~~' | `-----'\n", + " | .-----.\n", + " `--|1 0 |\n", + " 5 `-----'\n", + " ~~. 5 .-----.\n", + " 1 ┊-+--|1 0 |\n", + " ~~' | `-----'\n", + " | .-----.\n", + " |--|1 1 |\n", + " | `-----'\n", + " | .-----.\n", + " `--|1 2 |\n", + " 8 `-----'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-C-C-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Sparse(3), Coord(1)]\n", + "\n", + "tim_structure = [sparse, sparse, sparse, index]\n", + "\n", + "structure = [compressed, compressed, compressed, sparse]\n", + "\n", + "taco_structure = [dense, dense, dense, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i3\n", + " \n", + " C\n", + " C\n", + " C\n", + " S\n", + " \n", + " i0\n", + " i1\n", + " i2\n", + " p2\n", + " \n", + " \n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " \n", + " 2\n", + " 2\n", + " 1\n", + " 2\n", + " 0\n", + " 0\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 5\n", + " 0\n", + " 1\n", + " 0\n", + " 5\n", + " 1\n", + " 0\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 0\n", + " \n", + " 5\n", + " \n", + " 1\n", + " \n", + " 5\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C C C -----|S -|\n", + ".~~ ~~ ~~~. .---.\n", + "┊i0 i1 i2 ┊p2 |i3 |\n", + "`~~ ~~ ~~~' `---'\n", + "===================\n", + ".~~ ~~ ~~. 0 .--.\n", + "┊0 0 0 ┊-+--|1 |\n", + "`~~ ~~ ~~' `--|2 |\n", + " ~~. 2 `--'\n", + " 1 ┊)\n", + " ~~'\n", + " ~~ ~~. 2 .--.\n", + " 1 0 ┊-+--|0 |\n", + " ~~ ~~' `--|2 |\n", + " ~~. 4 |--|\n", + " 1 ┊----|0 |\n", + " ~~' 5 `--'\n", + ".~~ ~~ ~~.\n", + "┊1 0 0 ┊)\n", + "`~~ ~~ ~~'\n", + " ~~. 5\n", + " 1 ┊)\n", + " ~~'\n", + " ~~ ~~. 5\n", + " 1 0 ┊)\n", + " ~~ ~~'\n", + " ~~. 5 .--.\n", + " 1 ┊-+--|0 |\n", + " ~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-C-DC-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Sparse(2), HyperSparse(1), Coord(1)]\n", + "\n", + "tim_structure = [sparse, sparse, hyper, index]\n", + "\n", + "structure = [compressed, compressed, doubly_compressed, sparse]\n", + "\n", + "taco_structure = [dense, dense, compressed, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " C\n", + " C\n", + " DC\n", + " S\n", + " i0\n", + " i1\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 4\n", + " 0\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 3\n", + " 1\n", + " 1\n", + " 0\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " 1\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C C -----|DC ----|S -|\n", + ".~~ ~~~. .---. .---.\n", + "┊i0 i1 ┊p1 |i2 |p2 |i3 |\n", + "`~~ ~~~' `---' `---'\n", + "========================\n", + ".~~ ~~. 0 .--. 0 .--.\n", + "┊0 0 ┊----|0 |-+--|1 |\n", + "`~~ ~~' 1 `--' `--|2 |\n", + " ~~. .--. 2 |--|\n", + " 1 ┊-+--|0 |-+--|0 |\n", + " ~~' | `--' `--|2 |\n", + ".~~ ~~. | .--. 4 |--|\n", + "┊1 0 ┊)`--|1 |----|0 |\n", + "`~~ ~~' 3 `--' 5 `--'\n", + " ~~. 3 .--. .--.\n", + " 1 ┊----|1 |-+--|0 |\n", + " ~~' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-DC-S-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Sparse(1), HyperSparse(1), Coord(2)]\n", + "\n", + "tim_structure = [sparse, hyper, index, index]\n", + "\n", + "structure = [compressed, doubly_compressed, sparse, sparse]\n", + "\n", + "taco_structure = [dense, compressed, compressed-nonunique, singleton]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " C\n", + " DC\n", + " S\n", + " S\n", + " p0\n", + " p1\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 0\n", + " 2\n", + " 1\n", + " 0\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 1\n", + " 1\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|DC ----|S S -|\n", + ".~~~. .---. .------.\n", + "┊i0 ┊p0 |i1 |p1 |i2 i3 |\n", + "`~~~' `---' `------'\n", + "========================\n", + ".~~. 0 .--. 0 .-----.\n", + "┊0 ┊-+--|0 |-+--|0 1 |\n", + "`~~' | `--' | `-----'\n", + " | | .-----.\n", + " | `--|0 2 |\n", + " | 2 `-----'\n", + " | .--. .-----.\n", + " `--|1 |-+--|0 0 |\n", + " 2 `--' | `-----'\n", + " | .-----.\n", + " |--|0 2 |\n", + " | `-----'\n", + " | .-----.\n", + " `--|1 0 |\n", + " 5 `-----'\n", + ".~~. .--. .-----.\n", + "┊1 ┊----|1 |-+--|1 0 |\n", + "`~~' 3 `--' | `-----'\n", + " | .-----.\n", + " |--|1 1 |\n", + " | `-----'\n", + " | .-----.\n", + " `--|1 2 |\n", + " 8 `-----'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-DC-C-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Sparse(1), Coord(1), Sparse(1), Coord(1)]\n", + "\n", + "tim_structure = [sparse, index, sparse, index]\n", + "\n", + "structure = [compressed, doubly_compressed, compressed, sparse]\n", + "\n", + "taco_structure = [dense, compressed, dense, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " C\n", + " DC\n", + " C\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 0\n", + " 4\n", + " 5\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 0\n", + " 6\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|DC ----|C -----|S -|\n", + ".~~~. .---. .~~~. .---.\n", + "┊i0 ┊p0 |i1 |p1 ┊i2 ┊p2 |i3 |\n", + "`~~~' `---' `~~~' `---'\n", + "=============================\n", + ".~~. 0 .--. 0 .~~. 0 .--.\n", + "┊0 ┊-+--|0 |~+~~┊0 ┊-+--|1 |\n", + "`~~' | `--' ┊ `~~' `--|2 |\n", + " | ┊ .~~. 2 `--'\n", + " | `~~┊1 ┊)\n", + " | 2 `~~'\n", + " | .--. .~~. 2 .--.\n", + " `--|1 |~+~~┊0 ┊-+--|0 |\n", + " 2 `--' ┊ `~~' `--|2 |\n", + " ┊ .~~. 4 |--|\n", + " `~~┊1 ┊----|0 |\n", + " 4 `~~' 5 `--'\n", + ".~~. .--. .~~.\n", + "┊1 ┊----|1 |~+~~┊0 ┊)\n", + "`~~' 3 `--' ┊ `~~'\n", + " ┊ .~~. 5 .--.\n", + " `~~┊1 ┊-+--|0 |\n", + " 6 `~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-DC-DC-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Sparse(1), HyperSparse(1), HyperSparse(1), Coord(1)]\n", + "\n", + "tim_structure = [sparse, hyper, hyper, index]\n", + "\n", + "structure = [compressed, doubly_compressed, doubly_compressed, sparse]\n", + "\n", + "taco_structure = [dense, compressed, compressed, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " C\n", + " DC\n", + " DC\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|DC ----|DC ----|S -|\n", + ".~~~. .---. .---. .---.\n", + "┊i0 ┊p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`~~~' `---' `---' `---'\n", + "=============================\n", + ".~~. 0 .--. 0 .--. 0 .--.\n", + "┊0 ┊-+--|0 |----|0 |-+--|1 |\n", + "`~~' | `--' 1 `--' `--|2 |\n", + " | .--. .--. 2 |--|\n", + " `--|1 |-+--|0 |-+--|0 |\n", + " 2 `--' | `--' `--|2 |\n", + " | .--. 4 |--|\n", + " `--|1 |----|0 |\n", + " 3 `--' 5 `--'\n", + ".~~. .--. .--. .--.\n", + "┊1 ┊----|1 |----|1 |-+--|0 |\n", + "`~~' 3 `--' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `DC-S-C-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [HyperSparse(1), Coord(1, expanded=1), Sparse(1), Coord(1)]\n", + "\n", + "tim_structure = N/A\n", + "\n", + "structure = [doubly_compressed, sparse, compressed, sparse]\n", + "\n", + "taco_structure = [compressed, compressed-nonunique, dense, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " DC\n", + " S\n", + " C\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 3\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 1\n", + " 0\n", + " 6\n", + " 6\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|DC ----|S -----|C -----|S -|\n", + ".---. .---. .~~~. .---.\n", + "|i0 |p0 |i1 |p1 ┊i2 ┊p2 |i3 |\n", + "`---' `---' `~~~' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .~~. 0 .--.\n", + "|0 |-+--|0 |~~~~┊0 ┊-+--|1 |\n", + "`--' | `--' 1 `~~' `--|2 |\n", + " | .--. .~~. 2 `--'\n", + " |--|0 |~~~~┊1 ┊)\n", + " | `--' 2 `~~'\n", + " | .--. .~~. 2 .--.\n", + " |--|1 |~~~~┊0 ┊-+--|0 |\n", + " | `--' 3 `~~' `--|2 |\n", + " | .--. .~~. 4 |--|\n", + " `--|1 |~~~~┊1 ┊----|0 |\n", + " 4 `--' 4 `~~' 5 `--'\n", + ".--. .--. .~~.\n", + "|1 |-+--|1 |~~~~┊0 ┊)\n", + "`--' | `--' 5 `~~'\n", + " | .--. .~~. 5 .--.\n", + " `--|1 |~~~~┊1 ┊-+--|0 |\n", + " 6 `--' 6 `~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `DC-C-S-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Coord(1), Sparse(1), Coord(2)]\n", + "\n", + "tim_structure = [index, sparse, index, index]\n", + "\n", + "structure = [doubly_compressed, compressed, sparse, sparse]\n", + "\n", + "taco_structure = [compressed, dense, compressed-nonunique, singleton]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " DC\n", + " C\n", + " S\n", + " S\n", + " p0\n", + " p1\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 1\n", + " 0\n", + " 4\n", + " 1\n", + " 1\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|DC ----|C -----|S S -|\n", + ".---. .~~~. .------.\n", + "|i0 |p0 ┊i1 ┊p1 |i2 i3 |\n", + "`---' `~~~' `------'\n", + "========================\n", + ".--. 0 .~~. 0 .-----.\n", + "|0 |~+~~┊0 ┊-+--|0 1 |\n", + "`--' ┊ `~~' | `-----'\n", + " ┊ | .-----.\n", + " ┊ `--|0 2 |\n", + " ┊ 2 `-----'\n", + " ┊ .~~. .-----.\n", + " `~~┊1 ┊-+--|0 0 |\n", + " 2 `~~' | `-----'\n", + ".--. .~~. | .-----.\n", + "|1 |~+~~┊0 ┊)|--|0 2 |\n", + "`--' ┊ `~~' | `-----'\n", + " ┊ | .-----.\n", + " ┊ `--|1 0 |\n", + " ┊ 5 `-----'\n", + " ┊ .~~. 5 .-----.\n", + " `~~┊1 ┊-+--|1 0 |\n", + " 4 `~~' | `-----'\n", + " | .-----.\n", + " |--|1 1 |\n", + " | `-----'\n", + " | .-----.\n", + " `--|1 2 |\n", + " 8 `-----'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `DC-C-C-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Coord(1), Sparse(2), Coord(1)]\n", + "\n", + "tim_structure = [index, sparse, sparse, index]\n", + "\n", + "structure = [doubly_compressed, compressed, compressed, sparse]\n", + "\n", + "taco_structure = [compressed, dense, dense, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i3\n", + " \n", + " DC\n", + " C\n", + " C\n", + " S\n", + " p0\n", + " i1\n", + " i2\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 5\n", + " 0\n", + " 1\n", + " 0\n", + " 5\n", + " 1\n", + " 0\n", + " 1\n", + " 2\n", + " 8\n", + " 1\n", + " 0\n", + " 1\n", + " 4\n", + " 5\n", + " 5\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|DC ----|C C -----|S -|\n", + ".---. .~~ ~~~. .---.\n", + "|i0 |p0 ┊i1 i2 ┊p2 |i3 |\n", + "`---' `~~ ~~~' `---'\n", + "========================\n", + ".--. 0 .~~ ~~. 0 .--.\n", + "|0 |~+~~┊0 0 ┊-+--|1 |\n", + "`--' ┊ `~~ ~~' `--|2 |\n", + " ┊ ~~. 2 `--'\n", + " ┊ 1 ┊)\n", + " ┊ ~~'\n", + " ┊ .~~ ~~. 2 .--.\n", + " `~~┊1 0 ┊-+--|0 |\n", + " 2 `~~ ~~' `--|2 |\n", + " ~~. 4 |--|\n", + " 1 ┊----|0 |\n", + " ~~' 5 `--'\n", + ".--. .~~ ~~.\n", + "|1 |~+~~┊0 0 ┊)\n", + "`--' ┊ `~~ ~~'\n", + " ┊ ~~. 5\n", + " ┊ 1 ┊)\n", + " ┊ ~~'\n", + " ┊ .~~ ~~. 5\n", + " `~~┊1 0 ┊)\n", + " 4 `~~ ~~'\n", + " ~~. 5 .--.\n", + " 1 ┊-+--|0 |\n", + " ~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `DC-C-DC-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Coord(1), Sparse(1), HyperSparse(1), Coord(1)]\n", + "\n", + "tim_structure = [index, sparse, hyper, index]\n", + "\n", + "structure = [doubly_compressed, compressed, doubly_compressed, sparse]\n", + "\n", + "taco_structure = [compressed, dense, compressed, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " DC\n", + " C\n", + " DC\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 3\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|DC ----|C -----|DC ----|S -|\n", + ".---. .~~~. .---. .---.\n", + "|i0 |p0 ┊i1 ┊p1 |i2 |p2 |i3 |\n", + "`---' `~~~' `---' `---'\n", + "=============================\n", + ".--. 0 .~~. 0 .--. 0 .--.\n", + "|0 |~+~~┊0 ┊----|0 |-+--|1 |\n", + "`--' ┊ `~~' 1 `--' `--|2 |\n", + " ┊ .~~. .--. 2 |--|\n", + " `~~┊1 ┊-+--|0 |-+--|0 |\n", + " 2 `~~' | `--' `--|2 |\n", + ".--. .~~. | .--. 4 |--|\n", + "|1 |~+~~┊0 ┊)`--|1 |----|0 |\n", + "`--' ┊ `~~' 3 `--' 5 `--'\n", + " ┊ .~~. 3 .--. .--.\n", + " `~~┊1 ┊----|1 |-+--|0 |\n", + " 4 `~~' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `DC-DC-C-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [HyperSparse(1), Coord(1), Sparse(1), Coord(1)]\n", + "\n", + "tim_structure = [hyper, index, sparse, index]\n", + "\n", + "structure = [doubly_compressed, doubly_compressed, compressed, sparse]\n", + "\n", + "taco_structure = [compressed, compressed, dense, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " DC\n", + " DC\n", + " C\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 0\n", + " 4\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 0\n", + " 6\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|DC ----|DC ----|C -----|S -|\n", + ".---. .---. .~~~. .---.\n", + "|i0 |p0 |i1 |p1 ┊i2 ┊p2 |i3 |\n", + "`---' `---' `~~~' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .~~. 0 .--.\n", + "|0 |-+--|0 |~+~~┊0 ┊-+--|1 |\n", + "`--' | `--' ┊ `~~' `--|2 |\n", + " | ┊ .~~. 2 `--'\n", + " | `~~┊1 ┊)\n", + " | 2 `~~'\n", + " | .--. .~~. 2 .--.\n", + " `--|1 |~+~~┊0 ┊-+--|0 |\n", + " 2 `--' ┊ `~~' `--|2 |\n", + " ┊ .~~. 4 |--|\n", + " `~~┊1 ┊----|0 |\n", + " 4 `~~' 5 `--'\n", + ".--. .--. .~~.\n", + "|1 |----|1 |~+~~┊0 ┊)\n", + "`--' 3 `--' ┊ `~~'\n", + " ┊ .~~. 5 .--.\n", + " `~~┊1 ┊-+--|0 |\n", + " 6 `~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "sparsities = [\"S\", \"C\", \"DC\"]\n", + "for sparsity in itertools.product(sparsities, sparsities, sparsities, [\"S\"]):\n", + " if \"C\" not in sparsity:\n", + " continue\n", + " structure = \"-\".join(sparsity)\n", + " IPython.display.display(IPython.display.Markdown(f\"# `{structure}`\"))\n", + " st = SparseTensor(indices, shape=(2, 2, 2, 3), structure=structure, group_indices=group_indices)\n", + " display_header(st)\n", + " IPython.display.display(st)" + ] + }, + { + "cell_type": "markdown", + "id": "07f40f47", + "metadata": {}, + "source": [ + "# voilà!\n", + "\n", + "_Note that `Coord(n, expanded=1)`, which comes from `S-C` combination, is a silly data structure that duplicates data unnecessarily.\n", + "`Coord(n)` is strongly preferred._" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.8" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/sparsetensorviz/notebooks/Example_Rank4-taco.ipynb b/sparsetensorviz/notebooks/Example_Rank4-taco.ipynb new file mode 100644 index 0000000..642a8d2 --- /dev/null +++ b/sparsetensorviz/notebooks/Example_Rank4-taco.ipynb @@ -0,0 +1,11872 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "1d023620", + "metadata": {}, + "source": [ + "# Examples for rank 4 array using TACO-like dimensions\n", + "\n", + "Pass COO-like data to `SparseTensor` with one array of indices for each dimension.\n", + "\n", + "The default is to create CSF sparse data structure where all but the last dimension are doubly compressed.\n", + "\n", + "Use `.taco_view` attribute to see the TACO-like data structure." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "3f4ad63f", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " C\n", + " C\n", + " C\n", + " C\n", + " p1\n", + " p2\n", + " p3\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 3\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " p0\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|C -----|C -----|C -----|\n", + " .---. .---. .---. .---.\n", + " p0 |i0 |p1 |i1 |p2 |i2 |p3 |i3 |\n", + " `---' `---' `---' `---'\n", + "=================================\n", + " 0 .--. 0 .--. 0 .--. 0 .--.\n", + "-+--|0 |-+--|0 |----|0 |-+--|1 |\n", + " | `--' | `--' 1 `--' `--|2 |\n", + " | | .--. .--. 2 |--|\n", + " | `--|1 |-+--|0 |-+--|0 |\n", + " | 2 `--' | `--' `--|2 |\n", + " | | .--. 4 |--|\n", + " | `--|1 |----|0 |\n", + " | 3 `--' 5 `--'\n", + " | .--. .--. .--. .--.\n", + " `--|1 |----|1 |----|1 |-+--|0 |\n", + " 2 `--' 3 `--' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from sparsetensorviz import SparseTensor\n", + "import itertools\n", + "import IPython\n", + "\n", + "indices = [\n", + " [0, 0, 0, 0, 0, 1, 1, 1],\n", + " [0, 0, 1, 1, 1, 1, 1, 1],\n", + " [0, 0, 0, 0, 1, 1, 1, 1],\n", + " [1, 2, 0, 2, 0, 0, 1, 2],\n", + "]\n", + "sp = SparseTensor(indices).taco_view\n", + "# Display as SVG diagram\n", + "sp" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "833d4e98", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[array([0, 1]),\n", + " array([0, 1, 1]),\n", + " array([0, 0, 1, 1]),\n", + " array([1, 2, 0, 2, 0, 0, 1, 2])]" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sp.indices" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "e3399807", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[array([0, 2]), array([0, 2, 3]), array([0, 1, 3, 4]), array([0, 2, 4, 5, 8])]" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sp.pointers" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "e0bdf4f2", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "|C -----|C -----|C -----|C -----|\n", + " .---. .---. .---. .---.\n", + " p0 |i0 |p1 |i1 |p2 |i2 |p3 |i3 |\n", + " `---' `---' `---' `---'\n", + "=================================\n", + " 0 .--. 0 .--. 0 .--. 0 .--.\n", + "-+--|0 |-+--|0 |----|0 |-+--|1 |\n", + " | `--' | `--' 1 `--' `--|2 |\n", + " | | .--. .--. 2 |--|\n", + " | `--|1 |-+--|0 |-+--|0 |\n", + " | 2 `--' | `--' `--|2 |\n", + " | | .--. 4 |--|\n", + " | `--|1 |----|0 |\n", + " | 3 `--' 5 `--'\n", + " | .--. .--. .--. .--.\n", + " `--|1 |----|1 |----|1 |-+--|0 |\n", + " 2 `--' 3 `--' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'\n" + ] + } + ], + "source": [ + "# Can also display as ASCII diagram\n", + "print(sp)" + ] + }, + { + "cell_type": "markdown", + "id": "1092fc4b", + "metadata": {}, + "source": [ + "This diagram forms a tree-like structure where the first dimension is on the left and last dimension is on the right.\n", + "\n", + "Index values are in boxes, and pointer values are next to edges.\n", + "\n", + "We can choose how each dimension is compressed:\n", + "- **`S`, \"sparse\"**: like COO; indices are \"aligned\" to the following dimension indices or values.\n", + " - Uses: `indices_i`\n", + "- **`C`, \"compressed\"**: like CSR; fast lookup by index into pointers to the next dimension.\n", + " - Uses: `pointers_i`\n", + " - Makes `pointers_{i-1}` unnecessary\n", + "- **`DC`, \"doubly compressed\"**: like DCSR; store unique index values and pointers to the next dimension.\n", + " - Uses: `pointers_i`, `indices_i`\n", + "\n", + "Currently, the final dimension must be sparse, **`S`**.\n", + "\n", + "Hence, describing the structures of **CSR, CSC, DCSR, and DCSC** give us... CSR, CSC, DCSR, and DCSC (let's address the final \"R\" and \"C\" later).\n", + "\n", + "\n", + "#### TACO-like names\n", + "This notebook highlights the use of TACO-like names, which are:\n", + "- **\"compressed\"**: e.g., DCSR is `[\"compressed\", \"compressed\"]`\n", + "- **\"compressed-nonunique\"**: e.g., COO is `[\"compressed-nonunique\", \"singleton\"]`\n", + "- **\"singleton\"**: e.g., COO is `[\"compressed-nonunique\", \"singleton\"]`\n", + "- **\"dense\"**: e.g., CSR is `[\"dense\", \"compressed\"]`" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "b8253a23", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['compressed', 'compressed', 'compressed', 'compressed']" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sp.structure" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "ec61aa11", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'C-C-C-C'" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sp.abbreviation" + ] + }, + { + "cell_type": "markdown", + "id": "51842351", + "metadata": {}, + "source": [ + "## Display all sparse structures\n", + "\n", + "Hyphonated connecting lines indicate pointers that don't need stored.\n", + "\n", + "Hyphonated boxes indicate indices that don't need stored." + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "03f416ee-3b94-4044-8f4f-6e6f5d76b199", + "metadata": {}, + "outputs": [], + "source": [ + "def display_header(st, *, align=False, seen_taco=None):\n", + " taco_structure = \", \".join(st.taco_structure)\n", + " text = (\n", + " \"```\\n\"\n", + " f\"taco_structure = [{taco_structure}]\\n\\n\"\n", + " f\"structure = {st.structure}\\n\\n\"\n", + " \"```\"\n", + " )\n", + " IPython.display.display(IPython.display.Markdown(text))" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "232210ab", + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "# `C-C-C-C`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "taco_structure = [compressed, compressed, compressed, compressed]\n", + "\n", + "structure = [doubly_compressed, doubly_compressed, doubly_compressed, sparse]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " C\n", + " C\n", + " C\n", + " C\n", + " p1\n", + " p2\n", + " p3\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 3\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " p0\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|C -----|C -----|C -----|\n", + " .---. .---. .---. .---.\n", + " p0 |i0 |p1 |i1 |p2 |i2 |p3 |i3 |\n", + " `---' `---' `---' `---'\n", + "=================================\n", + " 0 .--. 0 .--. 0 .--. 0 .--.\n", + "-+--|0 |-+--|0 |----|0 |-+--|1 |\n", + " | `--' | `--' 1 `--' `--|2 |\n", + " | | .--. .--. 2 |--|\n", + " | `--|1 |-+--|0 |-+--|0 |\n", + " | 2 `--' | `--' `--|2 |\n", + " | | .--. 4 |--|\n", + " | `--|1 |----|0 |\n", + " | 3 `--' 5 `--'\n", + " | .--. .--. .--. .--.\n", + " `--|1 |----|1 |----|1 |-+--|0 |\n", + " 2 `--' 3 `--' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-C-CN-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "taco_structure = [compressed, compressed, compressed-nonunique, singleton]\n", + "\n", + "structure = [doubly_compressed, doubly_compressed, sparse, sparse]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " C\n", + " C\n", + " CN\n", + " S\n", + " p1\n", + " p2\n", + " p3\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 3\n", + " 0\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 3\n", + " 6\n", + " 1\n", + " 1\n", + " 7\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " p0\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|C -----|CN ----|S -----|\n", + " .---. .---. .---. .---.\n", + " p0 |i0 |p1 |i1 |p2 |i2 |p3 |i3 |\n", + " `---' `---' `---' `---'\n", + "=================================\n", + " 0 .--. 0 .--. 0 .--. 0 .--.\n", + "-+--|0 |-+--|0 |-+--|0 |~~~~|1 |\n", + " | `--' | `--' | `--' 1 `--'\n", + " | | | .--. .--.\n", + " | | `--|0 |~~~~|2 |\n", + " | | 2 `--' 2 `--'\n", + " | | .--. .--. .--.\n", + " | `--|1 |-+--|0 |~~~~|0 |\n", + " | 2 `--' | `--' 3 `--'\n", + " | | .--. .--.\n", + " | |--|0 |~~~~|2 |\n", + " | | `--' 4 `--'\n", + " | | .--. .--.\n", + " | `--|1 |~~~~|0 |\n", + " | 5 `--' 5 `--'\n", + " | .--. .--. .--. .--.\n", + " `--|1 |----|1 |-+--|1 |~~~~|0 |\n", + " 2 `--' 3 `--' | `--' 6 `--'\n", + " | .--. .--.\n", + " |--|1 |~~~~|1 |\n", + " | `--' 7 `--'\n", + " | .--. .--.\n", + " `--|1 |~~~~|2 |\n", + " 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-C-S-C`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "taco_structure = [compressed, compressed, singleton, compressed]\n", + "\n", + "structure = [doubly_compressed, sparse, doubly_compressed, sparse]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " C\n", + " C\n", + " S\n", + " C\n", + " p1\n", + " p2\n", + " p3\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 3\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 4\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " p0\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|C -----|S -----|C -----|\n", + " .---. .---. .---. .---.\n", + " p0 |i0 |p1 |i1 |p2 |i2 |p3 |i3 |\n", + " `---' `---' `---' `---'\n", + "=================================\n", + " 0 .--. 0 .--. 0 .--. 0 .--.\n", + "-+--|0 |-+--|0 |~~~~|0 |-+--|1 |\n", + " | `--' | `--' 1 `--' `--|2 |\n", + " | | .--. .--. 2 |--|\n", + " | |--|1 |~~~~|0 |-+--|0 |\n", + " | | `--' 2 `--' `--|2 |\n", + " | | .--. .--. 4 |--|\n", + " | `--|1 |~~~~|1 |----|0 |\n", + " | 3 `--' 3 `--' 5 `--'\n", + " | .--. .--. .--. .--.\n", + " `--|1 |----|1 |~~~~|1 |-+--|0 |\n", + " 2 `--' 4 `--' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-C-D-C`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "taco_structure = [compressed, compressed, dense, compressed]\n", + "\n", + "structure = [doubly_compressed, doubly_compressed, compressed, sparse]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " C\n", + " C\n", + " D\n", + " C\n", + " p1\n", + " p2\n", + " p3\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 0\n", + " 4\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 3\n", + " 5\n", + " 0\n", + " 6\n", + " 1\n", + " 2\n", + " 8\n", + " p0\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|C -----|D -----|C -----|\n", + " .---. .---. .~~~. .---.\n", + " p0 |i0 |p1 |i1 |p2 ┊i2 ┊p3 |i3 |\n", + " `---' `---' `~~~' `---'\n", + "=================================\n", + " 0 .--. 0 .--. 0 .~~. 0 .--.\n", + "-+--|0 |-+--|0 |~+~~┊0 ┊-+--|1 |\n", + " | `--' | `--' ┊ `~~' `--|2 |\n", + " | | ┊ .~~. 2 `--'\n", + " | | `~~┊1 ┊)\n", + " | | 2 `~~'\n", + " | | .--. .~~. 2 .--.\n", + " | `--|1 |~+~~┊0 ┊-+--|0 |\n", + " | 2 `--' ┊ `~~' `--|2 |\n", + " | ┊ .~~. 4 |--|\n", + " | `~~┊1 ┊----|0 |\n", + " | 4 `~~' 5 `--'\n", + " | .--. .--. .~~.\n", + " `--|1 |----|1 |~+~~┊0 ┊)\n", + " 2 `--' 3 `--' ┊ `~~'\n", + " ┊ .~~. 5 .--.\n", + " `~~┊1 ┊-+--|0 |\n", + " 6 `~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-CN-S-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "taco_structure = [compressed, compressed-nonunique, singleton, singleton]\n", + "\n", + "structure = [doubly_compressed, sparse, sparse, sparse]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " C\n", + " CN\n", + " S\n", + " S\n", + " p1\n", + " p2\n", + " p3\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 3\n", + " 3\n", + " 1\n", + " 0\n", + " 2\n", + " 4\n", + " 4\n", + " 1\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 6\n", + " 6\n", + " 1\n", + " 1\n", + " 1\n", + " 7\n", + " 7\n", + " 1\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " 8\n", + " p0\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|CN ----|S -----|S -----|\n", + " .---. .---. .---. .---.\n", + " p0 |i0 |p1 |i1 |p2 |i2 |p3 |i3 |\n", + " `---' `---' `---' `---'\n", + "=================================\n", + " 0 .--. 0 .--. 0 .--. 0 .--.\n", + "-+--|0 |-+--|0 |~~~~|0 |~~~~|1 |\n", + " | `--' | `--' 1 `--' 1 `--'\n", + " | | .--. .--. .--.\n", + " | |--|0 |~~~~|0 |~~~~|2 |\n", + " | | `--' 2 `--' 2 `--'\n", + " | | .--. .--. .--.\n", + " | |--|1 |~~~~|0 |~~~~|0 |\n", + " | | `--' 3 `--' 3 `--'\n", + " | | .--. .--. .--.\n", + " | |--|1 |~~~~|0 |~~~~|2 |\n", + " | | `--' 4 `--' 4 `--'\n", + " | | .--. .--. .--.\n", + " | `--|1 |~~~~|1 |~~~~|0 |\n", + " | 5 `--' 5 `--' 5 `--'\n", + " | .--. .--. .--. .--.\n", + " `--|1 |-+--|1 |~~~~|1 |~~~~|0 |\n", + " 2 `--' | `--' 6 `--' 6 `--'\n", + " | .--. .--. .--.\n", + " |--|1 |~~~~|1 |~~~~|1 |\n", + " | `--' 7 `--' 7 `--'\n", + " | .--. .--. .--.\n", + " `--|1 |~~~~|1 |~~~~|2 |\n", + " 8 `--' 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-CN-D-C`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "taco_structure = [compressed, compressed-nonunique, dense, compressed]\n", + "\n", + "structure = [doubly_compressed, sparse, compressed, sparse]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " C\n", + " CN\n", + " D\n", + " C\n", + " p1\n", + " p2\n", + " p3\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 3\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 5\n", + " 5\n", + " 1\n", + " 0\n", + " 6\n", + " 6\n", + " 1\n", + " 2\n", + " 8\n", + " p0\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|CN ----|D -----|C -----|\n", + " .---. .---. .~~~. .---.\n", + " p0 |i0 |p1 |i1 |p2 ┊i2 ┊p3 |i3 |\n", + " `---' `---' `~~~' `---'\n", + "=================================\n", + " 0 .--. 0 .--. 0 .~~. 0 .--.\n", + "-+--|0 |-+--|0 |~~~~┊0 ┊-+--|1 |\n", + " | `--' | `--' 1 `~~' `--|2 |\n", + " | | .--. .~~. 2 `--'\n", + " | |--|0 |~~~~┊1 ┊)\n", + " | | `--' 2 `~~'\n", + " | | .--. .~~. 2 .--.\n", + " | |--|1 |~~~~┊0 ┊-+--|0 |\n", + " | | `--' 3 `~~' `--|2 |\n", + " | | .--. .~~. 4 |--|\n", + " | `--|1 |~~~~┊1 ┊----|0 |\n", + " | 4 `--' 4 `~~' 5 `--'\n", + " | .--. .--. .~~.\n", + " `--|1 |-+--|1 |~~~~┊0 ┊)\n", + " 2 `--' | `--' 5 `~~'\n", + " | .--. .~~. 5 .--.\n", + " `--|1 |~~~~┊1 ┊-+--|0 |\n", + " 6 `--' 6 `~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-S-C-C`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "taco_structure = [compressed, singleton, compressed, compressed]\n", + "\n", + "structure = [sparse, doubly_compressed, doubly_compressed, sparse]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " C\n", + " S\n", + " C\n", + " C\n", + " p1\n", + " p2\n", + " p3\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 3\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " p0\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|S -----|C -----|C -----|\n", + " .---. .---. .---. .---.\n", + " p0 |i0 |p1 |i1 |p2 |i2 |p3 |i3 |\n", + " `---' `---' `---' `---'\n", + "=================================\n", + " 0 .--. 0 .--. 0 .--. 0 .--.\n", + "-+--|0 |~~~~|0 |----|0 |-+--|1 |\n", + " | `--' 1 `--' 1 `--' `--|2 |\n", + " | .--. .--. .--. 2 |--|\n", + " |--|0 |~~~~|1 |-+--|0 |-+--|0 |\n", + " | `--' 2 `--' | `--' `--|2 |\n", + " | | .--. 4 |--|\n", + " | `--|1 |----|0 |\n", + " | 3 `--' 5 `--'\n", + " | .--. .--. .--. .--.\n", + " `--|1 |~~~~|1 |----|1 |-+--|0 |\n", + " 3 `--' 3 `--' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-S-CN-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "taco_structure = [compressed, singleton, compressed-nonunique, singleton]\n", + "\n", + "structure = [sparse, doubly_compressed, sparse, sparse]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " C\n", + " S\n", + " CN\n", + " S\n", + " p1\n", + " p2\n", + " p3\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 3\n", + " 0\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 3\n", + " 6\n", + " 1\n", + " 1\n", + " 7\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " p0\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|S -----|CN ----|S -----|\n", + " .---. .---. .---. .---.\n", + " p0 |i0 |p1 |i1 |p2 |i2 |p3 |i3 |\n", + " `---' `---' `---' `---'\n", + "=================================\n", + " 0 .--. 0 .--. 0 .--. 0 .--.\n", + "-+--|0 |~~~~|0 |-+--|0 |~~~~|1 |\n", + " | `--' 1 `--' | `--' 1 `--'\n", + " | | .--. .--.\n", + " | `--|0 |~~~~|2 |\n", + " | 2 `--' 2 `--'\n", + " | .--. .--. .--. .--.\n", + " |--|0 |~~~~|1 |-+--|0 |~~~~|0 |\n", + " | `--' 2 `--' | `--' 3 `--'\n", + " | | .--. .--.\n", + " | |--|0 |~~~~|2 |\n", + " | | `--' 4 `--'\n", + " | | .--. .--.\n", + " | `--|1 |~~~~|0 |\n", + " | 5 `--' 5 `--'\n", + " | .--. .--. .--. .--.\n", + " `--|1 |~~~~|1 |-+--|1 |~~~~|0 |\n", + " 3 `--' 3 `--' | `--' 6 `--'\n", + " | .--. .--.\n", + " |--|1 |~~~~|1 |\n", + " | `--' 7 `--'\n", + " | .--. .--.\n", + " `--|1 |~~~~|2 |\n", + " 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-S-S-C`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "taco_structure = [compressed, singleton, singleton, compressed]\n", + "\n", + "structure = [sparse, sparse, doubly_compressed, sparse]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " C\n", + " S\n", + " S\n", + " C\n", + " p1\n", + " p2\n", + " p3\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 4\n", + " 0\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 3\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " p0\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|S -----|S -----|C -----|\n", + " .---. .---. .---. .---.\n", + " p0 |i0 |p1 |i1 |p2 |i2 |p3 |i3 |\n", + " `---' `---' `---' `---'\n", + "=================================\n", + " 0 .--. 0 .--. 0 .--. 0 .--.\n", + "-+--|0 |~~~~|0 |~~~~|0 |-+--|1 |\n", + " | `--' 1 `--' 1 `--' `--|2 |\n", + " | .--. .--. .--. 2 |--|\n", + " |--|0 |~~~~|1 |~~~~|0 |-+--|0 |\n", + " | `--' 2 `--' 2 `--' `--|2 |\n", + " | .--. .--. .--. 4 |--|\n", + " |--|0 |~~~~|1 |~~~~|1 |----|0 |\n", + " | `--' 3 `--' 3 `--' 5 `--'\n", + " | .--. .--. .--. .--.\n", + " `--|1 |~~~~|1 |~~~~|1 |-+--|0 |\n", + " 4 `--' 4 `--' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-S-D-C`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "taco_structure = [compressed, singleton, dense, compressed]\n", + "\n", + "structure = [sparse, doubly_compressed, compressed, sparse]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " C\n", + " S\n", + " D\n", + " C\n", + " p1\n", + " p2\n", + " p3\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 0\n", + " 4\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 3\n", + " 5\n", + " 0\n", + " 6\n", + " 1\n", + " 2\n", + " 8\n", + " p0\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|S -----|D -----|C -----|\n", + " .---. .---. .~~~. .---.\n", + " p0 |i0 |p1 |i1 |p2 ┊i2 ┊p3 |i3 |\n", + " `---' `---' `~~~' `---'\n", + "=================================\n", + " 0 .--. 0 .--. 0 .~~. 0 .--.\n", + "-+--|0 |~~~~|0 |~+~~┊0 ┊-+--|1 |\n", + " | `--' 1 `--' ┊ `~~' `--|2 |\n", + " | ┊ .~~. 2 `--'\n", + " | `~~┊1 ┊)\n", + " | 2 `~~'\n", + " | .--. .--. .~~. 2 .--.\n", + " |--|0 |~~~~|1 |~+~~┊0 ┊-+--|0 |\n", + " | `--' 2 `--' ┊ `~~' `--|2 |\n", + " | ┊ .~~. 4 |--|\n", + " | `~~┊1 ┊----|0 |\n", + " | 4 `~~' 5 `--'\n", + " | .--. .--. .~~.\n", + " `--|1 |~~~~|1 |~+~~┊0 ┊)\n", + " 3 `--' 3 `--' ┊ `~~'\n", + " ┊ .~~. 5 .--.\n", + " `~~┊1 ┊-+--|0 |\n", + " 6 `~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-D-C-C`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "taco_structure = [compressed, dense, compressed, compressed]\n", + "\n", + "structure = [doubly_compressed, compressed, doubly_compressed, sparse]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " C\n", + " D\n", + " C\n", + " C\n", + " p1\n", + " p2\n", + " p3\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 1\n", + " 0\n", + " 2\n", + " 3\n", + " 5\n", + " 3\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " p0\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|D -----|C -----|C -----|\n", + " .---. .~~~. .---. .---.\n", + " p0 |i0 |p1 ┊i1 ┊p2 |i2 |p3 |i3 |\n", + " `---' `~~~' `---' `---'\n", + "=================================\n", + " 0 .--. 0 .~~. 0 .--. 0 .--.\n", + "-+--|0 |~+~~┊0 ┊----|0 |-+--|1 |\n", + " | `--' ┊ `~~' 1 `--' `--|2 |\n", + " | ┊ .~~. .--. 2 |--|\n", + " | `~~┊1 ┊-+--|0 |-+--|0 |\n", + " | 2 `~~' | `--' `--|2 |\n", + " | .--. .~~. | .--. 4 |--|\n", + " `--|1 |~+~~┊0 ┊)`--|1 |----|0 |\n", + " 2 `--' ┊ `~~' 3 `--' 5 `--'\n", + " ┊ .~~. 3 .--. .--.\n", + " `~~┊1 ┊----|1 |-+--|0 |\n", + " 4 `~~' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-D-CN-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "taco_structure = [compressed, dense, compressed-nonunique, singleton]\n", + "\n", + "structure = [doubly_compressed, compressed, sparse, sparse]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " C\n", + " D\n", + " CN\n", + " S\n", + " p1\n", + " p2\n", + " p3\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 2\n", + " 3\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 5\n", + " 1\n", + " 0\n", + " 4\n", + " 6\n", + " 1\n", + " 1\n", + " 7\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " p0\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|D -----|CN ----|S -----|\n", + " .---. .~~~. .---. .---.\n", + " p0 |i0 |p1 ┊i1 ┊p2 |i2 |p3 |i3 |\n", + " `---' `~~~' `---' `---'\n", + "=================================\n", + " 0 .--. 0 .~~. 0 .--. 0 .--.\n", + "-+--|0 |~+~~┊0 ┊-+--|0 |~~~~|1 |\n", + " | `--' ┊ `~~' | `--' 1 `--'\n", + " | ┊ | .--. .--.\n", + " | ┊ `--|0 |~~~~|2 |\n", + " | ┊ 2 `--' 2 `--'\n", + " | ┊ .~~. .--. .--.\n", + " | `~~┊1 ┊-+--|0 |~~~~|0 |\n", + " | 2 `~~' | `--' 3 `--'\n", + " | .--. .~~. | .--. .--.\n", + " `--|1 |~+~~┊0 ┊)|--|0 |~~~~|2 |\n", + " 2 `--' ┊ `~~' | `--' 4 `--'\n", + " ┊ | .--. .--.\n", + " ┊ `--|1 |~~~~|0 |\n", + " ┊ 5 `--' 5 `--'\n", + " ┊ .~~. 5 .--. .--.\n", + " `~~┊1 ┊-+--|1 |~~~~|0 |\n", + " 4 `~~' | `--' 6 `--'\n", + " | .--. .--.\n", + " |--|1 |~~~~|1 |\n", + " | `--' 7 `--'\n", + " | .--. .--.\n", + " `--|1 |~~~~|2 |\n", + " 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-D-D-C`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "taco_structure = [compressed, dense, dense, compressed]\n", + "\n", + "structure = [doubly_compressed, compressed, compressed, sparse]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " C\n", + " D\n", + " D\n", + " C\n", + " p1\n", + " p2\n", + " p3\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 0\n", + " 4\n", + " 5\n", + " 1\n", + " 0\n", + " 2\n", + " 1\n", + " 6\n", + " 0\n", + " 4\n", + " 5\n", + " 0\n", + " 8\n", + " 1\n", + " 2\n", + " 8\n", + " p0\n", + " 5\n", + " 5\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|D -----|D -----|C -----|\n", + " .---. .~~~. .~~~. .---.\n", + " p0 |i0 |p1 ┊i1 ┊p2 ┊i2 ┊p3 |i3 |\n", + " `---' `~~~' `~~~' `---'\n", + "=================================\n", + " 0 .--. 0 .~~. 0 .~~. 0 .--.\n", + "-+--|0 |~+~~┊0 ┊~+~~┊0 ┊-+--|1 |\n", + " | `--' ┊ `~~' ┊ `~~' `--|2 |\n", + " | ┊ ┊ .~~. 2 `--'\n", + " | ┊ `~~┊1 ┊)\n", + " | ┊ 2 `~~'\n", + " | ┊ .~~. .~~. 2 .--.\n", + " | `~~┊1 ┊~+~~┊0 ┊-+--|0 |\n", + " | 2 `~~' ┊ `~~' `--|2 |\n", + " | ┊ .~~. 4 |--|\n", + " | `~~┊1 ┊----|0 |\n", + " | 4 `~~' 5 `--'\n", + " | .--. .~~. .~~.\n", + " `--|1 |~+~~┊0 ┊~+~~┊0 ┊)\n", + " 2 `--' ┊ `~~' ┊ `~~'\n", + " ┊ ┊ .~~. 5\n", + " ┊ `~~┊1 ┊)\n", + " ┊ 6 `~~'\n", + " ┊ .~~. .~~. 5\n", + " `~~┊1 ┊~+~~┊0 ┊)\n", + " 4 `~~' ┊ `~~'\n", + " ┊ .~~. 5 .--.\n", + " `~~┊1 ┊-+--|0 |\n", + " 8 `~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `CN-S-S-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "taco_structure = [compressed-nonunique, singleton, singleton, singleton]\n", + "\n", + "structure = [sparse, sparse, sparse, sparse]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " CN\n", + " S\n", + " S\n", + " S\n", + " p1\n", + " p2\n", + " p3\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 0\n", + " 0\n", + " 3\n", + " 3\n", + " 3\n", + " 0\n", + " 1\n", + " 0\n", + " 2\n", + " 4\n", + " 4\n", + " 4\n", + " 0\n", + " 1\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 6\n", + " 6\n", + " 6\n", + " 1\n", + " 1\n", + " 1\n", + " 1\n", + " 7\n", + " 7\n", + " 7\n", + " 1\n", + " 1\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " 8\n", + " 8\n", + " p0\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|CN ----|S -----|S -----|S -----|\n", + " .---. .---. .---. .---.\n", + " p0 |i0 |p1 |i1 |p2 |i2 |p3 |i3 |\n", + " `---' `---' `---' `---'\n", + "=================================\n", + " 0 .--. 0 .--. 0 .--. 0 .--.\n", + "-+--|0 |~~~~|0 |~~~~|0 |~~~~|1 |\n", + " | `--' 1 `--' 1 `--' 1 `--'\n", + " | .--. .--. .--. .--.\n", + " |--|0 |~~~~|0 |~~~~|0 |~~~~|2 |\n", + " | `--' 2 `--' 2 `--' 2 `--'\n", + " | .--. .--. .--. .--.\n", + " |--|0 |~~~~|1 |~~~~|0 |~~~~|0 |\n", + " | `--' 3 `--' 3 `--' 3 `--'\n", + " | .--. .--. .--. .--.\n", + " |--|0 |~~~~|1 |~~~~|0 |~~~~|2 |\n", + " | `--' 4 `--' 4 `--' 4 `--'\n", + " | .--. .--. .--. .--.\n", + " |--|0 |~~~~|1 |~~~~|1 |~~~~|0 |\n", + " | `--' 5 `--' 5 `--' 5 `--'\n", + " | .--. .--. .--. .--.\n", + " |--|1 |~~~~|1 |~~~~|1 |~~~~|0 |\n", + " | `--' 6 `--' 6 `--' 6 `--'\n", + " | .--. .--. .--. .--.\n", + " |--|1 |~~~~|1 |~~~~|1 |~~~~|1 |\n", + " | `--' 7 `--' 7 `--' 7 `--'\n", + " | .--. .--. .--. .--.\n", + " `--|1 |~~~~|1 |~~~~|1 |~~~~|2 |\n", + " 8 `--' 8 `--' 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `CN-S-D-C`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "taco_structure = [compressed-nonunique, singleton, dense, compressed]\n", + "\n", + "structure = [sparse, sparse, compressed, sparse]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " CN\n", + " S\n", + " D\n", + " C\n", + " p1\n", + " p2\n", + " p3\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 0\n", + " 3\n", + " 3\n", + " 2\n", + " 4\n", + " 0\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 6\n", + " 6\n", + " 6\n", + " 1\n", + " 2\n", + " 8\n", + " p0\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|CN ----|S -----|D -----|C -----|\n", + " .---. .---. .~~~. .---.\n", + " p0 |i0 |p1 |i1 |p2 ┊i2 ┊p3 |i3 |\n", + " `---' `---' `~~~' `---'\n", + "=================================\n", + " 0 .--. 0 .--. 0 .~~. 0 .--.\n", + "-+--|0 |~~~~|0 |~~~~┊0 ┊-+--|1 |\n", + " | `--' 1 `--' 1 `~~' `--|2 |\n", + " | .--. .--. .~~. 2 `--'\n", + " |--|0 |~~~~|0 |~~~~┊1 ┊)\n", + " | `--' 2 `--' 2 `~~'\n", + " | .--. .--. .~~. 2 .--.\n", + " |--|0 |~~~~|1 |~~~~┊0 ┊-+--|0 |\n", + " | `--' 3 `--' 3 `~~' `--|2 |\n", + " | .--. .--. .~~. 4 |--|\n", + " |--|0 |~~~~|1 |~~~~┊1 ┊----|0 |\n", + " | `--' 4 `--' 4 `~~' 5 `--'\n", + " | .--. .--. .~~.\n", + " |--|1 |~~~~|1 |~~~~┊0 ┊)\n", + " | `--' 5 `--' 5 `~~'\n", + " | .--. .--. .~~. 5 .--.\n", + " `--|1 |~~~~|1 |~~~~┊1 ┊-+--|0 |\n", + " 6 `--' 6 `--' 6 `~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `CN-D-C-C`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "taco_structure = [compressed-nonunique, dense, compressed, compressed]\n", + "\n", + "structure = [sparse, compressed, doubly_compressed, sparse]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " CN\n", + " D\n", + " C\n", + " C\n", + " p1\n", + " p2\n", + " p3\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 1\n", + " 0\n", + " 3\n", + " 3\n", + " 5\n", + " 3\n", + " 1\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " p0\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|CN ----|D -----|C -----|C -----|\n", + " .---. .~~~. .---. .---.\n", + " p0 |i0 |p1 ┊i1 ┊p2 |i2 |p3 |i3 |\n", + " `---' `~~~' `---' `---'\n", + "=================================\n", + " 0 .--. 0 .~~. 0 .--. 0 .--.\n", + "-+--|0 |~~~~┊0 ┊----|0 |-+--|1 |\n", + " | `--' 1 `~~' 1 `--' `--|2 |\n", + " | .--. .~~. .--. 2 |--|\n", + " |--|0 |~~~~┊1 ┊-+--|0 |-+--|0 |\n", + " | `--' 2 `~~' | `--' `--|2 |\n", + " | .--. .~~. | .--. 4 |--|\n", + " |--|1 |~~~~┊0 ┊)`--|1 |----|0 |\n", + " | `--' 3 `~~' 3 `--' 5 `--'\n", + " | .--. .~~. 3 .--. .--.\n", + " `--|1 |~~~~┊1 ┊----|1 |-+--|0 |\n", + " 4 `--' 4 `~~' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `CN-D-CN-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "taco_structure = [compressed-nonunique, dense, compressed-nonunique, singleton]\n", + "\n", + "structure = [sparse, compressed, sparse, sparse]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " CN\n", + " D\n", + " CN\n", + " S\n", + " p1\n", + " p2\n", + " p3\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 0\n", + " 2\n", + " 3\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 3\n", + " 4\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 6\n", + " 1\n", + " 1\n", + " 7\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " p0\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|CN ----|D -----|CN ----|S -----|\n", + " .---. .~~~. .---. .---.\n", + " p0 |i0 |p1 ┊i1 ┊p2 |i2 |p3 |i3 |\n", + " `---' `~~~' `---' `---'\n", + "=================================\n", + " 0 .--. 0 .~~. 0 .--. 0 .--.\n", + "-+--|0 |~~~~┊0 ┊-+--|0 |~~~~|1 |\n", + " | `--' 1 `~~' | `--' 1 `--'\n", + " | | .--. .--.\n", + " | `--|0 |~~~~|2 |\n", + " | 2 `--' 2 `--'\n", + " | .--. .~~. .--. .--.\n", + " |--|0 |~~~~┊1 ┊-+--|0 |~~~~|0 |\n", + " | `--' 2 `~~' | `--' 3 `--'\n", + " | .--. .~~. | .--. .--.\n", + " |--|1 |~~~~┊0 ┊)|--|0 |~~~~|2 |\n", + " | `--' 3 `~~' | `--' 4 `--'\n", + " | | .--. .--.\n", + " | `--|1 |~~~~|0 |\n", + " | 5 `--' 5 `--'\n", + " | .--. .~~. 5 .--. .--.\n", + " `--|1 |~~~~┊1 ┊-+--|1 |~~~~|0 |\n", + " 4 `--' 4 `~~' | `--' 6 `--'\n", + " | .--. .--.\n", + " |--|1 |~~~~|1 |\n", + " | `--' 7 `--'\n", + " | .--. .--.\n", + " `--|1 |~~~~|2 |\n", + " 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `CN-D-D-C`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "taco_structure = [compressed-nonunique, dense, dense, compressed]\n", + "\n", + "structure = [sparse, compressed, compressed, sparse]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " CN\n", + " D\n", + " D\n", + " C\n", + " p1\n", + " p2\n", + " p3\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 0\n", + " 4\n", + " 5\n", + " 1\n", + " 0\n", + " 3\n", + " 1\n", + " 6\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 5\n", + " 0\n", + " 8\n", + " 1\n", + " 2\n", + " 8\n", + " p0\n", + " 5\n", + " 5\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|CN ----|D -----|D -----|C -----|\n", + " .---. .~~~. .~~~. .---.\n", + " p0 |i0 |p1 ┊i1 ┊p2 ┊i2 ┊p3 |i3 |\n", + " `---' `~~~' `~~~' `---'\n", + "=================================\n", + " 0 .--. 0 .~~. 0 .~~. 0 .--.\n", + "-+--|0 |~~~~┊0 ┊~+~~┊0 ┊-+--|1 |\n", + " | `--' 1 `~~' ┊ `~~' `--|2 |\n", + " | ┊ .~~. 2 `--'\n", + " | `~~┊1 ┊)\n", + " | 2 `~~'\n", + " | .--. .~~. .~~. 2 .--.\n", + " |--|0 |~~~~┊1 ┊~+~~┊0 ┊-+--|0 |\n", + " | `--' 2 `~~' ┊ `~~' `--|2 |\n", + " | ┊ .~~. 4 |--|\n", + " | `~~┊1 ┊----|0 |\n", + " | 4 `~~' 5 `--'\n", + " | .--. .~~. .~~.\n", + " |--|1 |~~~~┊0 ┊~+~~┊0 ┊)\n", + " | `--' 3 `~~' ┊ `~~'\n", + " | ┊ .~~. 5\n", + " | `~~┊1 ┊)\n", + " | 6 `~~'\n", + " | .--. .~~. .~~. 5\n", + " `--|1 |~~~~┊1 ┊~+~~┊0 ┊)\n", + " 4 `--' 4 `~~' ┊ `~~'\n", + " ┊ .~~. 5 .--.\n", + " `~~┊1 ┊-+--|0 |\n", + " 8 `~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `D-C-C-C`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "taco_structure = [dense, compressed, compressed, compressed]\n", + "\n", + "structure = [compressed, doubly_compressed, doubly_compressed, sparse]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " D\n", + " C\n", + " C\n", + " C\n", + " p1\n", + " p2\n", + " p3\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " \n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 4\n", + " 1\n", + " 2\n", + " 2\n", + " 8\n", + " 3\n", + " p0\n", + " 3\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|D -----|C -----|C -----|C -----|\n", + " .~~~. .---. .---. .---.\n", + " p0 ┊i0 ┊p1 |i1 |p2 |i2 |p3 |i3 |\n", + " `~~~' `---' `---' `---'\n", + "=================================\n", + " 0 .~~. 0 .--. 0 .--. 0 .--.\n", + "~+~~┊0 ┊-+--|0 |----|0 |-+--|1 |\n", + " ┊ `~~' | `--' 1 `--' `--|2 |\n", + " ┊ | .--. .--. 2 |--|\n", + " ┊ `--|1 |-+--|0 |-+--|0 |\n", + " ┊ 2 `--' | `--' `--|2 |\n", + " ┊ | .--. 4 |--|\n", + " ┊ `--|1 |----|0 |\n", + " ┊ 3 `--' 5 `--'\n", + " ┊ .~~. .--. .--. .--.\n", + " ┊~~┊1 ┊----|1 |----|1 |-+--|0 |\n", + " ┊ `~~' 3 `--' 4 `--' |--|1 |\n", + " ┊ .~~. `--|2 |\n", + " `~~┊2 ┊) 8 `--'\n", + " 3 `~~' 3" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `D-C-CN-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "taco_structure = [dense, compressed, compressed-nonunique, singleton]\n", + "\n", + "structure = [compressed, doubly_compressed, sparse, sparse]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " D\n", + " C\n", + " CN\n", + " S\n", + " p1\n", + " p2\n", + " p3\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 3\n", + " 0\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " \n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 6\n", + " 2\n", + " 1\n", + " 1\n", + " 3\n", + " 7\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " p0\n", + " 3\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|D -----|C -----|CN ----|S -----|\n", + " .~~~. .---. .---. .---.\n", + " p0 ┊i0 ┊p1 |i1 |p2 |i2 |p3 |i3 |\n", + " `~~~' `---' `---' `---'\n", + "=================================\n", + " 0 .~~. 0 .--. 0 .--. 0 .--.\n", + "~+~~┊0 ┊-+--|0 |-+--|0 |~~~~|1 |\n", + " ┊ `~~' | `--' | `--' 1 `--'\n", + " ┊ | | .--. .--.\n", + " ┊ | `--|0 |~~~~|2 |\n", + " ┊ | 2 `--' 2 `--'\n", + " ┊ | .--. .--. .--.\n", + " ┊ `--|1 |-+--|0 |~~~~|0 |\n", + " ┊ 2 `--' | `--' 3 `--'\n", + " ┊ | .--. .--.\n", + " ┊ |--|0 |~~~~|2 |\n", + " ┊ | `--' 4 `--'\n", + " ┊ | .--. .--.\n", + " ┊ `--|1 |~~~~|0 |\n", + " ┊ 5 `--' 5 `--'\n", + " ┊ .~~. .--. .--. .--.\n", + " ┊~~┊1 ┊----|1 |-+--|1 |~~~~|0 |\n", + " ┊ `~~' 3 `--' | `--' 6 `--'\n", + " ┊ .~~. | .--. .--.\n", + " `~~┊2 ┊) |--|1 |~~~~|1 |\n", + " 3 `~~' 3 | `--' 7 `--'\n", + " | .--. .--.\n", + " `--|1 |~~~~|2 |\n", + " 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `D-C-S-C`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "taco_structure = [dense, compressed, singleton, compressed]\n", + "\n", + "structure = [compressed, sparse, doubly_compressed, sparse]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " D\n", + " C\n", + " S\n", + " C\n", + " p1\n", + " p2\n", + " p3\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 3\n", + " 5\n", + " \n", + " 1\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 1\n", + " 2\n", + " 2\n", + " 8\n", + " 3\n", + " p0\n", + " 4\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|D -----|C -----|S -----|C -----|\n", + " .~~~. .---. .---. .---.\n", + " p0 ┊i0 ┊p1 |i1 |p2 |i2 |p3 |i3 |\n", + " `~~~' `---' `---' `---'\n", + "=================================\n", + " 0 .~~. 0 .--. 0 .--. 0 .--.\n", + "~+~~┊0 ┊-+--|0 |~~~~|0 |-+--|1 |\n", + " ┊ `~~' | `--' 1 `--' `--|2 |\n", + " ┊ | .--. .--. 2 |--|\n", + " ┊ |--|1 |~~~~|0 |-+--|0 |\n", + " ┊ | `--' 2 `--' `--|2 |\n", + " ┊ | .--. .--. 4 |--|\n", + " ┊ `--|1 |~~~~|1 |----|0 |\n", + " ┊ 3 `--' 3 `--' 5 `--'\n", + " ┊ .~~. .--. .--. .--.\n", + " ┊~~┊1 ┊----|1 |~~~~|1 |-+--|0 |\n", + " ┊ `~~' 4 `--' 4 `--' |--|1 |\n", + " ┊ .~~. `--|2 |\n", + " `~~┊2 ┊) 8 `--'\n", + " 3 `~~' 4" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `D-C-D-C`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "taco_structure = [dense, compressed, dense, compressed]\n", + "\n", + "structure = [compressed, doubly_compressed, compressed, sparse]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " D\n", + " C\n", + " D\n", + " C\n", + " p1\n", + " p2\n", + " p3\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 0\n", + " 4\n", + " 5\n", + " \n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 2\n", + " 0\n", + " 3\n", + " 6\n", + " 1\n", + " 2\n", + " 8\n", + " p0\n", + " 3\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|D -----|C -----|D -----|C -----|\n", + " .~~~. .---. .~~~. .---.\n", + " p0 ┊i0 ┊p1 |i1 |p2 ┊i2 ┊p3 |i3 |\n", + " `~~~' `---' `~~~' `---'\n", + "=================================\n", + " 0 .~~. 0 .--. 0 .~~. 0 .--.\n", + "~+~~┊0 ┊-+--|0 |~+~~┊0 ┊-+--|1 |\n", + " ┊ `~~' | `--' ┊ `~~' `--|2 |\n", + " ┊ | ┊ .~~. 2 `--'\n", + " ┊ | `~~┊1 ┊)\n", + " ┊ | 2 `~~'\n", + " ┊ | .--. .~~. 2 .--.\n", + " ┊ `--|1 |~+~~┊0 ┊-+--|0 |\n", + " ┊ 2 `--' ┊ `~~' `--|2 |\n", + " ┊ ┊ .~~. 4 |--|\n", + " ┊ `~~┊1 ┊----|0 |\n", + " ┊ 4 `~~' 5 `--'\n", + " ┊ .~~. .--. .~~.\n", + " ┊~~┊1 ┊----|1 |~+~~┊0 ┊)\n", + " ┊ `~~' 3 `--' ┊ `~~'\n", + " ┊ .~~. ┊ .~~. 5 .--.\n", + " `~~┊2 ┊) `~~┊1 ┊-+--|0 |\n", + " 3 `~~' 3 6 `~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `D-CN-S-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "taco_structure = [dense, compressed-nonunique, singleton, singleton]\n", + "\n", + "structure = [compressed, sparse, sparse, sparse]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " D\n", + " CN\n", + " S\n", + " S\n", + " p1\n", + " p2\n", + " p3\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 3\n", + " 3\n", + " 1\n", + " 0\n", + " 2\n", + " 4\n", + " 4\n", + " 1\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 5\n", + " \n", + " 1\n", + " 1\n", + " 0\n", + " 6\n", + " 6\n", + " 2\n", + " 1\n", + " 1\n", + " 1\n", + " 3\n", + " 7\n", + " 7\n", + " 1\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " 8\n", + " p0\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|D -----|CN ----|S -----|S -----|\n", + " .~~~. .---. .---. .---.\n", + " p0 ┊i0 ┊p1 |i1 |p2 |i2 |p3 |i3 |\n", + " `~~~' `---' `---' `---'\n", + "=================================\n", + " 0 .~~. 0 .--. 0 .--. 0 .--.\n", + "~+~~┊0 ┊-+--|0 |~~~~|0 |~~~~|1 |\n", + " ┊ `~~' | `--' 1 `--' 1 `--'\n", + " ┊ | .--. .--. .--.\n", + " ┊ |--|0 |~~~~|0 |~~~~|2 |\n", + " ┊ | `--' 2 `--' 2 `--'\n", + " ┊ | .--. .--. .--.\n", + " ┊ |--|1 |~~~~|0 |~~~~|0 |\n", + " ┊ | `--' 3 `--' 3 `--'\n", + " ┊ | .--. .--. .--.\n", + " ┊ |--|1 |~~~~|0 |~~~~|2 |\n", + " ┊ | `--' 4 `--' 4 `--'\n", + " ┊ | .--. .--. .--.\n", + " ┊ `--|1 |~~~~|1 |~~~~|0 |\n", + " ┊ 5 `--' 5 `--' 5 `--'\n", + " ┊ .~~. .--. .--. .--.\n", + " ┊~~┊1 ┊-+--|1 |~~~~|1 |~~~~|0 |\n", + " ┊ `~~' | `--' 6 `--' 6 `--'\n", + " ┊ .~~. | .--. .--. .--.\n", + " `~~┊2 ┊)|--|1 |~~~~|1 |~~~~|1 |\n", + " 3 `~~' | `--' 7 `--' 7 `--'\n", + " | .--. .--. .--.\n", + " `--|1 |~~~~|1 |~~~~|2 |\n", + " 8 `--' 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `D-CN-D-C`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "taco_structure = [dense, compressed-nonunique, dense, compressed]\n", + "\n", + "structure = [compressed, sparse, compressed, sparse]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " D\n", + " CN\n", + " D\n", + " C\n", + " p1\n", + " p2\n", + " p3\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 3\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 5\n", + " \n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 2\n", + " 1\n", + " 0\n", + " 3\n", + " 6\n", + " 6\n", + " 1\n", + " 2\n", + " 8\n", + " p0\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|D -----|CN ----|D -----|C -----|\n", + " .~~~. .---. .~~~. .---.\n", + " p0 ┊i0 ┊p1 |i1 |p2 ┊i2 ┊p3 |i3 |\n", + " `~~~' `---' `~~~' `---'\n", + "=================================\n", + " 0 .~~. 0 .--. 0 .~~. 0 .--.\n", + "~+~~┊0 ┊-+--|0 |~~~~┊0 ┊-+--|1 |\n", + " ┊ `~~' | `--' 1 `~~' `--|2 |\n", + " ┊ | .--. .~~. 2 `--'\n", + " ┊ |--|0 |~~~~┊1 ┊)\n", + " ┊ | `--' 2 `~~'\n", + " ┊ | .--. .~~. 2 .--.\n", + " ┊ |--|1 |~~~~┊0 ┊-+--|0 |\n", + " ┊ | `--' 3 `~~' `--|2 |\n", + " ┊ | .--. .~~. 4 |--|\n", + " ┊ `--|1 |~~~~┊1 ┊----|0 |\n", + " ┊ 4 `--' 4 `~~' 5 `--'\n", + " ┊ .~~. .--. .~~.\n", + " ┊~~┊1 ┊-+--|1 |~~~~┊0 ┊)\n", + " ┊ `~~' | `--' 5 `~~'\n", + " ┊ .~~. | .--. .~~. 5 .--.\n", + " `~~┊2 ┊)`--|1 |~~~~┊1 ┊-+--|0 |\n", + " 3 `~~' 6 `--' 6 `~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `D-D-C-C`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "taco_structure = [dense, dense, compressed, compressed]\n", + "\n", + "structure = [compressed, compressed, doubly_compressed, sparse]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 2\n", + " \n", + " D\n", + " D\n", + " C\n", + " C\n", + " p1\n", + " p2\n", + " p3\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " \n", + " 0\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 3\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 1\n", + " 2\n", + " 0\n", + " 8\n", + " 3\n", + " 1\n", + " 6\n", + " p0\n", + " 4\n", + " 4\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|D -----|D -----|C -----|C -----|\n", + " .~~~. .~~~. .---. .---.\n", + " p0 ┊i0 ┊p1 ┊i1 ┊p2 |i2 |p3 |i3 |\n", + " `~~~' `~~~' `---' `---'\n", + "=================================\n", + " 0 .~~. 0 .~~. 0 .--. 0 .--.\n", + "~+~~┊0 ┊~+~~┊0 ┊----|0 |-+--|1 |\n", + " ┊ `~~' ┊ `~~' 1 `--' `--|2 |\n", + " ┊ ┊ .~~. .--. 2 |--|\n", + " ┊ `~~┊1 ┊-+--|0 |-+--|0 |\n", + " ┊ 2 `~~' | `--' `--|2 |\n", + " ┊ .~~. .~~. | .--. 4 |--|\n", + " ┊~~┊1 ┊~+~~┊0 ┊)`--|1 |----|0 |\n", + " ┊ `~~' ┊ `~~' 3 `--' 5 `--'\n", + " ┊ ┊ .~~. 3 .--. .--.\n", + " ┊ `~~┊1 ┊----|1 |-+--|0 |\n", + " ┊ 4 `~~' 4 `--' |--|1 |\n", + " ┊ .~~. .~~. `--|2 |\n", + " `~~┊2 ┊~+~~┊0 ┊) 8 `--'\n", + " 3 `~~' ┊ `~~'\n", + " ┊ .~~. 4\n", + " `~~┊1 ┊)\n", + " 6 `~~' 4" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `D-D-CN-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "taco_structure = [dense, dense, compressed-nonunique, singleton]\n", + "\n", + "structure = [compressed, compressed, sparse, sparse]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 2\n", + " \n", + " D\n", + " D\n", + " CN\n", + " S\n", + " p1\n", + " p2\n", + " p3\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 2\n", + " 3\n", + " \n", + " 0\n", + " 0\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 5\n", + " 1\n", + " 0\n", + " 4\n", + " 6\n", + " 0\n", + " 1\n", + " 1\n", + " 3\n", + " 7\n", + " 1\n", + " 1\n", + " 2\n", + " 6\n", + " 8\n", + " 8\n", + " p0\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|D -----|D -----|CN ----|S -----|\n", + " .~~~. .~~~. .---. .---.\n", + " p0 ┊i0 ┊p1 ┊i1 ┊p2 |i2 |p3 |i3 |\n", + " `~~~' `~~~' `---' `---'\n", + "=================================\n", + " 0 .~~. 0 .~~. 0 .--. 0 .--.\n", + "~+~~┊0 ┊~+~~┊0 ┊-+--|0 |~~~~|1 |\n", + " ┊ `~~' ┊ `~~' | `--' 1 `--'\n", + " ┊ ┊ | .--. .--.\n", + " ┊ ┊ `--|0 |~~~~|2 |\n", + " ┊ ┊ 2 `--' 2 `--'\n", + " ┊ ┊ .~~. .--. .--.\n", + " ┊ `~~┊1 ┊-+--|0 |~~~~|0 |\n", + " ┊ 2 `~~' | `--' 3 `--'\n", + " ┊ .~~. .~~. | .--. .--.\n", + " ┊~~┊1 ┊~+~~┊0 ┊)|--|0 |~~~~|2 |\n", + " ┊ `~~' ┊ `~~' | `--' 4 `--'\n", + " ┊ ┊ | .--. .--.\n", + " ┊ ┊ `--|1 |~~~~|0 |\n", + " ┊ ┊ 5 `--' 5 `--'\n", + " ┊ ┊ .~~. 5 .--. .--.\n", + " ┊ `~~┊1 ┊-+--|1 |~~~~|0 |\n", + " ┊ 4 `~~' | `--' 6 `--'\n", + " ┊ .~~. .~~. | .--. .--.\n", + " `~~┊2 ┊~+~~┊0 ┊)|--|1 |~~~~|1 |\n", + " 3 `~~' ┊ `~~' | `--' 7 `--'\n", + " ┊ .~~. | .--. .--.\n", + " `~~┊1 ┊)`--|1 |~~~~|2 |\n", + " 6 `~~' 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `D-D-D-C`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "taco_structure = [dense, dense, dense, compressed]\n", + "\n", + "structure = [compressed, compressed, compressed, sparse]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 2\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " D\n", + " D\n", + " D\n", + " C\n", + " p1\n", + " p2\n", + " p3\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 0\n", + " 4\n", + " 5\n", + " \n", + " 0\n", + " 1\n", + " 6\n", + " 0\n", + " 4\n", + " 5\n", + " 0\n", + " 8\n", + " 1\n", + " 2\n", + " 8\n", + " 0\n", + " 3\n", + " 1\n", + " 10\n", + " 0\n", + " 6\n", + " 1\n", + " 12\n", + " p0\n", + " 5\n", + " 5\n", + " 8\n", + " 8\n", + " 8\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|D -----|D -----|D -----|C -----|\n", + " .~~~. .~~~. .~~~. .---.\n", + " p0 ┊i0 ┊p1 ┊i1 ┊p2 ┊i2 ┊p3 |i3 |\n", + " `~~~' `~~~' `~~~' `---'\n", + "=================================\n", + " 0 .~~. 0 .~~. 0 .~~. 0 .--.\n", + "~+~~┊0 ┊~+~~┊0 ┊~+~~┊0 ┊-+--|1 |\n", + " ┊ `~~' ┊ `~~' ┊ `~~' `--|2 |\n", + " ┊ ┊ ┊ .~~. 2 `--'\n", + " ┊ ┊ `~~┊1 ┊)\n", + " ┊ ┊ 2 `~~'\n", + " ┊ ┊ .~~. .~~. 2 .--.\n", + " ┊ `~~┊1 ┊~+~~┊0 ┊-+--|0 |\n", + " ┊ 2 `~~' ┊ `~~' `--|2 |\n", + " ┊ ┊ .~~. 4 |--|\n", + " ┊ `~~┊1 ┊----|0 |\n", + " ┊ 4 `~~' 5 `--'\n", + " ┊ .~~. .~~. .~~.\n", + " ┊~~┊1 ┊~+~~┊0 ┊~+~~┊0 ┊)\n", + " ┊ `~~' ┊ `~~' ┊ `~~'\n", + " ┊ ┊ ┊ .~~. 5\n", + " ┊ ┊ `~~┊1 ┊)\n", + " ┊ ┊ 6 `~~'\n", + " ┊ ┊ .~~. .~~. 5\n", + " ┊ `~~┊1 ┊~+~~┊0 ┊)\n", + " ┊ 4 `~~' ┊ `~~'\n", + " ┊ ┊ .~~. 5 .--.\n", + " ┊ `~~┊1 ┊-+--|0 |\n", + " ┊ 8 `~~' |--|1 |\n", + " ┊ `--|2 |\n", + " ┊ .~~. .~~. .~~. 8 `--'\n", + " `~~┊2 ┊~+~~┊0 ┊~+~~┊0 ┊)\n", + " 3 `~~' ┊ `~~' ┊ `~~'\n", + " ┊ ┊ .~~. 8\n", + " ┊ `~~┊1 ┊)\n", + " ┊ 10 `~~'\n", + " ┊ .~~. .~~. 8\n", + " `~~┊1 ┊~+~~┊0 ┊)\n", + " 6 `~~' ┊ `~~'\n", + " ┊ .~~. 8\n", + " `~~┊1 ┊)\n", + " 12 `~~' 8" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "sparsities = [\"compressed\", \"compressed-nonunique\", \"singleton\", \"dense\"]\n", + "for structure in itertools.product(*([sparsities] * 4)):\n", + " try:\n", + " st = SparseTensor.from_taco(indices, shape=(3, 2, 2, 3), structure=structure)\n", + " except Exception:\n", + " continue\n", + " taco = st.taco_view\n", + " IPython.display.display(IPython.display.Markdown(f\"# `{taco.abbreviation}`\"))\n", + " display_header(st)\n", + " IPython.display.display(taco)" + ] + }, + { + "cell_type": "markdown", + "id": "07f40f47", + "metadata": {}, + "source": [ + "# voilà!\n", + "
" + ] + }, + { + "cell_type": "markdown", + "id": "54777a45-18e2-41f0-aaca-3863ae0d09e4", + "metadata": {}, + "source": [ + "## ✨ _Bonus: brain teasers_ ✨\n", + "\n", + "#### Are any of these valid TACO (or MLIR sparse tensor) formats, and, if so, what do they mean?\n", + "```\n", + "- [compressed, compressed, compressed-nonunique, compressed]\n", + "- [compressed, compressed-nonunique, compressed, compressed]\n", + "- [compressed, compressed-nonunique, compressed-nonunique, compressed]\n", + "- [compressed, compressed-nonunique, compressed-nonunique, singleton]\n", + "- [compressed, compressed-nonunique, singleton, compressed]\n", + "- [compressed, dense, compressed-nonunique, compressed]\n", + "- [compressed, singleton, compressed-nonunique, compressed]\n", + "- [compressed-nonunique, compressed, compressed, compressed]\n", + "- [compressed-nonunique, compressed, compressed-nonunique, compressed]\n", + "- [compressed-nonunique, compressed, compressed-nonunique, singleton]\n", + "- [compressed-nonunique, compressed, dense, compressed]\n", + "- [compressed-nonunique, compressed, singleton, compressed]\n", + "- [compressed-nonunique, compressed-nonunique, compressed, compressed]\n", + "- [compressed-nonunique, compressed-nonunique, compressed-nonunique, compressed]\n", + "- [compressed-nonunique, compressed-nonunique, compressed-nonunique, singleton]\n", + "- [compressed-nonunique, compressed-nonunique, dense, compressed]\n", + "- [compressed-nonunique, compressed-nonunique, singleton, compressed]\n", + "- [compressed-nonunique, compressed-nonunique, singleton, singleton]\n", + "- [compressed-nonunique, dense, compressed-nonunique, compressed]\n", + "- [compressed-nonunique, singleton, compressed, compressed]\n", + "- [compressed-nonunique, singleton, compressed-nonunique, compressed]\n", + "- [compressed-nonunique, singleton, compressed-nonunique, singleton]\n", + "- [compressed-nonunique, singleton, singleton, compressed]\n", + "- [dense, compressed, compressed-nonunique, compressed]\n", + "- [dense, compressed-nonunique, compressed, compressed]\n", + "- [dense, compressed-nonunique, compressed-nonunique, compressed]\n", + "- [dense, compressed-nonunique, compressed-nonunique, singleton]\n", + "- [dense, compressed-nonunique, singleton, compressed]\n", + "- [dense, dense, compressed-nonunique, compressed]\n", + "```" + ] + }, + { + "cell_type": "markdown", + "id": "e40edac3-f736-4899-bcff-216d2b6be344", + "metadata": {}, + "source": [ + "#### What about these?\n", + "```\n", + "- [compressed, compressed, compressed, compressed-nonunique]\n", + "- [compressed, compressed, compressed-nonunique, compressed-nonunique]\n", + "- [compressed, compressed, dense, compressed-nonunique]\n", + "- [compressed, compressed, singleton, compressed-nonunique]\n", + "- [compressed, compressed-nonunique, compressed, compressed-nonunique]\n", + "- [compressed, compressed-nonunique, compressed-nonunique, compressed-nonunique]\n", + "- [compressed, compressed-nonunique, dense, compressed-nonunique]\n", + "- [compressed, compressed-nonunique, singleton, compressed-nonunique]\n", + "- [compressed, dense, compressed, compressed-nonunique]\n", + "- [compressed, dense, compressed-nonunique, compressed-nonunique]\n", + "- [compressed, dense, dense, compressed-nonunique]\n", + "- [compressed, dense, singleton, compressed-nonunique]\n", + "- [compressed, singleton, compressed, compressed-nonunique]\n", + "- [compressed, singleton, compressed-nonunique, compressed-nonunique]\n", + "- [compressed, singleton, dense, compressed-nonunique]\n", + "- [compressed, singleton, singleton, compressed-nonunique]\n", + "- [compressed-nonunique, compressed, compressed, compressed-nonunique]\n", + "- [compressed-nonunique, compressed, compressed-nonunique, compressed-nonunique]\n", + "- [compressed-nonunique, compressed, dense, compressed-nonunique]\n", + "- [compressed-nonunique, compressed, singleton, compressed-nonunique]\n", + "- [compressed-nonunique, compressed-nonunique, compressed, compressed-nonunique]\n", + "- [compressed-nonunique, compressed-nonunique, compressed-nonunique, compressed-nonunique]\n", + "- [compressed-nonunique, compressed-nonunique, dense, compressed-nonunique]\n", + "- [compressed-nonunique, compressed-nonunique, singleton, compressed-nonunique]\n", + "- [compressed-nonunique, dense, compressed, compressed-nonunique]\n", + "- [compressed-nonunique, dense, compressed-nonunique, compressed-nonunique]\n", + "- [compressed-nonunique, dense, dense, compressed-nonunique]\n", + "- [compressed-nonunique, dense, singleton, compressed-nonunique]\n", + "- [compressed-nonunique, singleton, compressed, compressed-nonunique]\n", + "- [compressed-nonunique, singleton, compressed-nonunique, compressed-nonunique]\n", + "- [compressed-nonunique, singleton, dense, compressed-nonunique]\n", + "- [compressed-nonunique, singleton, singleton, compressed-nonunique]\n", + "- [dense, compressed, compressed, compressed-nonunique]\n", + "- [dense, compressed, compressed-nonunique, compressed-nonunique]\n", + "- [dense, compressed, dense, compressed-nonunique]\n", + "- [dense, compressed, singleton, compressed-nonunique]\n", + "- [dense, compressed-nonunique, compressed, compressed-nonunique]\n", + "- [dense, compressed-nonunique, compressed-nonunique, compressed-nonunique]\n", + "- [dense, compressed-nonunique, dense, compressed-nonunique]\n", + "- [dense, compressed-nonunique, singleton, compressed-nonunique]\n", + "- [dense, dense, compressed, compressed-nonunique]\n", + "- [dense, dense, compressed-nonunique, compressed-nonunique]\n", + "- [dense, dense, dense, compressed-nonunique]\n", + "- [dense, dense, singleton, compressed-nonunique]\n", + "- [dense, singleton, compressed, compressed-nonunique]\n", + "- [dense, singleton, compressed-nonunique, compressed-nonunique]\n", + "- [dense, singleton, dense, compressed-nonunique]\n", + "- [dense, singleton, singleton, compressed-nonunique]\n", + "```" + ] + }, + { + "cell_type": "markdown", + "id": "5b3145a2-6db6-4df3-a935-c0d99a4a4143", + "metadata": {}, + "source": [ + "#### Or these?\n", + "```\n", + "- [singleton, compressed, compressed, compressed]\n", + "- [singleton, compressed, compressed, compressed-nonunique]\n", + "- [singleton, compressed, compressed, singleton]\n", + "- [singleton, compressed, compressed-nonunique, compressed]\n", + "- [singleton, compressed, compressed-nonunique, compressed-nonunique]\n", + "- [singleton, compressed, compressed-nonunique, singleton]\n", + "- [singleton, compressed, dense, compressed]\n", + "- [singleton, compressed, dense, compressed-nonunique]\n", + "- [singleton, compressed, dense, singleton]\n", + "- [singleton, compressed, singleton, compressed]\n", + "- [singleton, compressed, singleton, compressed-nonunique]\n", + "- [singleton, compressed, singleton, singleton]\n", + "- [singleton, compressed-nonunique, compressed, compressed]\n", + "- [singleton, compressed-nonunique, compressed, compressed-nonunique]\n", + "- [singleton, compressed-nonunique, compressed, singleton]\n", + "- [singleton, compressed-nonunique, compressed-nonunique, compressed]\n", + "- [singleton, compressed-nonunique, compressed-nonunique, compressed-nonunique]\n", + "- [singleton, compressed-nonunique, compressed-nonunique, singleton]\n", + "- [singleton, compressed-nonunique, dense, compressed]\n", + "- [singleton, compressed-nonunique, dense, compressed-nonunique]\n", + "- [singleton, compressed-nonunique, dense, singleton]\n", + "- [singleton, compressed-nonunique, singleton, compressed]\n", + "- [singleton, compressed-nonunique, singleton, compressed-nonunique]\n", + "- [singleton, compressed-nonunique, singleton, singleton]\n", + "- [singleton, dense, compressed, compressed]\n", + "- [singleton, dense, compressed, compressed-nonunique]\n", + "- [singleton, dense, compressed, singleton]\n", + "- [singleton, dense, compressed-nonunique, compressed]\n", + "- [singleton, dense, compressed-nonunique, compressed-nonunique]\n", + "- [singleton, dense, compressed-nonunique, singleton]\n", + "- [singleton, dense, dense, compressed]\n", + "- [singleton, dense, dense, compressed-nonunique]\n", + "- [singleton, dense, dense, singleton]\n", + "- [singleton, dense, singleton, compressed]\n", + "- [singleton, dense, singleton, compressed-nonunique]\n", + "- [singleton, dense, singleton, singleton]\n", + "- [singleton, singleton, compressed, compressed]\n", + "- [singleton, singleton, compressed, compressed-nonunique]\n", + "- [singleton, singleton, compressed, singleton]\n", + "- [singleton, singleton, compressed-nonunique, compressed]\n", + "- [singleton, singleton, compressed-nonunique, compressed-nonunique]\n", + "- [singleton, singleton, compressed-nonunique, singleton]\n", + "- [singleton, singleton, dense, compressed]\n", + "- [singleton, singleton, dense, compressed-nonunique]\n", + "- [singleton, singleton, dense, singleton]\n", + "- [singleton, singleton, singleton, compressed]\n", + "- [singleton, singleton, singleton, compressed-nonunique]\n", + "- [singleton, singleton, singleton, singleton]\n", + "```" + ] + }, + { + "cell_type": "markdown", + "id": "3c1d13b5-03ee-441f-a448-c004f6be61ca", + "metadata": {}, + "source": [ + "#### Or, finally, these?\n", + "```\n", + "- [compressed, compressed, compressed, singleton]\n", + "- [compressed, compressed, dense, singleton]\n", + "- [compressed, compressed, singleton, singleton]\n", + "- [compressed, compressed-nonunique, compressed, singleton]\n", + "- [compressed, compressed-nonunique, dense, singleton]\n", + "- [compressed, dense, compressed, singleton]\n", + "- [compressed, dense, dense, singleton]\n", + "- [compressed, dense, singleton, compressed]\n", + "- [compressed, dense, singleton, singleton]\n", + "- [compressed, singleton, compressed, singleton]\n", + "- [compressed, singleton, dense, singleton]\n", + "- [compressed, singleton, singleton, singleton]\n", + "- [compressed-nonunique, compressed, compressed, singleton]\n", + "- [compressed-nonunique, compressed, dense, singleton]\n", + "- [compressed-nonunique, compressed, singleton, singleton]\n", + "- [compressed-nonunique, compressed-nonunique, compressed, singleton]\n", + "- [compressed-nonunique, compressed-nonunique, dense, singleton]\n", + "- [compressed-nonunique, dense, compressed, singleton]\n", + "- [compressed-nonunique, dense, dense, singleton]\n", + "- [compressed-nonunique, dense, singleton, compressed]\n", + "- [compressed-nonunique, dense, singleton, singleton]\n", + "- [compressed-nonunique, singleton, compressed, singleton]\n", + "- [compressed-nonunique, singleton, dense, singleton]\n", + "- [dense, compressed, compressed, singleton]\n", + "- [dense, compressed, dense, singleton]\n", + "- [dense, compressed, singleton, singleton]\n", + "- [dense, compressed-nonunique, compressed, singleton]\n", + "- [dense, compressed-nonunique, dense, singleton]\n", + "- [dense, dense, compressed, singleton]\n", + "- [dense, dense, dense, singleton]\n", + "- [dense, dense, singleton, compressed]\n", + "- [dense, dense, singleton, singleton]\n", + "- [dense, singleton, compressed, compressed]\n", + "- [dense, singleton, compressed, singleton]\n", + "- [dense, singleton, compressed-nonunique, compressed]\n", + "- [dense, singleton, compressed-nonunique, singleton]\n", + "- [dense, singleton, dense, compressed]\n", + "- [dense, singleton, dense, singleton]\n", + "- [dense, singleton, singleton, compressed]\n", + "- [dense, singleton, singleton, singleton]\n", + "```" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.13" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/sparsetensorviz/notebooks/Example_Rank4.ipynb b/sparsetensorviz/notebooks/Example_Rank4.ipynb new file mode 100644 index 0000000..d55180b --- /dev/null +++ b/sparsetensorviz/notebooks/Example_Rank4.ipynb @@ -0,0 +1,18194 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "1d023620", + "metadata": {}, + "source": [ + "# Examples for rank 4 array\n", + "\n", + "Pass COO-like data to `SparseTensor` with one array of indices for each dimension.\n", + "\n", + "The default is to create CSF sparse data structure where all but the last dimension are doubly compressed." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "3f4ad63f", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " DC\n", + " DC\n", + " DC\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|DC ----|DC ----|DC ----|S -|\n", + ".---. .---. .---. .---.\n", + "|i0 |p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`---' `---' `---' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .--. 0 .--.\n", + "|0 |-+--|0 |----|0 |-+--|1 |\n", + "`--' | `--' 1 `--' `--|2 |\n", + " | .--. .--. 2 |--|\n", + " `--|1 |-+--|0 |-+--|0 |\n", + " 2 `--' | `--' `--|2 |\n", + " | .--. 4 |--|\n", + " `--|1 |----|0 |\n", + " 3 `--' 5 `--'\n", + ".--. .--. .--. .--.\n", + "|1 |----|1 |----|1 |-+--|0 |\n", + "`--' 3 `--' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from sparsetensorviz import SparseTensor\n", + "import itertools\n", + "import IPython\n", + "\n", + "indices = [\n", + " [0, 0, 0, 0, 0, 1, 1, 1],\n", + " [0, 0, 1, 1, 1, 1, 1, 1],\n", + " [0, 0, 0, 0, 1, 1, 1, 1],\n", + " [1, 2, 0, 2, 0, 0, 1, 2],\n", + "]\n", + "sp = SparseTensor(indices)\n", + "# Display as SVG diagram\n", + "sp" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "833d4e98", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[array([0, 1]),\n", + " array([0, 1, 1]),\n", + " array([0, 0, 1, 1]),\n", + " array([1, 2, 0, 2, 0, 0, 1, 2])]" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sp.indices" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "e3399807", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[array([0, 2, 3]), array([0, 1, 3, 4]), array([0, 2, 4, 5, 8])]" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sp.pointers" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "e0bdf4f2", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "|DC ----|DC ----|DC ----|S -|\n", + ".---. .---. .---. .---.\n", + "|i0 |p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`---' `---' `---' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .--. 0 .--.\n", + "|0 |-+--|0 |----|0 |-+--|1 |\n", + "`--' | `--' 1 `--' `--|2 |\n", + " | .--. .--. 2 |--|\n", + " `--|1 |-+--|0 |-+--|0 |\n", + " 2 `--' | `--' `--|2 |\n", + " | .--. 4 |--|\n", + " `--|1 |----|0 |\n", + " 3 `--' 5 `--'\n", + ".--. .--. .--. .--.\n", + "|1 |----|1 |----|1 |-+--|0 |\n", + "`--' 3 `--' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'\n" + ] + } + ], + "source": [ + "# Can also display as ASCII diagram\n", + "print(sp)" + ] + }, + { + "cell_type": "markdown", + "id": "1092fc4b", + "metadata": {}, + "source": [ + "This diagram forms a tree-like structure where the first dimension is on the left and last dimension is on the right.\n", + "\n", + "Index values are in boxes, and pointer values are next to edges.\n", + "\n", + "We can choose how each dimension is compressed with any of the following:\n", + "- **`S`, \"sparse\"**: like COO; indices are \"aligned\" to the following dimension indices or values.\n", + " - Uses: `indices_i`\n", + "- **`C`, \"compressed\"**: like CSR; fast lookup by index into pointers to the next dimension.\n", + " - Uses: `pointers_i`\n", + " - Makes `pointers_{i-1}` unnecessary\n", + "- **`DC`, \"doubly compressed\"**: like DCSR; store unique index values and pointers to the next dimension.\n", + " - Uses: `pointers_i`, `indices_i`\n", + "\n", + "Currently, the final dimension must be sparse, **`S`**.\n", + "\n", + "Hence, describing the structures of **CSR, CSC, DCSR, and DCSC** give us... CSR, CSC, DCSR, and DCSC (let's address the final \"R\" and \"C\" later)." + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "db4c6cef", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['HyperSparse(1)', 'HyperSparse(1)', 'HyperSparse(1)', 'Coord(1)']" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sp.bundled_groups" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "b8253a23", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[doubly_compressed, doubly_compressed, doubly_compressed, sparse]" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sp.structure" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "ec61aa11", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'DC-DC-DC-S'" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sp.abbreviation" + ] + }, + { + "cell_type": "markdown", + "id": "0c0f78d3-40dc-4d93-b805-aa8ad9054870", + "metadata": {}, + "source": [ + "#### We can also use TACO-like dimensions names\n", + "`\"dense\"`, `\"compressed\"`, `\"compressed-nonunique\"`, and `\"singleton\"`" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "628b81c7-4722-481d-9cbc-dddbf75ad4a0", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[sparse, sparse, compressed, sparse]" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sp = SparseTensor.from_taco(\n", + " indices, structure=[\"compressed-nonunique\", \"singleton\", \"dense\", \"compressed\"]\n", + ")\n", + "sp.structure" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "ac55dcb8-77dc-4d53-96c2-84dbb4d16683", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['compressed-nonunique', 'singleton', 'dense', 'compressed']" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sp.taco_structure" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "9261134d-0b40-441e-b4be-db35d92c0a18", + "metadata": { + "scrolled": false + }, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " CN\n", + " S\n", + " D\n", + " C\n", + " p1\n", + " p2\n", + " p3\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 0\n", + " 3\n", + " 3\n", + " 2\n", + " 4\n", + " 0\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 6\n", + " 6\n", + " 6\n", + " 1\n", + " 2\n", + " 8\n", + " p0\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|CN ----|S -----|D -----|C -----|\n", + " .---. .---. .~~~. .---.\n", + " p0 |i0 |p1 |i1 |p2 ┊i2 ┊p3 |i3 |\n", + " `---' `---' `~~~' `---'\n", + "=================================\n", + " 0 .--. 0 .--. 0 .~~. 0 .--.\n", + "-+--|0 |~~~~|0 |~~~~┊0 ┊-+--|1 |\n", + " | `--' 1 `--' 1 `~~' `--|2 |\n", + " | .--. .--. .~~. 2 `--'\n", + " |--|0 |~~~~|0 |~~~~┊1 ┊)\n", + " | `--' 2 `--' 2 `~~'\n", + " | .--. .--. .~~. 2 .--.\n", + " |--|0 |~~~~|1 |~~~~┊0 ┊-+--|0 |\n", + " | `--' 3 `--' 3 `~~' `--|2 |\n", + " | .--. .--. .~~. 4 |--|\n", + " |--|0 |~~~~|1 |~~~~┊1 ┊----|0 |\n", + " | `--' 4 `--' 4 `~~' 5 `--'\n", + " | .--. .--. .~~.\n", + " |--|1 |~~~~|1 |~~~~┊0 ┊)\n", + " | `--' 5 `--' 5 `~~'\n", + " | .--. .--. .~~. 5 .--.\n", + " `--|1 |~~~~|1 |~~~~┊1 ┊-+--|0 |\n", + " 6 `--' 6 `--' 6 `~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sp.taco_view" + ] + }, + { + "cell_type": "markdown", + "id": "51842351", + "metadata": {}, + "source": [ + "## Display all sparse structures that are independent of shape\n", + "\n", + "This includes sparse structures that have no \"compressed sparse\" (**`C`**) dimensions.\n", + "\n", + "Hyphonated connecting lines indicate pointers that don't need stored." + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "03f416ee-3b94-4044-8f4f-6e6f5d76b199", + "metadata": {}, + "outputs": [], + "source": [ + "# Helper function\n", + "seen_taco = {}\n", + "\n", + "\n", + "def display_header(st, *, align=False, seen_taco=None):\n", + " key = tuple(st.taco_structure)\n", + " if seen_taco and key in seen_taco:\n", + " seen_text = \" # (seen)\"\n", + " else:\n", + " seen_text = \"\"\n", + " if seen_taco is not None:\n", + " seen_taco[key] = st.structure\n", + " bundled = \", \".join(st.bundled_groups)\n", + " if align:\n", + " widths = [max(len(str(x)), len(y)) for x, y in zip(st.structure, st.taco_structure)]\n", + " structure = \", \".join(\n", + " str(sparse).rjust(width) for sparse, width in zip(st.structure, widths)\n", + " )\n", + " taco_structure = \", \".join(\n", + " sparse.rjust(width) for sparse, width in zip(st.taco_structure, widths)\n", + " )\n", + " text = (\n", + " \"```\\n\"\n", + " f\"bundled_groups = [{bundled}]\\n\\n\"\n", + " f\"structure = [{structure}]\\n\\n\"\n", + " f\"taco_structure = [{taco_structure}]{seen_text}\\n\\n\"\n", + " \"```\"\n", + " )\n", + " else:\n", + " taco_structure = \", \".join(st.taco_structure)\n", + " text = (\n", + " \"```\\n\"\n", + " f\"bundled_groups = [{bundled}]\\n\\n\"\n", + " f\"structure = {st.structure}\\n\\n\"\n", + " f\"taco_structure = [{taco_structure}]{seen_text}\\n\\n\"\n", + " \"```\"\n", + " )\n", + " IPython.display.display(IPython.display.Markdown(text))" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "232210ab", + "metadata": { + "scrolled": false + }, + "outputs": [ + { + "data": { + "text/markdown": [ + "# `S-S-S-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Coord(4)]\n", + "\n", + "structure = [sparse, sparse, sparse, sparse]\n", + "\n", + "taco_structure = [compressed-nonunique, singleton, singleton, singleton]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " S\n", + " S\n", + " S\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 0\n", + " 0\n", + " 3\n", + " 3\n", + " 3\n", + " 0\n", + " 1\n", + " 0\n", + " 2\n", + " 4\n", + " 4\n", + " 4\n", + " 0\n", + " 1\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 6\n", + " 6\n", + " 6\n", + " 1\n", + " 1\n", + " 1\n", + " 1\n", + " 7\n", + " 7\n", + " 7\n", + " 1\n", + " 1\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|S -----|S -----|S -----|S -|\n", + ".---. .---. .---. .---.\n", + "|i0 |p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`---' `---' `---' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .--. 0 .--.\n", + "|0 |~~~~|0 |~~~~|0 |~~~~|1 |\n", + "`--' 1 `--' 1 `--' 1 `--'\n", + ".--. .--. .--. .--.\n", + "|0 |~~~~|0 |~~~~|0 |~~~~|2 |\n", + "`--' 2 `--' 2 `--' 2 `--'\n", + ".--. .--. .--. .--.\n", + "|0 |~~~~|1 |~~~~|0 |~~~~|0 |\n", + "`--' 3 `--' 3 `--' 3 `--'\n", + ".--. .--. .--. .--.\n", + "|0 |~~~~|1 |~~~~|0 |~~~~|2 |\n", + "`--' 4 `--' 4 `--' 4 `--'\n", + ".--. .--. .--. .--.\n", + "|0 |~~~~|1 |~~~~|1 |~~~~|0 |\n", + "`--' 5 `--' 5 `--' 5 `--'\n", + ".--. .--. .--. .--.\n", + "|1 |~~~~|1 |~~~~|1 |~~~~|0 |\n", + "`--' 6 `--' 6 `--' 6 `--'\n", + ".--. .--. .--. .--.\n", + "|1 |~~~~|1 |~~~~|1 |~~~~|1 |\n", + "`--' 7 `--' 7 `--' 7 `--'\n", + ".--. .--. .--. .--.\n", + "|1 |~~~~|1 |~~~~|1 |~~~~|2 |\n", + "`--' 8 `--' 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `S-S-DC-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [HyperSparse(3), Coord(1)]\n", + "\n", + "structure = [sparse, sparse, doubly_compressed, sparse]\n", + "\n", + "taco_structure = [compressed, singleton, singleton, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " S\n", + " S\n", + " DC\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 4\n", + " 0\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 3\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|S -----|S -----|DC ----|S -|\n", + ".---. .---. .---. .---.\n", + "|i0 |p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`---' `---' `---' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .--. 0 .--.\n", + "|0 |~~~~|0 |~~~~|0 |-+--|1 |\n", + "`--' 1 `--' 1 `--' `--|2 |\n", + ".--. .--. .--. 2 |--|\n", + "|0 |~~~~|1 |~~~~|0 |-+--|0 |\n", + "`--' 2 `--' 2 `--' `--|2 |\n", + ".--. .--. .--. 4 |--|\n", + "|0 |~~~~|1 |~~~~|1 |----|0 |\n", + "`--' 3 `--' 3 `--' 5 `--'\n", + ".--. .--. .--. .--.\n", + "|1 |~~~~|1 |~~~~|1 |-+--|0 |\n", + "`--' 4 `--' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `S-DC-S-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [HyperSparse(2), Coord(2)]\n", + "\n", + "structure = [sparse, doubly_compressed, sparse, sparse]\n", + "\n", + "taco_structure = [compressed, singleton, compressed-nonunique, singleton]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " S\n", + " DC\n", + " S\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 3\n", + " 0\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 6\n", + " 1\n", + " 1\n", + " 7\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|S -----|DC ----|S -----|S -|\n", + ".---. .---. .---. .---.\n", + "|i0 |p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`---' `---' `---' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .--. 0 .--.\n", + "|0 |~~~~|0 |-+--|0 |~~~~|1 |\n", + "`--' 1 `--' | `--' 1 `--'\n", + " | .--. .--.\n", + " `--|0 |~~~~|2 |\n", + " 2 `--' 2 `--'\n", + ".--. .--. .--. .--.\n", + "|0 |~~~~|1 |-+--|0 |~~~~|0 |\n", + "`--' 2 `--' | `--' 3 `--'\n", + " | .--. .--.\n", + " |--|0 |~~~~|2 |\n", + " | `--' 4 `--'\n", + " | .--. .--.\n", + " `--|1 |~~~~|0 |\n", + " 5 `--' 5 `--'\n", + ".--. .--. .--. .--.\n", + "|1 |~~~~|1 |-+--|1 |~~~~|0 |\n", + "`--' 3 `--' | `--' 6 `--'\n", + " | .--. .--.\n", + " |--|1 |~~~~|1 |\n", + " | `--' 7 `--'\n", + " | .--. .--.\n", + " `--|1 |~~~~|2 |\n", + " 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `S-DC-DC-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [HyperSparse(2), HyperSparse(1), Coord(1)]\n", + "\n", + "structure = [sparse, doubly_compressed, doubly_compressed, sparse]\n", + "\n", + "taco_structure = [compressed, singleton, compressed, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " S\n", + " DC\n", + " DC\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|S -----|DC ----|DC ----|S -|\n", + ".---. .---. .---. .---.\n", + "|i0 |p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`---' `---' `---' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .--. 0 .--.\n", + "|0 |~~~~|0 |----|0 |-+--|1 |\n", + "`--' 1 `--' 1 `--' `--|2 |\n", + ".--. .--. .--. 2 |--|\n", + "|0 |~~~~|1 |-+--|0 |-+--|0 |\n", + "`--' 2 `--' | `--' `--|2 |\n", + " | .--. 4 |--|\n", + " `--|1 |----|0 |\n", + " 3 `--' 5 `--'\n", + ".--. .--. .--. .--.\n", + "|1 |~~~~|1 |----|1 |-+--|0 |\n", + "`--' 3 `--' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `DC-S-S-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [HyperSparse(1), Coord(3)]\n", + "\n", + "structure = [doubly_compressed, sparse, sparse, sparse]\n", + "\n", + "taco_structure = [compressed, compressed-nonunique, singleton, singleton]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " DC\n", + " S\n", + " S\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 3\n", + " 3\n", + " 1\n", + " 0\n", + " 2\n", + " 4\n", + " 4\n", + " 1\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 6\n", + " 6\n", + " 1\n", + " 1\n", + " 1\n", + " 7\n", + " 7\n", + " 1\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|DC ----|S -----|S -----|S -|\n", + ".---. .---. .---. .---.\n", + "|i0 |p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`---' `---' `---' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .--. 0 .--.\n", + "|0 |-+--|0 |~~~~|0 |~~~~|1 |\n", + "`--' | `--' 1 `--' 1 `--'\n", + " | .--. .--. .--.\n", + " |--|0 |~~~~|0 |~~~~|2 |\n", + " | `--' 2 `--' 2 `--'\n", + " | .--. .--. .--.\n", + " |--|1 |~~~~|0 |~~~~|0 |\n", + " | `--' 3 `--' 3 `--'\n", + " | .--. .--. .--.\n", + " |--|1 |~~~~|0 |~~~~|2 |\n", + " | `--' 4 `--' 4 `--'\n", + " | .--. .--. .--.\n", + " `--|1 |~~~~|1 |~~~~|0 |\n", + " 5 `--' 5 `--' 5 `--'\n", + ".--. .--. .--. .--.\n", + "|1 |-+--|1 |~~~~|1 |~~~~|0 |\n", + "`--' | `--' 6 `--' 6 `--'\n", + " | .--. .--. .--.\n", + " |--|1 |~~~~|1 |~~~~|1 |\n", + " | `--' 7 `--' 7 `--'\n", + " | .--. .--. .--.\n", + " `--|1 |~~~~|1 |~~~~|2 |\n", + " 8 `--' 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `DC-S-DC-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [HyperSparse(1), HyperSparse(2), Coord(1)]\n", + "\n", + "structure = [doubly_compressed, sparse, doubly_compressed, sparse]\n", + "\n", + "taco_structure = [compressed, compressed, singleton, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " DC\n", + " S\n", + " DC\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 3\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|DC ----|S -----|DC ----|S -|\n", + ".---. .---. .---. .---.\n", + "|i0 |p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`---' `---' `---' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .--. 0 .--.\n", + "|0 |-+--|0 |~~~~|0 |-+--|1 |\n", + "`--' | `--' 1 `--' `--|2 |\n", + " | .--. .--. 2 |--|\n", + " |--|1 |~~~~|0 |-+--|0 |\n", + " | `--' 2 `--' `--|2 |\n", + " | .--. .--. 4 |--|\n", + " `--|1 |~~~~|1 |----|0 |\n", + " 3 `--' 3 `--' 5 `--'\n", + ".--. .--. .--. .--.\n", + "|1 |----|1 |~~~~|1 |-+--|0 |\n", + "`--' 4 `--' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `DC-DC-S-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [HyperSparse(1), HyperSparse(1), Coord(2)]\n", + "\n", + "structure = [doubly_compressed, doubly_compressed, sparse, sparse]\n", + "\n", + "taco_structure = [compressed, compressed, compressed-nonunique, singleton]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " DC\n", + " DC\n", + " S\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 3\n", + " 0\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 6\n", + " 1\n", + " 1\n", + " 7\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|DC ----|DC ----|S -----|S -|\n", + ".---. .---. .---. .---.\n", + "|i0 |p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`---' `---' `---' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .--. 0 .--.\n", + "|0 |-+--|0 |-+--|0 |~~~~|1 |\n", + "`--' | `--' | `--' 1 `--'\n", + " | | .--. .--.\n", + " | `--|0 |~~~~|2 |\n", + " | 2 `--' 2 `--'\n", + " | .--. .--. .--.\n", + " `--|1 |-+--|0 |~~~~|0 |\n", + " 2 `--' | `--' 3 `--'\n", + " | .--. .--.\n", + " |--|0 |~~~~|2 |\n", + " | `--' 4 `--'\n", + " | .--. .--.\n", + " `--|1 |~~~~|0 |\n", + " 5 `--' 5 `--'\n", + ".--. .--. .--. .--.\n", + "|1 |----|1 |-+--|1 |~~~~|0 |\n", + "`--' 3 `--' | `--' 6 `--'\n", + " | .--. .--.\n", + " |--|1 |~~~~|1 |\n", + " | `--' 7 `--'\n", + " | .--. .--.\n", + " `--|1 |~~~~|2 |\n", + " 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `DC-DC-DC-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [HyperSparse(1), HyperSparse(1), HyperSparse(1), Coord(1)]\n", + "\n", + "structure = [doubly_compressed, doubly_compressed, doubly_compressed, sparse]\n", + "\n", + "taco_structure = [compressed, compressed, compressed, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " DC\n", + " DC\n", + " DC\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|DC ----|DC ----|DC ----|S -|\n", + ".---. .---. .---. .---.\n", + "|i0 |p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`---' `---' `---' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .--. 0 .--.\n", + "|0 |-+--|0 |----|0 |-+--|1 |\n", + "`--' | `--' 1 `--' `--|2 |\n", + " | .--. .--. 2 |--|\n", + " `--|1 |-+--|0 |-+--|0 |\n", + " 2 `--' | `--' `--|2 |\n", + " | .--. 4 |--|\n", + " `--|1 |----|0 |\n", + " 3 `--' 5 `--'\n", + ".--. .--. .--. .--.\n", + "|1 |----|1 |----|1 |-+--|0 |\n", + "`--' 3 `--' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "sparsities = [\"S\", \"DC\"]\n", + "for sparsity in itertools.product(sparsities, sparsities, sparsities, [\"S\"]):\n", + " structure = \"-\".join(sparsity)\n", + " IPython.display.display(IPython.display.Markdown(f\"# `{structure}`\"))\n", + " st = SparseTensor(indices, structure=structure)\n", + " display_header(st, seen_taco=seen_taco)\n", + " IPython.display.display(st)" + ] + }, + { + "cell_type": "markdown", + "id": "eec6fad5", + "metadata": {}, + "source": [ + "## Display sparse structures, `shape=(2, 2, 2, 3)`\n", + "\n", + "Hyphonated boxes indicate indices that don't need stored.\n", + "\n", + "For compressed sparse dimensions, `C`, some repeated pointer values may be skipped if there is no room" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "c8e1d2a7", + "metadata": { + "scrolled": false + }, + "outputs": [ + { + "data": { + "text/markdown": [ + "# `S-S-C-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Coord(2, expanded=True), Sparse(1), Coord(1)]\n", + "\n", + "structure = [sparse, sparse, compressed, sparse]\n", + "\n", + "taco_structure = [compressed-nonunique, singleton, dense, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " S\n", + " S\n", + " C\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 0\n", + " 3\n", + " 3\n", + " 2\n", + " 4\n", + " 0\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 6\n", + " 6\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|S -----|S -----|C -----|S -|\n", + ".---. .---. .~~~. .---.\n", + "|i0 |p0 |i1 |p1 ┊i2 ┊p2 |i3 |\n", + "`---' `---' `~~~' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .~~. 0 .--.\n", + "|0 |~~~~|0 |~~~~┊0 ┊-+--|1 |\n", + "`--' 1 `--' 1 `~~' `--|2 |\n", + ".--. .--. .~~. 2 `--'\n", + "|0 |~~~~|0 |~~~~┊1 ┊)\n", + "`--' 2 `--' 2 `~~'\n", + ".--. .--. .~~. 2 .--.\n", + "|0 |~~~~|1 |~~~~┊0 ┊-+--|0 |\n", + "`--' 3 `--' 3 `~~' `--|2 |\n", + ".--. .--. .~~. 4 |--|\n", + "|0 |~~~~|1 |~~~~┊1 ┊----|0 |\n", + "`--' 4 `--' 4 `~~' 5 `--'\n", + ".--. .--. .~~.\n", + "|1 |~~~~|1 |~~~~┊0 ┊)\n", + "`--' 5 `--' 5 `~~'\n", + ".--. .--. .~~. 5 .--.\n", + "|1 |~~~~|1 |~~~~┊1 ┊-+--|0 |\n", + "`--' 6 `--' 6 `~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `S-C-S-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Coord(1, expanded=True), Sparse(1), Coord(2)]\n", + "\n", + "structure = [sparse, compressed, sparse, sparse]\n", + "\n", + "taco_structure = [compressed-nonunique, dense, compressed-nonunique, singleton]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " S\n", + " C\n", + " S\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 0\n", + " 2\n", + " 3\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 3\n", + " 4\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 4\n", + " 6\n", + " 1\n", + " 1\n", + " 7\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|S -----|C -----|S -----|S -|\n", + ".---. .~~~. .---. .---.\n", + "|i0 |p0 ┊i1 ┊p1 |i2 |p2 |i3 |\n", + "`---' `~~~' `---' `---'\n", + "=============================\n", + ".--. 0 .~~. 0 .--. 0 .--.\n", + "|0 |~~~~┊0 ┊-+--|0 |~~~~|1 |\n", + "`--' 1 `~~' | `--' 1 `--'\n", + " | .--. .--.\n", + " `--|0 |~~~~|2 |\n", + " 2 `--' 2 `--'\n", + ".--. .~~. .--. .--.\n", + "|0 |~~~~┊1 ┊-+--|0 |~~~~|0 |\n", + "`--' 2 `~~' | `--' 3 `--'\n", + ".--. .~~. | .--. .--.\n", + "|1 |~~~~┊0 ┊)|--|0 |~~~~|2 |\n", + "`--' 3 `~~' | `--' 4 `--'\n", + " | .--. .--.\n", + " `--|1 |~~~~|0 |\n", + " 5 `--' 5 `--'\n", + ".--. .~~. 5 .--. .--.\n", + "|1 |~~~~┊1 ┊-+--|1 |~~~~|0 |\n", + "`--' 4 `~~' | `--' 6 `--'\n", + " | .--. .--.\n", + " |--|1 |~~~~|1 |\n", + " | `--' 7 `--'\n", + " | .--. .--.\n", + " `--|1 |~~~~|2 |\n", + " 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `S-C-C-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Coord(1, expanded=True), Sparse(2), Coord(1)]\n", + "\n", + "structure = [sparse, compressed, compressed, sparse]\n", + "\n", + "taco_structure = [compressed-nonunique, dense, dense, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " S\n", + " C\n", + " C\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 0\n", + " 4\n", + " 5\n", + " 1\n", + " 0\n", + " 3\n", + " 1\n", + " 6\n", + " 1\n", + " 0\n", + " 4\n", + " 5\n", + " 0\n", + " 8\n", + " 1\n", + " 2\n", + " 8\n", + " 5\n", + " 5\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|S -----|C -----|C -----|S -|\n", + ".---. .~~~. .~~~. .---.\n", + "|i0 |p0 ┊i1 ┊p1 ┊i2 ┊p2 |i3 |\n", + "`---' `~~~' `~~~' `---'\n", + "=============================\n", + ".--. 0 .~~. 0 .~~. 0 .--.\n", + "|0 |~~~~┊0 ┊~+~~┊0 ┊-+--|1 |\n", + "`--' 1 `~~' ┊ `~~' `--|2 |\n", + " ┊ .~~. 2 `--'\n", + " `~~┊1 ┊)\n", + " 2 `~~'\n", + ".--. .~~. .~~. 2 .--.\n", + "|0 |~~~~┊1 ┊~+~~┊0 ┊-+--|0 |\n", + "`--' 2 `~~' ┊ `~~' `--|2 |\n", + " ┊ .~~. 4 |--|\n", + " `~~┊1 ┊----|0 |\n", + " 4 `~~' 5 `--'\n", + ".--. .~~. .~~.\n", + "|1 |~~~~┊0 ┊~+~~┊0 ┊)\n", + "`--' 3 `~~' ┊ `~~'\n", + " ┊ .~~. 5\n", + " `~~┊1 ┊)\n", + " 6 `~~'\n", + ".--. .~~. .~~. 5\n", + "|1 |~~~~┊1 ┊~+~~┊0 ┊)\n", + "`--' 4 `~~' ┊ `~~'\n", + " ┊ .~~. 5 .--.\n", + " `~~┊1 ┊-+--|0 |\n", + " 8 `~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `S-C-DC-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Coord(1, expanded=True), Sparse(1), HyperSparse(1), Coord(1)]\n", + "\n", + "structure = [sparse, compressed, doubly_compressed, sparse]\n", + "\n", + "taco_structure = [compressed-nonunique, dense, compressed, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " S\n", + " C\n", + " DC\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 1\n", + " 0\n", + " 3\n", + " 3\n", + " 5\n", + " 3\n", + " 1\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|S -----|C -----|DC ----|S -|\n", + ".---. .~~~. .---. .---.\n", + "|i0 |p0 ┊i1 ┊p1 |i2 |p2 |i3 |\n", + "`---' `~~~' `---' `---'\n", + "=============================\n", + ".--. 0 .~~. 0 .--. 0 .--.\n", + "|0 |~~~~┊0 ┊----|0 |-+--|1 |\n", + "`--' 1 `~~' 1 `--' `--|2 |\n", + ".--. .~~. .--. 2 |--|\n", + "|0 |~~~~┊1 ┊-+--|0 |-+--|0 |\n", + "`--' 2 `~~' | `--' `--|2 |\n", + ".--. .~~. | .--. 4 |--|\n", + "|1 |~~~~┊0 ┊)`--|1 |----|0 |\n", + "`--' 3 `~~' 3 `--' 5 `--'\n", + ".--. .~~. 3 .--. .--.\n", + "|1 |~~~~┊1 ┊----|1 |-+--|0 |\n", + "`--' 4 `~~' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `S-DC-C-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Coord(2), Sparse(1), Coord(1)]\n", + "\n", + "structure = [sparse, doubly_compressed, compressed, sparse]\n", + "\n", + "taco_structure = [compressed, singleton, dense, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " S\n", + " DC\n", + " C\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 0\n", + " 4\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 0\n", + " 6\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|S -----|DC ----|C -----|S -|\n", + ".---. .---. .~~~. .---.\n", + "|i0 |p0 |i1 |p1 ┊i2 ┊p2 |i3 |\n", + "`---' `---' `~~~' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .~~. 0 .--.\n", + "|0 |~~~~|0 |~+~~┊0 ┊-+--|1 |\n", + "`--' 1 `--' ┊ `~~' `--|2 |\n", + " ┊ .~~. 2 `--'\n", + " `~~┊1 ┊)\n", + " 2 `~~'\n", + ".--. .--. .~~. 2 .--.\n", + "|0 |~~~~|1 |~+~~┊0 ┊-+--|0 |\n", + "`--' 2 `--' ┊ `~~' `--|2 |\n", + " ┊ .~~. 4 |--|\n", + " `~~┊1 ┊----|0 |\n", + " 4 `~~' 5 `--'\n", + ".--. .--. .~~.\n", + "|1 |~~~~|1 |~+~~┊0 ┊)\n", + "`--' 3 `--' ┊ `~~'\n", + " ┊ .~~. 5 .--.\n", + " `~~┊1 ┊-+--|0 |\n", + " 6 `~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-S-S-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Sparse(1), Coord(3)]\n", + "\n", + "structure = [compressed, sparse, sparse, sparse]\n", + "\n", + "taco_structure = [dense, compressed-nonunique, singleton, singleton]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " C\n", + " S\n", + " S\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 3\n", + " 3\n", + " 1\n", + " 0\n", + " 2\n", + " 4\n", + " 4\n", + " 1\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 6\n", + " 6\n", + " 1\n", + " 1\n", + " 1\n", + " 7\n", + " 7\n", + " 1\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|S -----|S -----|S -|\n", + ".~~~. .---. .---. .---.\n", + "┊i0 ┊p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`~~~' `---' `---' `---'\n", + "=============================\n", + ".~~. 0 .--. 0 .--. 0 .--.\n", + "┊0 ┊-+--|0 |~~~~|0 |~~~~|1 |\n", + "`~~' | `--' 1 `--' 1 `--'\n", + " | .--. .--. .--.\n", + " |--|0 |~~~~|0 |~~~~|2 |\n", + " | `--' 2 `--' 2 `--'\n", + " | .--. .--. .--.\n", + " |--|1 |~~~~|0 |~~~~|0 |\n", + " | `--' 3 `--' 3 `--'\n", + " | .--. .--. .--.\n", + " |--|1 |~~~~|0 |~~~~|2 |\n", + " | `--' 4 `--' 4 `--'\n", + " | .--. .--. .--.\n", + " `--|1 |~~~~|1 |~~~~|0 |\n", + " 5 `--' 5 `--' 5 `--'\n", + ".~~. .--. .--. .--.\n", + "┊1 ┊-+--|1 |~~~~|1 |~~~~|0 |\n", + "`~~' | `--' 6 `--' 6 `--'\n", + " | .--. .--. .--.\n", + " |--|1 |~~~~|1 |~~~~|1 |\n", + " | `--' 7 `--' 7 `--'\n", + " | .--. .--. .--.\n", + " `--|1 |~~~~|1 |~~~~|2 |\n", + " 8 `--' 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-S-C-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Sparse(1), Coord(1, expanded=True), Sparse(1), Coord(1)]\n", + "\n", + "structure = [compressed, sparse, compressed, sparse]\n", + "\n", + "taco_structure = [dense, compressed-nonunique, dense, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " C\n", + " S\n", + " C\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 3\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 5\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 1\n", + " 0\n", + " 6\n", + " 6\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|S -----|C -----|S -|\n", + ".~~~. .---. .~~~. .---.\n", + "┊i0 ┊p0 |i1 |p1 ┊i2 ┊p2 |i3 |\n", + "`~~~' `---' `~~~' `---'\n", + "=============================\n", + ".~~. 0 .--. 0 .~~. 0 .--.\n", + "┊0 ┊-+--|0 |~~~~┊0 ┊-+--|1 |\n", + "`~~' | `--' 1 `~~' `--|2 |\n", + " | .--. .~~. 2 `--'\n", + " |--|0 |~~~~┊1 ┊)\n", + " | `--' 2 `~~'\n", + " | .--. .~~. 2 .--.\n", + " |--|1 |~~~~┊0 ┊-+--|0 |\n", + " | `--' 3 `~~' `--|2 |\n", + " | .--. .~~. 4 |--|\n", + " `--|1 |~~~~┊1 ┊----|0 |\n", + " 4 `--' 4 `~~' 5 `--'\n", + ".~~. .--. .~~.\n", + "┊1 ┊-+--|1 |~~~~┊0 ┊)\n", + "`~~' | `--' 5 `~~'\n", + " | .--. .~~. 5 .--.\n", + " `--|1 |~~~~┊1 ┊-+--|0 |\n", + " 6 `--' 6 `~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-S-DC-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Sparse(1), HyperSparse(2), Coord(1)]\n", + "\n", + "structure = [compressed, sparse, doubly_compressed, sparse]\n", + "\n", + "taco_structure = [dense, compressed, singleton, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " C\n", + " S\n", + " DC\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 3\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|S -----|DC ----|S -|\n", + ".~~~. .---. .---. .---.\n", + "┊i0 ┊p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`~~~' `---' `---' `---'\n", + "=============================\n", + ".~~. 0 .--. 0 .--. 0 .--.\n", + "┊0 ┊-+--|0 |~~~~|0 |-+--|1 |\n", + "`~~' | `--' 1 `--' `--|2 |\n", + " | .--. .--. 2 |--|\n", + " |--|1 |~~~~|0 |-+--|0 |\n", + " | `--' 2 `--' `--|2 |\n", + " | .--. .--. 4 |--|\n", + " `--|1 |~~~~|1 |----|0 |\n", + " 3 `--' 3 `--' 5 `--'\n", + ".~~. .--. .--. .--.\n", + "┊1 ┊----|1 |~~~~|1 |-+--|0 |\n", + "`~~' 4 `--' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-C-S-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Sparse(2), Coord(2)]\n", + "\n", + "structure = [compressed, compressed, sparse, sparse]\n", + "\n", + "taco_structure = [dense, dense, compressed-nonunique, singleton]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " C\n", + " C\n", + " S\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 2\n", + " 3\n", + " 0\n", + " 0\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 5\n", + " 1\n", + " 0\n", + " 4\n", + " 6\n", + " 1\n", + " 1\n", + " 7\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|C -----|S -----|S -|\n", + ".~~~. .~~~. .---. .---.\n", + "┊i0 ┊p0 ┊i1 ┊p1 |i2 |p2 |i3 |\n", + "`~~~' `~~~' `---' `---'\n", + "=============================\n", + ".~~. 0 .~~. 0 .--. 0 .--.\n", + "┊0 ┊~+~~┊0 ┊-+--|0 |~~~~|1 |\n", + "`~~' ┊ `~~' | `--' 1 `--'\n", + " ┊ | .--. .--.\n", + " ┊ `--|0 |~~~~|2 |\n", + " ┊ 2 `--' 2 `--'\n", + " ┊ .~~. .--. .--.\n", + " `~~┊1 ┊-+--|0 |~~~~|0 |\n", + " 2 `~~' | `--' 3 `--'\n", + ".~~. .~~. | .--. .--.\n", + "┊1 ┊~+~~┊0 ┊)|--|0 |~~~~|2 |\n", + "`~~' ┊ `~~' | `--' 4 `--'\n", + " ┊ | .--. .--.\n", + " ┊ `--|1 |~~~~|0 |\n", + " ┊ 5 `--' 5 `--'\n", + " ┊ .~~. 5 .--. .--.\n", + " `~~┊1 ┊-+--|1 |~~~~|0 |\n", + " 4 `~~' | `--' 6 `--'\n", + " | .--. .--.\n", + " |--|1 |~~~~|1 |\n", + " | `--' 7 `--'\n", + " | .--. .--.\n", + " `--|1 |~~~~|2 |\n", + " 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-C-C-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Sparse(3), Coord(1)]\n", + "\n", + "structure = [compressed, compressed, compressed, sparse]\n", + "\n", + "taco_structure = [dense, dense, dense, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " C\n", + " C\n", + " C\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 0\n", + " 4\n", + " 5\n", + " 0\n", + " 1\n", + " 6\n", + " 0\n", + " 4\n", + " 5\n", + " 0\n", + " 8\n", + " 1\n", + " 2\n", + " 8\n", + " 5\n", + " 5\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|C -----|C -----|S -|\n", + ".~~~. .~~~. .~~~. .---.\n", + "┊i0 ┊p0 ┊i1 ┊p1 ┊i2 ┊p2 |i3 |\n", + "`~~~' `~~~' `~~~' `---'\n", + "=============================\n", + ".~~. 0 .~~. 0 .~~. 0 .--.\n", + "┊0 ┊~+~~┊0 ┊~+~~┊0 ┊-+--|1 |\n", + "`~~' ┊ `~~' ┊ `~~' `--|2 |\n", + " ┊ ┊ .~~. 2 `--'\n", + " ┊ `~~┊1 ┊)\n", + " ┊ 2 `~~'\n", + " ┊ .~~. .~~. 2 .--.\n", + " `~~┊1 ┊~+~~┊0 ┊-+--|0 |\n", + " 2 `~~' ┊ `~~' `--|2 |\n", + " ┊ .~~. 4 |--|\n", + " `~~┊1 ┊----|0 |\n", + " 4 `~~' 5 `--'\n", + ".~~. .~~. .~~.\n", + "┊1 ┊~+~~┊0 ┊~+~~┊0 ┊)\n", + "`~~' ┊ `~~' ┊ `~~'\n", + " ┊ ┊ .~~. 5\n", + " ┊ `~~┊1 ┊)\n", + " ┊ 6 `~~'\n", + " ┊ .~~. .~~. 5\n", + " `~~┊1 ┊~+~~┊0 ┊)\n", + " 4 `~~' ┊ `~~'\n", + " ┊ .~~. 5 .--.\n", + " `~~┊1 ┊-+--|0 |\n", + " 8 `~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-C-DC-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Sparse(2), HyperSparse(1), Coord(1)]\n", + "\n", + "structure = [compressed, compressed, doubly_compressed, sparse]\n", + "\n", + "taco_structure = [dense, dense, compressed, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " C\n", + " C\n", + " DC\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 0\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 3\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|C -----|DC ----|S -|\n", + ".~~~. .~~~. .---. .---.\n", + "┊i0 ┊p0 ┊i1 ┊p1 |i2 |p2 |i3 |\n", + "`~~~' `~~~' `---' `---'\n", + "=============================\n", + ".~~. 0 .~~. 0 .--. 0 .--.\n", + "┊0 ┊~+~~┊0 ┊----|0 |-+--|1 |\n", + "`~~' ┊ `~~' 1 `--' `--|2 |\n", + " ┊ .~~. .--. 2 |--|\n", + " `~~┊1 ┊-+--|0 |-+--|0 |\n", + " 2 `~~' | `--' `--|2 |\n", + ".~~. .~~. | .--. 4 |--|\n", + "┊1 ┊~+~~┊0 ┊)`--|1 |----|0 |\n", + "`~~' ┊ `~~' 3 `--' 5 `--'\n", + " ┊ .~~. 3 .--. .--.\n", + " `~~┊1 ┊----|1 |-+--|0 |\n", + " 4 `~~' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-DC-S-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Sparse(1), HyperSparse(1), Coord(2)]\n", + "\n", + "structure = [compressed, doubly_compressed, sparse, sparse]\n", + "\n", + "taco_structure = [dense, compressed, compressed-nonunique, singleton]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " C\n", + " DC\n", + " S\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 3\n", + " 0\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 6\n", + " 1\n", + " 1\n", + " 7\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|DC ----|S -----|S -|\n", + ".~~~. .---. .---. .---.\n", + "┊i0 ┊p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`~~~' `---' `---' `---'\n", + "=============================\n", + ".~~. 0 .--. 0 .--. 0 .--.\n", + "┊0 ┊-+--|0 |-+--|0 |~~~~|1 |\n", + "`~~' | `--' | `--' 1 `--'\n", + " | | .--. .--.\n", + " | `--|0 |~~~~|2 |\n", + " | 2 `--' 2 `--'\n", + " | .--. .--. .--.\n", + " `--|1 |-+--|0 |~~~~|0 |\n", + " 2 `--' | `--' 3 `--'\n", + " | .--. .--.\n", + " |--|0 |~~~~|2 |\n", + " | `--' 4 `--'\n", + " | .--. .--.\n", + " `--|1 |~~~~|0 |\n", + " 5 `--' 5 `--'\n", + ".~~. .--. .--. .--.\n", + "┊1 ┊----|1 |-+--|1 |~~~~|0 |\n", + "`~~' 3 `--' | `--' 6 `--'\n", + " | .--. .--.\n", + " |--|1 |~~~~|1 |\n", + " | `--' 7 `--'\n", + " | .--. .--.\n", + " `--|1 |~~~~|2 |\n", + " 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-DC-C-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Sparse(1), Coord(1), Sparse(1), Coord(1)]\n", + "\n", + "structure = [compressed, doubly_compressed, compressed, sparse]\n", + "\n", + "taco_structure = [dense, compressed, dense, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " C\n", + " DC\n", + " C\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 0\n", + " 4\n", + " 5\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 0\n", + " 6\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|DC ----|C -----|S -|\n", + ".~~~. .---. .~~~. .---.\n", + "┊i0 ┊p0 |i1 |p1 ┊i2 ┊p2 |i3 |\n", + "`~~~' `---' `~~~' `---'\n", + "=============================\n", + ".~~. 0 .--. 0 .~~. 0 .--.\n", + "┊0 ┊-+--|0 |~+~~┊0 ┊-+--|1 |\n", + "`~~' | `--' ┊ `~~' `--|2 |\n", + " | ┊ .~~. 2 `--'\n", + " | `~~┊1 ┊)\n", + " | 2 `~~'\n", + " | .--. .~~. 2 .--.\n", + " `--|1 |~+~~┊0 ┊-+--|0 |\n", + " 2 `--' ┊ `~~' `--|2 |\n", + " ┊ .~~. 4 |--|\n", + " `~~┊1 ┊----|0 |\n", + " 4 `~~' 5 `--'\n", + ".~~. .--. .~~.\n", + "┊1 ┊----|1 |~+~~┊0 ┊)\n", + "`~~' 3 `--' ┊ `~~'\n", + " ┊ .~~. 5 .--.\n", + " `~~┊1 ┊-+--|0 |\n", + " 6 `~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-DC-DC-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Sparse(1), HyperSparse(1), HyperSparse(1), Coord(1)]\n", + "\n", + "structure = [compressed, doubly_compressed, doubly_compressed, sparse]\n", + "\n", + "taco_structure = [dense, compressed, compressed, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " C\n", + " DC\n", + " DC\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|DC ----|DC ----|S -|\n", + ".~~~. .---. .---. .---.\n", + "┊i0 ┊p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`~~~' `---' `---' `---'\n", + "=============================\n", + ".~~. 0 .--. 0 .--. 0 .--.\n", + "┊0 ┊-+--|0 |----|0 |-+--|1 |\n", + "`~~' | `--' 1 `--' `--|2 |\n", + " | .--. .--. 2 |--|\n", + " `--|1 |-+--|0 |-+--|0 |\n", + " 2 `--' | `--' `--|2 |\n", + " | .--. 4 |--|\n", + " `--|1 |----|0 |\n", + " 3 `--' 5 `--'\n", + ".~~. .--. .--. .--.\n", + "┊1 ┊----|1 |----|1 |-+--|0 |\n", + "`~~' 3 `--' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `DC-S-C-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [HyperSparse(1), Coord(1, expanded=True), Sparse(1), Coord(1)]\n", + "\n", + "structure = [doubly_compressed, sparse, compressed, sparse]\n", + "\n", + "taco_structure = [compressed, compressed-nonunique, dense, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " DC\n", + " S\n", + " C\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 3\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 1\n", + " 0\n", + " 6\n", + " 6\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|DC ----|S -----|C -----|S -|\n", + ".---. .---. .~~~. .---.\n", + "|i0 |p0 |i1 |p1 ┊i2 ┊p2 |i3 |\n", + "`---' `---' `~~~' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .~~. 0 .--.\n", + "|0 |-+--|0 |~~~~┊0 ┊-+--|1 |\n", + "`--' | `--' 1 `~~' `--|2 |\n", + " | .--. .~~. 2 `--'\n", + " |--|0 |~~~~┊1 ┊)\n", + " | `--' 2 `~~'\n", + " | .--. .~~. 2 .--.\n", + " |--|1 |~~~~┊0 ┊-+--|0 |\n", + " | `--' 3 `~~' `--|2 |\n", + " | .--. .~~. 4 |--|\n", + " `--|1 |~~~~┊1 ┊----|0 |\n", + " 4 `--' 4 `~~' 5 `--'\n", + ".--. .--. .~~.\n", + "|1 |-+--|1 |~~~~┊0 ┊)\n", + "`--' | `--' 5 `~~'\n", + " | .--. .~~. 5 .--.\n", + " `--|1 |~~~~┊1 ┊-+--|0 |\n", + " 6 `--' 6 `~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `DC-C-S-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Coord(1), Sparse(1), Coord(2)]\n", + "\n", + "structure = [doubly_compressed, compressed, sparse, sparse]\n", + "\n", + "taco_structure = [compressed, dense, compressed-nonunique, singleton]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " DC\n", + " C\n", + " S\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 2\n", + " 3\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 5\n", + " 1\n", + " 0\n", + " 4\n", + " 6\n", + " 1\n", + " 1\n", + " 7\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|DC ----|C -----|S -----|S -|\n", + ".---. .~~~. .---. .---.\n", + "|i0 |p0 ┊i1 ┊p1 |i2 |p2 |i3 |\n", + "`---' `~~~' `---' `---'\n", + "=============================\n", + ".--. 0 .~~. 0 .--. 0 .--.\n", + "|0 |~+~~┊0 ┊-+--|0 |~~~~|1 |\n", + "`--' ┊ `~~' | `--' 1 `--'\n", + " ┊ | .--. .--.\n", + " ┊ `--|0 |~~~~|2 |\n", + " ┊ 2 `--' 2 `--'\n", + " ┊ .~~. .--. .--.\n", + " `~~┊1 ┊-+--|0 |~~~~|0 |\n", + " 2 `~~' | `--' 3 `--'\n", + ".--. .~~. | .--. .--.\n", + "|1 |~+~~┊0 ┊)|--|0 |~~~~|2 |\n", + "`--' ┊ `~~' | `--' 4 `--'\n", + " ┊ | .--. .--.\n", + " ┊ `--|1 |~~~~|0 |\n", + " ┊ 5 `--' 5 `--'\n", + " ┊ .~~. 5 .--. .--.\n", + " `~~┊1 ┊-+--|1 |~~~~|0 |\n", + " 4 `~~' | `--' 6 `--'\n", + " | .--. .--.\n", + " |--|1 |~~~~|1 |\n", + " | `--' 7 `--'\n", + " | .--. .--.\n", + " `--|1 |~~~~|2 |\n", + " 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `DC-C-C-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Coord(1), Sparse(2), Coord(1)]\n", + "\n", + "structure = [doubly_compressed, compressed, compressed, sparse]\n", + "\n", + "taco_structure = [compressed, dense, dense, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " DC\n", + " C\n", + " C\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 0\n", + " 4\n", + " 5\n", + " 1\n", + " 0\n", + " 1\n", + " 6\n", + " 0\n", + " 4\n", + " 5\n", + " 0\n", + " 8\n", + " 1\n", + " 2\n", + " 8\n", + " 5\n", + " 5\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|DC ----|C -----|C -----|S -|\n", + ".---. .~~~. .~~~. .---.\n", + "|i0 |p0 ┊i1 ┊p1 ┊i2 ┊p2 |i3 |\n", + "`---' `~~~' `~~~' `---'\n", + "=============================\n", + ".--. 0 .~~. 0 .~~. 0 .--.\n", + "|0 |~+~~┊0 ┊~+~~┊0 ┊-+--|1 |\n", + "`--' ┊ `~~' ┊ `~~' `--|2 |\n", + " ┊ ┊ .~~. 2 `--'\n", + " ┊ `~~┊1 ┊)\n", + " ┊ 2 `~~'\n", + " ┊ .~~. .~~. 2 .--.\n", + " `~~┊1 ┊~+~~┊0 ┊-+--|0 |\n", + " 2 `~~' ┊ `~~' `--|2 |\n", + " ┊ .~~. 4 |--|\n", + " `~~┊1 ┊----|0 |\n", + " 4 `~~' 5 `--'\n", + ".--. .~~. .~~.\n", + "|1 |~+~~┊0 ┊~+~~┊0 ┊)\n", + "`--' ┊ `~~' ┊ `~~'\n", + " ┊ ┊ .~~. 5\n", + " ┊ `~~┊1 ┊)\n", + " ┊ 6 `~~'\n", + " ┊ .~~. .~~. 5\n", + " `~~┊1 ┊~+~~┊0 ┊)\n", + " 4 `~~' ┊ `~~'\n", + " ┊ .~~. 5 .--.\n", + " `~~┊1 ┊-+--|0 |\n", + " 8 `~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `DC-C-DC-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Coord(1), Sparse(1), HyperSparse(1), Coord(1)]\n", + "\n", + "structure = [doubly_compressed, compressed, doubly_compressed, sparse]\n", + "\n", + "taco_structure = [compressed, dense, compressed, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " DC\n", + " C\n", + " DC\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 3\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|DC ----|C -----|DC ----|S -|\n", + ".---. .~~~. .---. .---.\n", + "|i0 |p0 ┊i1 ┊p1 |i2 |p2 |i3 |\n", + "`---' `~~~' `---' `---'\n", + "=============================\n", + ".--. 0 .~~. 0 .--. 0 .--.\n", + "|0 |~+~~┊0 ┊----|0 |-+--|1 |\n", + "`--' ┊ `~~' 1 `--' `--|2 |\n", + " ┊ .~~. .--. 2 |--|\n", + " `~~┊1 ┊-+--|0 |-+--|0 |\n", + " 2 `~~' | `--' `--|2 |\n", + ".--. .~~. | .--. 4 |--|\n", + "|1 |~+~~┊0 ┊)`--|1 |----|0 |\n", + "`--' ┊ `~~' 3 `--' 5 `--'\n", + " ┊ .~~. 3 .--. .--.\n", + " `~~┊1 ┊----|1 |-+--|0 |\n", + " 4 `~~' 4 `--' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `DC-DC-C-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [HyperSparse(1), Coord(1), Sparse(1), Coord(1)]\n", + "\n", + "structure = [doubly_compressed, doubly_compressed, compressed, sparse]\n", + "\n", + "taco_structure = [compressed, compressed, dense, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " DC\n", + " DC\n", + " C\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 0\n", + " 4\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 0\n", + " 6\n", + " 1\n", + " 2\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|DC ----|DC ----|C -----|S -|\n", + ".---. .---. .~~~. .---.\n", + "|i0 |p0 |i1 |p1 ┊i2 ┊p2 |i3 |\n", + "`---' `---' `~~~' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .~~. 0 .--.\n", + "|0 |-+--|0 |~+~~┊0 ┊-+--|1 |\n", + "`--' | `--' ┊ `~~' `--|2 |\n", + " | ┊ .~~. 2 `--'\n", + " | `~~┊1 ┊)\n", + " | 2 `~~'\n", + " | .--. .~~. 2 .--.\n", + " `--|1 |~+~~┊0 ┊-+--|0 |\n", + " 2 `--' ┊ `~~' `--|2 |\n", + " ┊ .~~. 4 |--|\n", + " `~~┊1 ┊----|0 |\n", + " 4 `~~' 5 `--'\n", + ".--. .--. .~~.\n", + "|1 |----|1 |~+~~┊0 ┊)\n", + "`--' 3 `--' ┊ `~~'\n", + " ┊ .~~. 5 .--.\n", + " `~~┊1 ┊-+--|0 |\n", + " 6 `~~' |--|1 |\n", + " `--|2 |\n", + " 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "sparsities = [\"S\", \"C\", \"DC\"]\n", + "for sparsity in itertools.product(sparsities, sparsities, sparsities, [\"S\"]):\n", + " if \"C\" not in sparsity:\n", + " continue\n", + " structure = \"-\".join(sparsity)\n", + " IPython.display.display(IPython.display.Markdown(f\"# `{structure}`\"))\n", + " st = SparseTensor(indices, shape=(2, 2, 2, 3), structure=structure)\n", + " display_header(st)\n", + " IPython.display.display(st)" + ] + }, + { + "cell_type": "markdown", + "id": "1131a918", + "metadata": {}, + "source": [ + "## Display sparse structures, `shape=(3, 3, 3, 3)`" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "95577c70", + "metadata": { + "scrolled": false + }, + "outputs": [ + { + "data": { + "text/markdown": [ + "# `S-S-C-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Coord(2, expanded=True), Sparse(1), Coord(1)]\n", + "\n", + "structure = [sparse, sparse, compressed, sparse]\n", + "\n", + "taco_structure = [compressed-nonunique, singleton, dense, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " S\n", + " S\n", + " C\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 2\n", + " 3\n", + " 3\n", + " 2\n", + " 0\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 2\n", + " 4\n", + " 0\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 5\n", + " 0\n", + " 1\n", + " 2\n", + " 6\n", + " 6\n", + " 1\n", + " 1\n", + " 0\n", + " 7\n", + " 7\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 8\n", + " 8\n", + " 1\n", + " 2\n", + " 8\n", + " 2\n", + " 5\n", + " 1\n", + " 1\n", + " 2\n", + " 9\n", + " 9\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|S -----|S -----|C -----|S -|\n", + ".---. .---. .~~~. .---.\n", + "|i0 |p0 |i1 |p1 ┊i2 ┊p2 |i3 |\n", + "`---' `---' `~~~' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .~~. 0 .--.\n", + "|0 |~~~~|0 |~~~~┊0 ┊-+--|1 |\n", + "`--' 1 `--' 1 `~~' `--|2 |\n", + ".--. .--. .~~. 2 `--'\n", + "|0 |~~~~|0 |~~~~┊1 ┊)\n", + "`--' 2 `--' 2 `~~'\n", + ".--. .--. .~~. 2\n", + "|0 |~~~~|0 |~~~~┊2 ┊)\n", + "`--' 3 `--' 3 `~~'\n", + ".--. .--. .~~. 2 .--.\n", + "|0 |~~~~|1 |~~~~┊0 ┊-+--|0 |\n", + "`--' 4 `--' 4 `~~' `--|2 |\n", + ".--. .--. .~~. 4 |--|\n", + "|0 |~~~~|1 |~~~~┊1 ┊----|0 |\n", + "`--' 5 `--' 5 `~~' 5 `--'\n", + ".--. .--. .~~.\n", + "|0 |~~~~|1 |~~~~┊2 ┊)\n", + "`--' 6 `--' 6 `~~'\n", + ".--. .--. .~~. 5\n", + "|1 |~~~~|1 |~~~~┊0 ┊)\n", + "`--' 7 `--' 7 `~~'\n", + ".--. .--. .~~. 5 .--.\n", + "|1 |~~~~|1 |~~~~┊1 ┊-+--|0 |\n", + "`--' 8 `--' 8 `~~' |--|1 |\n", + " `--|2 |\n", + ".--. .--. .~~. 8 `--'\n", + "|1 |~~~~|1 |~~~~┊2 ┊)\n", + "`--' 9 `--' 9 `~~' 8" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `S-C-S-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Coord(1, expanded=True), Sparse(1), Coord(2)]\n", + "\n", + "structure = [sparse, compressed, sparse, sparse]\n", + "\n", + "taco_structure = [compressed-nonunique, dense, compressed-nonunique, singleton]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " S\n", + " C\n", + " S\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 0\n", + " 2\n", + " 3\n", + " 0\n", + " 2\n", + " 0\n", + " 2\n", + " 3\n", + " 4\n", + " 1\n", + " 0\n", + " 1\n", + " 0\n", + " 4\n", + " 5\n", + " 5\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 5\n", + " 6\n", + " 1\n", + " 2\n", + " 1\n", + " 1\n", + " 6\n", + " 7\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|S -----|C -----|S -----|S -|\n", + ".---. .~~~. .---. .---.\n", + "|i0 |p0 ┊i1 ┊p1 |i2 |p2 |i3 |\n", + "`---' `~~~' `---' `---'\n", + "=============================\n", + ".--. 0 .~~. 0 .--. 0 .--.\n", + "|0 |~~~~┊0 ┊-+--|0 |~~~~|1 |\n", + "`--' 1 `~~' | `--' 1 `--'\n", + " | .--. .--.\n", + " `--|0 |~~~~|2 |\n", + " 2 `--' 2 `--'\n", + ".--. .~~. .--. .--.\n", + "|0 |~~~~┊1 ┊-+--|0 |~~~~|0 |\n", + "`--' 2 `~~' | `--' 3 `--'\n", + ".--. .~~. | .--. .--.\n", + "|0 |~~~~┊2 ┊)|--|0 |~~~~|2 |\n", + "`--' 3 `~~' | `--' 4 `--'\n", + ".--. .~~. | .--. .--.\n", + "|1 |~~~~┊0 ┊)`--|1 |~~~~|0 |\n", + "`--' 4 `~~' 5 `--' 5 `--'\n", + ".--. .~~. 5 .--. .--.\n", + "|1 |~~~~┊1 ┊-+--|1 |~~~~|0 |\n", + "`--' 5 `~~' | `--' 6 `--'\n", + ".--. .~~. | .--. .--.\n", + "|1 |~~~~┊2 ┊)|--|1 |~~~~|1 |\n", + "`--' 6 `~~' | `--' 7 `--'\n", + " | .--. .--.\n", + " `--|1 |~~~~|2 |\n", + " 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `S-C-C-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Coord(1, expanded=True), Sparse(2), Coord(1)]\n", + "\n", + "structure = [sparse, compressed, compressed, sparse]\n", + "\n", + "taco_structure = [compressed-nonunique, dense, dense, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 2\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 2\n", + " \n", + " S\n", + " C\n", + " C\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " \n", + " 1\n", + " 2\n", + " 3\n", + " 2\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " \n", + " 0\n", + " 5\n", + " 2\n", + " 6\n", + " 0\n", + " 0\n", + " 3\n", + " \n", + " 1\n", + " 2\n", + " 9\n", + " 1\n", + " 0\n", + " 4\n", + " \n", + " 1\n", + " 2\n", + " 12\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " \n", + " 0\n", + " 1\n", + " 2\n", + " 8\n", + " 2\n", + " 15\n", + " 1\n", + " 0\n", + " 6\n", + " \n", + " 1\n", + " 2\n", + " 18\n", + " 2\n", + " 5\n", + " 5\n", + " 5\n", + " 5\n", + " 5\n", + " 5\n", + " 5\n", + " 8\n", + " 8\n", + " 8\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|S -----|C -----|C -----|S -|\n", + ".---. .~~~. .~~~. .---.\n", + "|i0 |p0 ┊i1 ┊p1 ┊i2 ┊p2 |i3 |\n", + "`---' `~~~' `~~~' `---'\n", + "=============================\n", + ".--. 0 .~~. 0 .~~. 0 .--.\n", + "|0 |~~~~┊0 ┊~+~~┊0 ┊-+--|1 |\n", + "`--' 1 `~~' ┊ `~~' `--|2 |\n", + " ┊ .~~. 2 `--'\n", + " ┊~~┊1 ┊)\n", + " ┊ `~~'\n", + " ┊ .~~. 2\n", + " `~~┊2 ┊)\n", + " 3 `~~'\n", + ".--. .~~. .~~. 2 .--.\n", + "|0 |~~~~┊1 ┊~+~~┊0 ┊-+--|0 |\n", + "`--' 2 `~~' ┊ `~~' `--|2 |\n", + " ┊ .~~. 4 |--|\n", + " ┊~~┊1 ┊----|0 |\n", + " ┊ `~~' 5 `--'\n", + " ┊ .~~.\n", + " `~~┊2 ┊)\n", + " 6 `~~'\n", + ".--. .~~. .~~. 5\n", + "|0 |~~~~┊2 ┊~+~~┊0 ┊)\n", + "`--' 3 `~~' ┊ `~~'\n", + " ┊ .~~. 5\n", + " ┊~~┊1 ┊)\n", + " ┊ `~~'\n", + " ┊ .~~. 5\n", + " `~~┊2 ┊)\n", + " 9 `~~'\n", + ".--. .~~. .~~. 5\n", + "|1 |~~~~┊0 ┊~+~~┊0 ┊)\n", + "`--' 4 `~~' ┊ `~~'\n", + " ┊ .~~. 5\n", + " ┊~~┊1 ┊)\n", + " ┊ `~~'\n", + " ┊ .~~. 5\n", + " `~~┊2 ┊)\n", + " 12 `~~'\n", + ".--. .~~. .~~. 5\n", + "|1 |~~~~┊1 ┊~+~~┊0 ┊)\n", + "`--' 5 `~~' ┊ `~~'\n", + " ┊ .~~. 5 .--.\n", + " ┊~~┊1 ┊-+--|0 |\n", + " ┊ `~~' |--|1 |\n", + " ┊ `--|2 |\n", + " ┊ .~~. 8 `--'\n", + " `~~┊2 ┊)\n", + " 15 `~~'\n", + ".--. .~~. .~~. 8\n", + "|1 |~~~~┊2 ┊~+~~┊0 ┊)\n", + "`--' 6 `~~' ┊ `~~'\n", + " ┊ .~~. 8\n", + " ┊~~┊1 ┊)\n", + " ┊ `~~'\n", + " ┊ .~~. 8\n", + " `~~┊2 ┊)\n", + " 18 `~~' 8" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `S-C-DC-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Coord(1, expanded=True), Sparse(1), HyperSparse(1), Coord(1)]\n", + "\n", + "structure = [sparse, compressed, doubly_compressed, sparse]\n", + "\n", + "taco_structure = [compressed-nonunique, dense, compressed, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " S\n", + " C\n", + " DC\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 0\n", + " 2\n", + " 1\n", + " 0\n", + " 3\n", + " 3\n", + " 5\n", + " 3\n", + " 1\n", + " 0\n", + " 4\n", + " 3\n", + " 1\n", + " 1\n", + " 0\n", + " 5\n", + " 4\n", + " 1\n", + " 2\n", + " 1\n", + " 2\n", + " 8\n", + " 6\n", + " 4\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|S -----|C -----|DC ----|S -|\n", + ".---. .~~~. .---. .---.\n", + "|i0 |p0 ┊i1 ┊p1 |i2 |p2 |i3 |\n", + "`---' `~~~' `---' `---'\n", + "=============================\n", + ".--. 0 .~~. 0 .--. 0 .--.\n", + "|0 |~~~~┊0 ┊----|0 |-+--|1 |\n", + "`--' 1 `~~' 1 `--' `--|2 |\n", + ".--. .~~. .--. 2 |--|\n", + "|0 |~~~~┊1 ┊-+--|0 |-+--|0 |\n", + "`--' 2 `~~' | `--' `--|2 |\n", + ".--. .~~. | .--. 4 |--|\n", + "|0 |~~~~┊2 ┊)`--|1 |----|0 |\n", + "`--' 3 `~~' 3 `--' 5 `--'\n", + ".--. .~~. 3\n", + "|1 |~~~~┊0 ┊)\n", + "`--' 4 `~~'\n", + ".--. .~~. 3 .--. .--.\n", + "|1 |~~~~┊1 ┊----|1 |-+--|0 |\n", + "`--' 5 `~~' 4 `--' |--|1 |\n", + ".--. .~~. `--|2 |\n", + "|1 |~~~~┊2 ┊) 8 `--'\n", + "`--' 6 `~~' 4" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `S-DC-C-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Coord(2), Sparse(1), Coord(1)]\n", + "\n", + "structure = [sparse, doubly_compressed, compressed, sparse]\n", + "\n", + "taco_structure = [compressed, singleton, dense, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " S\n", + " DC\n", + " C\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " \n", + " 1\n", + " 2\n", + " 3\n", + " 2\n", + " 0\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " \n", + " 0\n", + " 5\n", + " 2\n", + " 6\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " \n", + " 0\n", + " 1\n", + " 2\n", + " 8\n", + " 2\n", + " 9\n", + " 2\n", + " 5\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|S -----|DC ----|C -----|S -|\n", + ".---. .---. .~~~. .---.\n", + "|i0 |p0 |i1 |p1 ┊i2 ┊p2 |i3 |\n", + "`---' `---' `~~~' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .~~. 0 .--.\n", + "|0 |~~~~|0 |~+~~┊0 ┊-+--|1 |\n", + "`--' 1 `--' ┊ `~~' `--|2 |\n", + " ┊ .~~. 2 `--'\n", + " ┊~~┊1 ┊)\n", + " ┊ `~~'\n", + " ┊ .~~. 2\n", + " `~~┊2 ┊)\n", + " 3 `~~'\n", + ".--. .--. .~~. 2 .--.\n", + "|0 |~~~~|1 |~+~~┊0 ┊-+--|0 |\n", + "`--' 2 `--' ┊ `~~' `--|2 |\n", + " ┊ .~~. 4 |--|\n", + " ┊~~┊1 ┊----|0 |\n", + " ┊ `~~' 5 `--'\n", + " ┊ .~~.\n", + " `~~┊2 ┊)\n", + " 6 `~~'\n", + ".--. .--. .~~. 5\n", + "|1 |~~~~|1 |~+~~┊0 ┊)\n", + "`--' 3 `--' ┊ `~~'\n", + " ┊ .~~. 5 .--.\n", + " ┊~~┊1 ┊-+--|0 |\n", + " ┊ `~~' |--|1 |\n", + " ┊ `--|2 |\n", + " ┊ .~~. 8 `--'\n", + " `~~┊2 ┊)\n", + " 9 `~~' 8" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-S-S-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Sparse(1), Coord(3)]\n", + "\n", + "structure = [compressed, sparse, sparse, sparse]\n", + "\n", + "taco_structure = [dense, compressed-nonunique, singleton, singleton]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " C\n", + " S\n", + " S\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 3\n", + " 3\n", + " 1\n", + " 0\n", + " 2\n", + " 4\n", + " 4\n", + " 1\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 6\n", + " 6\n", + " 2\n", + " 1\n", + " 1\n", + " 1\n", + " 7\n", + " 7\n", + " 1\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|S -----|S -----|S -|\n", + ".~~~. .---. .---. .---.\n", + "┊i0 ┊p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`~~~' `---' `---' `---'\n", + "=============================\n", + ".~~. 0 .--. 0 .--. 0 .--.\n", + "┊0 ┊-+--|0 |~~~~|0 |~~~~|1 |\n", + "`~~' | `--' 1 `--' 1 `--'\n", + " | .--. .--. .--.\n", + " |--|0 |~~~~|0 |~~~~|2 |\n", + " | `--' 2 `--' 2 `--'\n", + " | .--. .--. .--.\n", + " |--|1 |~~~~|0 |~~~~|0 |\n", + " | `--' 3 `--' 3 `--'\n", + " | .--. .--. .--.\n", + " |--|1 |~~~~|0 |~~~~|2 |\n", + " | `--' 4 `--' 4 `--'\n", + " | .--. .--. .--.\n", + " `--|1 |~~~~|1 |~~~~|0 |\n", + " 5 `--' 5 `--' 5 `--'\n", + ".~~. .--. .--. .--.\n", + "┊1 ┊-+--|1 |~~~~|1 |~~~~|0 |\n", + "`~~' | `--' 6 `--' 6 `--'\n", + ".~~. | .--. .--. .--.\n", + "┊2 ┊)|--|1 |~~~~|1 |~~~~|1 |\n", + "`~~' | `--' 7 `--' 7 `--'\n", + " | .--. .--. .--.\n", + " `--|1 |~~~~|1 |~~~~|2 |\n", + " 8 `--' 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-S-C-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Sparse(1), Coord(1, expanded=True), Sparse(1), Coord(1)]\n", + "\n", + "structure = [compressed, sparse, compressed, sparse]\n", + "\n", + "taco_structure = [dense, compressed-nonunique, dense, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " C\n", + " S\n", + " C\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 2\n", + " 0\n", + " 2\n", + " 3\n", + " 2\n", + " 1\n", + " 0\n", + " 4\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 1\n", + " 2\n", + " 6\n", + " 6\n", + " 1\n", + " 0\n", + " 7\n", + " 5\n", + " 2\n", + " 1\n", + " 0\n", + " 8\n", + " 1\n", + " 2\n", + " 8\n", + " 1\n", + " 2\n", + " 9\n", + " 9\n", + " 2\n", + " 5\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|S -----|C -----|S -|\n", + ".~~~. .---. .~~~. .---.\n", + "┊i0 ┊p0 |i1 |p1 ┊i2 ┊p2 |i3 |\n", + "`~~~' `---' `~~~' `---'\n", + "=============================\n", + ".~~. 0 .--. 0 .~~. 0 .--.\n", + "┊0 ┊-+--|0 |~~~~┊0 ┊-+--|1 |\n", + "`~~' | `--' 1 `~~' `--|2 |\n", + " | .--. .~~. 2 `--'\n", + " |--|0 |~~~~┊1 ┊)\n", + " | `--' 2 `~~'\n", + " | .--. .~~. 2\n", + " |--|0 |~~~~┊2 ┊)\n", + " | `--' 3 `~~'\n", + " | .--. .~~. 2 .--.\n", + " |--|1 |~~~~┊0 ┊-+--|0 |\n", + " | `--' 4 `~~' `--|2 |\n", + " | .--. .~~. 4 |--|\n", + " |--|1 |~~~~┊1 ┊----|0 |\n", + " | `--' 5 `~~' 5 `--'\n", + " | .--. .~~.\n", + " `--|1 |~~~~┊2 ┊)\n", + " 6 `--' 6 `~~'\n", + ".~~. .--. .~~. 5\n", + "┊1 ┊-+--|1 |~~~~┊0 ┊)\n", + "`~~' | `--' 7 `~~'\n", + ".~~. | .--. .~~. 5 .--.\n", + "┊2 ┊)|--|1 |~~~~┊1 ┊-+--|0 |\n", + "`~~' | `--' 8 `~~' |--|1 |\n", + " | `--|2 |\n", + " | .--. .~~. 8 `--'\n", + " `--|1 |~~~~┊2 ┊)\n", + " 9 `--' 9 `~~' 8" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-S-DC-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Sparse(1), HyperSparse(2), Coord(1)]\n", + "\n", + "structure = [compressed, sparse, doubly_compressed, sparse]\n", + "\n", + "taco_structure = [dense, compressed, singleton, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " C\n", + " S\n", + " DC\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 3\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 4\n", + " 4\n", + " 1\n", + " 2\n", + " 2\n", + " 8\n", + " 4\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|S -----|DC ----|S -|\n", + ".~~~. .---. .---. .---.\n", + "┊i0 ┊p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`~~~' `---' `---' `---'\n", + "=============================\n", + ".~~. 0 .--. 0 .--. 0 .--.\n", + "┊0 ┊-+--|0 |~~~~|0 |-+--|1 |\n", + "`~~' | `--' 1 `--' `--|2 |\n", + " | .--. .--. 2 |--|\n", + " |--|1 |~~~~|0 |-+--|0 |\n", + " | `--' 2 `--' `--|2 |\n", + " | .--. .--. 4 |--|\n", + " `--|1 |~~~~|1 |----|0 |\n", + " 3 `--' 3 `--' 5 `--'\n", + ".~~. .--. .--. .--.\n", + "┊1 ┊----|1 |~~~~|1 |-+--|0 |\n", + "`~~' 4 `--' 4 `--' |--|1 |\n", + ".~~. `--|2 |\n", + "┊2 ┊) 8 `--'\n", + "`~~' 4" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-C-S-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Sparse(2), Coord(2)]\n", + "\n", + "structure = [compressed, compressed, sparse, sparse]\n", + "\n", + "taco_structure = [dense, dense, compressed-nonunique, singleton]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 2\n", + " \n", + " C\n", + " C\n", + " S\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " \n", + " 0\n", + " 0\n", + " 3\n", + " 2\n", + " 0\n", + " 2\n", + " 3\n", + " 4\n", + " 0\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 5\n", + " \n", + " 1\n", + " 0\n", + " 6\n", + " 2\n", + " 1\n", + " 1\n", + " 6\n", + " 7\n", + " 0\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " 8\n", + " \n", + " 1\n", + " 2\n", + " 9\n", + " 8\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|C -----|S -----|S -|\n", + ".~~~. .~~~. .---. .---.\n", + "┊i0 ┊p0 ┊i1 ┊p1 |i2 |p2 |i3 |\n", + "`~~~' `~~~' `---' `---'\n", + "=============================\n", + ".~~. 0 .~~. 0 .--. 0 .--.\n", + "┊0 ┊~+~~┊0 ┊-+--|0 |~~~~|1 |\n", + "`~~' ┊ `~~' | `--' 1 `--'\n", + " ┊ | .--. .--.\n", + " ┊ `--|0 |~~~~|2 |\n", + " ┊ 2 `--' 2 `--'\n", + " ┊ .~~. .--. .--.\n", + " ┊~~┊1 ┊-+--|0 |~~~~|0 |\n", + " ┊ `~~' | `--' 3 `--'\n", + " ┊ .~~. | .--. .--.\n", + " `~~┊2 ┊)|--|0 |~~~~|2 |\n", + " 3 `~~' | `--' 4 `--'\n", + ".~~. .~~. | .--. .--.\n", + "┊1 ┊~+~~┊0 ┊)`--|1 |~~~~|0 |\n", + "`~~' ┊ `~~' 5 `--' 5 `--'\n", + " ┊ .~~. 5 .--. .--.\n", + " ┊~~┊1 ┊-+--|1 |~~~~|0 |\n", + " ┊ `~~' | `--' 6 `--'\n", + " ┊ .~~. | .--. .--.\n", + " `~~┊2 ┊)|--|1 |~~~~|1 |\n", + " 6 `~~' | `--' 7 `--'\n", + ".~~. .~~. | .--. .--.\n", + "┊2 ┊~+~~┊0 ┊)`--|1 |~~~~|2 |\n", + "`~~' ┊ `~~' 8 `--' 8 `--'\n", + " ┊ .~~. 8\n", + " ┊~~┊1 ┊)\n", + " ┊ `~~'\n", + " ┊ .~~. 8\n", + " `~~┊2 ┊)\n", + " 9 `~~' 8" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-C-C-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Sparse(3), Coord(1)]\n", + "\n", + "structure = [compressed, compressed, compressed, sparse]\n", + "\n", + "taco_structure = [dense, dense, dense, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 2\n", + " \n", + " 1\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 2\n", + " \n", + " 2\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 2\n", + " \n", + " C\n", + " C\n", + " C\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " \n", + " 1\n", + " 2\n", + " 3\n", + " 2\n", + " \n", + " 0\n", + " 2\n", + " 4\n", + " \n", + " 0\n", + " 5\n", + " 2\n", + " 6\n", + " 0\n", + " 3\n", + " \n", + " 1\n", + " 2\n", + " 9\n", + " 0\n", + " \n", + " 1\n", + " 2\n", + " 12\n", + " \n", + " 0\n", + " 5\n", + " \n", + " 0\n", + " 1\n", + " 2\n", + " 8\n", + " 2\n", + " 15\n", + " 0\n", + " 6\n", + " \n", + " 1\n", + " 2\n", + " 18\n", + " 0\n", + " \n", + " 1\n", + " 2\n", + " 21\n", + " \n", + " 0\n", + " \n", + " 1\n", + " 2\n", + " 24\n", + " 0\n", + " 9\n", + " \n", + " 1\n", + " 2\n", + " 27\n", + " 2\n", + " 5\n", + " 5\n", + " 5\n", + " 5\n", + " 5\n", + " 5\n", + " 5\n", + " 8\n", + " 8\n", + " 8\n", + " 8\n", + " 8\n", + " 8\n", + " 8\n", + " 8\n", + " 8\n", + " 8\n", + " 8\n", + " 8\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|C -----|C -----|S -|\n", + ".~~~. .~~~. .~~~. .---.\n", + "┊i0 ┊p0 ┊i1 ┊p1 ┊i2 ┊p2 |i3 |\n", + "`~~~' `~~~' `~~~' `---'\n", + "=============================\n", + ".~~. 0 .~~. 0 .~~. 0 .--.\n", + "┊0 ┊~+~~┊0 ┊~+~~┊0 ┊-+--|1 |\n", + "`~~' ┊ `~~' ┊ `~~' `--|2 |\n", + " ┊ ┊ .~~. 2 `--'\n", + " ┊ ┊~~┊1 ┊)\n", + " ┊ ┊ `~~'\n", + " ┊ ┊ .~~. 2\n", + " ┊ `~~┊2 ┊)\n", + " ┊ 3 `~~'\n", + " ┊ .~~. .~~. 2 .--.\n", + " ┊~~┊1 ┊~+~~┊0 ┊-+--|0 |\n", + " ┊ `~~' ┊ `~~' `--|2 |\n", + " ┊ ┊ .~~. 4 |--|\n", + " ┊ ┊~~┊1 ┊----|0 |\n", + " ┊ ┊ `~~' 5 `--'\n", + " ┊ ┊ .~~.\n", + " ┊ `~~┊2 ┊)\n", + " ┊ 6 `~~'\n", + " ┊ .~~. .~~. 5\n", + " `~~┊2 ┊~+~~┊0 ┊)\n", + " 3 `~~' ┊ `~~'\n", + " ┊ .~~. 5\n", + " ┊~~┊1 ┊)\n", + " ┊ `~~'\n", + " ┊ .~~. 5\n", + " `~~┊2 ┊)\n", + " 9 `~~'\n", + ".~~. .~~. .~~. 5\n", + "┊1 ┊~+~~┊0 ┊~+~~┊0 ┊)\n", + "`~~' ┊ `~~' ┊ `~~'\n", + " ┊ ┊ .~~. 5\n", + " ┊ ┊~~┊1 ┊)\n", + " ┊ ┊ `~~'\n", + " ┊ ┊ .~~. 5\n", + " ┊ `~~┊2 ┊)\n", + " ┊ 12 `~~'\n", + " ┊ .~~. .~~. 5\n", + " ┊~~┊1 ┊~+~~┊0 ┊)\n", + " ┊ `~~' ┊ `~~'\n", + " ┊ ┊ .~~. 5 .--.\n", + " ┊ ┊~~┊1 ┊-+--|0 |\n", + " ┊ ┊ `~~' |--|1 |\n", + " ┊ ┊ `--|2 |\n", + " ┊ ┊ .~~. 8 `--'\n", + " ┊ `~~┊2 ┊)\n", + " ┊ 15 `~~'\n", + " ┊ .~~. .~~. 8\n", + " `~~┊2 ┊~+~~┊0 ┊)\n", + " 6 `~~' ┊ `~~'\n", + " ┊ .~~. 8\n", + " ┊~~┊1 ┊)\n", + " ┊ `~~'\n", + " ┊ .~~. 8\n", + " `~~┊2 ┊)\n", + " 18 `~~'\n", + ".~~. .~~. .~~. 8\n", + "┊2 ┊~+~~┊0 ┊~+~~┊0 ┊)\n", + "`~~' ┊ `~~' ┊ `~~'\n", + " ┊ ┊ .~~. 8\n", + " ┊ ┊~~┊1 ┊)\n", + " ┊ ┊ `~~'\n", + " ┊ ┊ .~~. 8\n", + " ┊ `~~┊2 ┊)\n", + " ┊ 21 `~~'\n", + " ┊ .~~. .~~. 8\n", + " ┊~~┊1 ┊~+~~┊0 ┊)\n", + " ┊ `~~' ┊ `~~'\n", + " ┊ ┊ .~~. 8\n", + " ┊ ┊~~┊1 ┊)\n", + " ┊ ┊ `~~'\n", + " ┊ ┊ .~~. 8\n", + " ┊ `~~┊2 ┊)\n", + " ┊ 24 `~~'\n", + " ┊ .~~. .~~. 8\n", + " `~~┊2 ┊~+~~┊0 ┊)\n", + " 9 `~~' ┊ `~~'\n", + " ┊ .~~. 8\n", + " ┊~~┊1 ┊)\n", + " ┊ `~~'\n", + " ┊ .~~. 8\n", + " `~~┊2 ┊)\n", + " 27 `~~' 8" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-C-DC-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Sparse(2), HyperSparse(1), Coord(1)]\n", + "\n", + "structure = [compressed, compressed, doubly_compressed, sparse]\n", + "\n", + "taco_structure = [dense, dense, compressed, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 2\n", + " \n", + " C\n", + " C\n", + " DC\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " \n", + " 0\n", + " 0\n", + " 2\n", + " 4\n", + " 2\n", + " 1\n", + " 0\n", + " 3\n", + " 3\n", + " 5\n", + " 3\n", + " 0\n", + " 3\n", + " \n", + " 1\n", + " 0\n", + " 4\n", + " 1\n", + " 2\n", + " 2\n", + " 8\n", + " 6\n", + " 0\n", + " \n", + " 1\n", + " 2\n", + " 9\n", + " 4\n", + " 4\n", + " 4\n", + " 4\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|C -----|DC ----|S -|\n", + ".~~~. .~~~. .---. .---.\n", + "┊i0 ┊p0 ┊i1 ┊p1 |i2 |p2 |i3 |\n", + "`~~~' `~~~' `---' `---'\n", + "=============================\n", + ".~~. 0 .~~. 0 .--. 0 .--.\n", + "┊0 ┊~+~~┊0 ┊----|0 |-+--|1 |\n", + "`~~' ┊ `~~' 1 `--' `--|2 |\n", + " ┊ .~~. .--. 2 |--|\n", + " ┊~~┊1 ┊-+--|0 |-+--|0 |\n", + " ┊ `~~' | `--' `--|2 |\n", + " ┊ .~~. | .--. 4 |--|\n", + " `~~┊2 ┊)`--|1 |----|0 |\n", + " 3 `~~' 3 `--' 5 `--'\n", + ".~~. .~~. 3\n", + "┊1 ┊~+~~┊0 ┊)\n", + "`~~' ┊ `~~'\n", + " ┊ .~~. 3 .--. .--.\n", + " ┊~~┊1 ┊----|1 |-+--|0 |\n", + " ┊ `~~' 4 `--' |--|1 |\n", + " ┊ .~~. `--|2 |\n", + " `~~┊2 ┊) 8 `--'\n", + " 6 `~~'\n", + ".~~. .~~. 4\n", + "┊2 ┊~+~~┊0 ┊)\n", + "`~~' ┊ `~~'\n", + " ┊ .~~. 4\n", + " ┊~~┊1 ┊)\n", + " ┊ `~~'\n", + " ┊ .~~. 4\n", + " `~~┊2 ┊)\n", + " 9 `~~' 4" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-DC-S-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Sparse(1), HyperSparse(1), Coord(2)]\n", + "\n", + "structure = [compressed, doubly_compressed, sparse, sparse]\n", + "\n", + "taco_structure = [dense, compressed, compressed-nonunique, singleton]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " C\n", + " DC\n", + " S\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 3\n", + " 0\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 6\n", + " 2\n", + " 1\n", + " 1\n", + " 7\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " 3\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|DC ----|S -----|S -|\n", + ".~~~. .---. .---. .---.\n", + "┊i0 ┊p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`~~~' `---' `---' `---'\n", + "=============================\n", + ".~~. 0 .--. 0 .--. 0 .--.\n", + "┊0 ┊-+--|0 |-+--|0 |~~~~|1 |\n", + "`~~' | `--' | `--' 1 `--'\n", + " | | .--. .--.\n", + " | `--|0 |~~~~|2 |\n", + " | 2 `--' 2 `--'\n", + " | .--. .--. .--.\n", + " `--|1 |-+--|0 |~~~~|0 |\n", + " 2 `--' | `--' 3 `--'\n", + " | .--. .--.\n", + " |--|0 |~~~~|2 |\n", + " | `--' 4 `--'\n", + " | .--. .--.\n", + " `--|1 |~~~~|0 |\n", + " 5 `--' 5 `--'\n", + ".~~. .--. .--. .--.\n", + "┊1 ┊----|1 |-+--|1 |~~~~|0 |\n", + "`~~' 3 `--' | `--' 6 `--'\n", + ".~~. | .--. .--.\n", + "┊2 ┊) |--|1 |~~~~|1 |\n", + "`~~' 3 | `--' 7 `--'\n", + " | .--. .--.\n", + " `--|1 |~~~~|2 |\n", + " 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-DC-C-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Sparse(1), Coord(1), Sparse(1), Coord(1)]\n", + "\n", + "structure = [compressed, doubly_compressed, compressed, sparse]\n", + "\n", + "taco_structure = [dense, compressed, dense, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " C\n", + " DC\n", + " C\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " \n", + " 1\n", + " 2\n", + " 3\n", + " 2\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " \n", + " 0\n", + " 5\n", + " 2\n", + " 6\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 2\n", + " \n", + " 0\n", + " 1\n", + " 2\n", + " 8\n", + " 2\n", + " 9\n", + " 2\n", + " 5\n", + " 3\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|DC ----|C -----|S -|\n", + ".~~~. .---. .~~~. .---.\n", + "┊i0 ┊p0 |i1 |p1 ┊i2 ┊p2 |i3 |\n", + "`~~~' `---' `~~~' `---'\n", + "=============================\n", + ".~~. 0 .--. 0 .~~. 0 .--.\n", + "┊0 ┊-+--|0 |~+~~┊0 ┊-+--|1 |\n", + "`~~' | `--' ┊ `~~' `--|2 |\n", + " | ┊ .~~. 2 `--'\n", + " | ┊~~┊1 ┊)\n", + " | ┊ `~~'\n", + " | ┊ .~~. 2\n", + " | `~~┊2 ┊)\n", + " | 3 `~~'\n", + " | .--. .~~. 2 .--.\n", + " `--|1 |~+~~┊0 ┊-+--|0 |\n", + " 2 `--' ┊ `~~' `--|2 |\n", + " ┊ .~~. 4 |--|\n", + " ┊~~┊1 ┊----|0 |\n", + " ┊ `~~' 5 `--'\n", + " ┊ .~~.\n", + " `~~┊2 ┊)\n", + " 6 `~~'\n", + ".~~. .--. .~~. 5\n", + "┊1 ┊----|1 |~+~~┊0 ┊)\n", + "`~~' 3 `--' ┊ `~~'\n", + ".~~. ┊ .~~. 5 .--.\n", + "┊2 ┊) ┊~~┊1 ┊-+--|0 |\n", + "`~~' 3 ┊ `~~' |--|1 |\n", + " ┊ `--|2 |\n", + " ┊ .~~. 8 `--'\n", + " `~~┊2 ┊)\n", + " 9 `~~' 8" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `C-DC-DC-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Sparse(1), HyperSparse(1), HyperSparse(1), Coord(1)]\n", + "\n", + "structure = [compressed, doubly_compressed, doubly_compressed, sparse]\n", + "\n", + "taco_structure = [dense, compressed, compressed, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " C\n", + " DC\n", + " DC\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 1\n", + " 0\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 4\n", + " 1\n", + " 2\n", + " 2\n", + " 8\n", + " 3\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|C -----|DC ----|DC ----|S -|\n", + ".~~~. .---. .---. .---.\n", + "┊i0 ┊p0 |i1 |p1 |i2 |p2 |i3 |\n", + "`~~~' `---' `---' `---'\n", + "=============================\n", + ".~~. 0 .--. 0 .--. 0 .--.\n", + "┊0 ┊-+--|0 |----|0 |-+--|1 |\n", + "`~~' | `--' 1 `--' `--|2 |\n", + " | .--. .--. 2 |--|\n", + " `--|1 |-+--|0 |-+--|0 |\n", + " 2 `--' | `--' `--|2 |\n", + " | .--. 4 |--|\n", + " `--|1 |----|0 |\n", + " 3 `--' 5 `--'\n", + ".~~. .--. .--. .--.\n", + "┊1 ┊----|1 |----|1 |-+--|0 |\n", + "`~~' 3 `--' 4 `--' |--|1 |\n", + ".~~. `--|2 |\n", + "┊2 ┊) 8 `--'\n", + "`~~' 3" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `DC-S-C-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [HyperSparse(1), Coord(1, expanded=True), Sparse(1), Coord(1)]\n", + "\n", + "structure = [doubly_compressed, sparse, compressed, sparse]\n", + "\n", + "taco_structure = [compressed, compressed-nonunique, dense, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " DC\n", + " S\n", + " C\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " 0\n", + " 1\n", + " 2\n", + " 0\n", + " 2\n", + " 3\n", + " 2\n", + " 1\n", + " 0\n", + " 4\n", + " 2\n", + " 4\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 1\n", + " 2\n", + " 6\n", + " 6\n", + " 1\n", + " 1\n", + " 0\n", + " 7\n", + " 5\n", + " 1\n", + " 0\n", + " 8\n", + " 1\n", + " 2\n", + " 8\n", + " 1\n", + " 2\n", + " 9\n", + " 9\n", + " 2\n", + " 5\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|DC ----|S -----|C -----|S -|\n", + ".---. .---. .~~~. .---.\n", + "|i0 |p0 |i1 |p1 ┊i2 ┊p2 |i3 |\n", + "`---' `---' `~~~' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .~~. 0 .--.\n", + "|0 |-+--|0 |~~~~┊0 ┊-+--|1 |\n", + "`--' | `--' 1 `~~' `--|2 |\n", + " | .--. .~~. 2 `--'\n", + " |--|0 |~~~~┊1 ┊)\n", + " | `--' 2 `~~'\n", + " | .--. .~~. 2\n", + " |--|0 |~~~~┊2 ┊)\n", + " | `--' 3 `~~'\n", + " | .--. .~~. 2 .--.\n", + " |--|1 |~~~~┊0 ┊-+--|0 |\n", + " | `--' 4 `~~' `--|2 |\n", + " | .--. .~~. 4 |--|\n", + " |--|1 |~~~~┊1 ┊----|0 |\n", + " | `--' 5 `~~' 5 `--'\n", + " | .--. .~~.\n", + " `--|1 |~~~~┊2 ┊)\n", + " 6 `--' 6 `~~'\n", + ".--. .--. .~~. 5\n", + "|1 |-+--|1 |~~~~┊0 ┊)\n", + "`--' | `--' 7 `~~'\n", + " | .--. .~~. 5 .--.\n", + " |--|1 |~~~~┊1 ┊-+--|0 |\n", + " | `--' 8 `~~' |--|1 |\n", + " | `--|2 |\n", + " | .--. .~~. 8 `--'\n", + " `--|1 |~~~~┊2 ┊)\n", + " 9 `--' 9 `~~' 8" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `DC-C-S-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Coord(1), Sparse(1), Coord(2)]\n", + "\n", + "structure = [doubly_compressed, compressed, sparse, sparse]\n", + "\n", + "taco_structure = [compressed, dense, compressed-nonunique, singleton]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " DC\n", + " C\n", + " S\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 2\n", + " \n", + " 0\n", + " 0\n", + " 3\n", + " 2\n", + " 0\n", + " 2\n", + " 3\n", + " 4\n", + " 1\n", + " 0\n", + " 1\n", + " 0\n", + " 5\n", + " 5\n", + " 5\n", + " \n", + " 1\n", + " 0\n", + " 6\n", + " 2\n", + " 1\n", + " 1\n", + " 6\n", + " 7\n", + " 1\n", + " 2\n", + " 8\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|DC ----|C -----|S -----|S -|\n", + ".---. .~~~. .---. .---.\n", + "|i0 |p0 ┊i1 ┊p1 |i2 |p2 |i3 |\n", + "`---' `~~~' `---' `---'\n", + "=============================\n", + ".--. 0 .~~. 0 .--. 0 .--.\n", + "|0 |~+~~┊0 ┊-+--|0 |~~~~|1 |\n", + "`--' ┊ `~~' | `--' 1 `--'\n", + " ┊ | .--. .--.\n", + " ┊ `--|0 |~~~~|2 |\n", + " ┊ 2 `--' 2 `--'\n", + " ┊ .~~. .--. .--.\n", + " ┊~~┊1 ┊-+--|0 |~~~~|0 |\n", + " ┊ `~~' | `--' 3 `--'\n", + " ┊ .~~. | .--. .--.\n", + " `~~┊2 ┊)|--|0 |~~~~|2 |\n", + " 3 `~~' | `--' 4 `--'\n", + ".--. .~~. | .--. .--.\n", + "|1 |~+~~┊0 ┊)`--|1 |~~~~|0 |\n", + "`--' ┊ `~~' 5 `--' 5 `--'\n", + " ┊ .~~. 5 .--. .--.\n", + " ┊~~┊1 ┊-+--|1 |~~~~|0 |\n", + " ┊ `~~' | `--' 6 `--'\n", + " ┊ .~~. | .--. .--.\n", + " `~~┊2 ┊)|--|1 |~~~~|1 |\n", + " 6 `~~' | `--' 7 `--'\n", + " | .--. .--.\n", + " `--|1 |~~~~|2 |\n", + " 8 `--' 8 `--'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `DC-C-C-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Coord(1), Sparse(2), Coord(1)]\n", + "\n", + "structure = [doubly_compressed, compressed, compressed, sparse]\n", + "\n", + "taco_structure = [compressed, dense, dense, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 2\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " 2\n", + " \n", + " DC\n", + " C\n", + " C\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " \n", + " 1\n", + " 2\n", + " 3\n", + " 2\n", + " \n", + " 0\n", + " 2\n", + " 4\n", + " \n", + " 0\n", + " 5\n", + " 2\n", + " 6\n", + " 0\n", + " 3\n", + " \n", + " 1\n", + " 2\n", + " 9\n", + " 1\n", + " 0\n", + " \n", + " 1\n", + " 2\n", + " 12\n", + " \n", + " 0\n", + " 5\n", + " \n", + " 0\n", + " 1\n", + " 2\n", + " 8\n", + " 2\n", + " 15\n", + " 0\n", + " 6\n", + " \n", + " 1\n", + " 2\n", + " 18\n", + " 2\n", + " 5\n", + " 5\n", + " 5\n", + " 5\n", + " 5\n", + " 5\n", + " 5\n", + " 8\n", + " 8\n", + " 8\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|DC ----|C -----|C -----|S -|\n", + ".---. .~~~. .~~~. .---.\n", + "|i0 |p0 ┊i1 ┊p1 ┊i2 ┊p2 |i3 |\n", + "`---' `~~~' `~~~' `---'\n", + "=============================\n", + ".--. 0 .~~. 0 .~~. 0 .--.\n", + "|0 |~+~~┊0 ┊~+~~┊0 ┊-+--|1 |\n", + "`--' ┊ `~~' ┊ `~~' `--|2 |\n", + " ┊ ┊ .~~. 2 `--'\n", + " ┊ ┊~~┊1 ┊)\n", + " ┊ ┊ `~~'\n", + " ┊ ┊ .~~. 2\n", + " ┊ `~~┊2 ┊)\n", + " ┊ 3 `~~'\n", + " ┊ .~~. .~~. 2 .--.\n", + " ┊~~┊1 ┊~+~~┊0 ┊-+--|0 |\n", + " ┊ `~~' ┊ `~~' `--|2 |\n", + " ┊ ┊ .~~. 4 |--|\n", + " ┊ ┊~~┊1 ┊----|0 |\n", + " ┊ ┊ `~~' 5 `--'\n", + " ┊ ┊ .~~.\n", + " ┊ `~~┊2 ┊)\n", + " ┊ 6 `~~'\n", + " ┊ .~~. .~~. 5\n", + " `~~┊2 ┊~+~~┊0 ┊)\n", + " 3 `~~' ┊ `~~'\n", + " ┊ .~~. 5\n", + " ┊~~┊1 ┊)\n", + " ┊ `~~'\n", + " ┊ .~~. 5\n", + " `~~┊2 ┊)\n", + " 9 `~~'\n", + ".--. .~~. .~~. 5\n", + "|1 |~+~~┊0 ┊~+~~┊0 ┊)\n", + "`--' ┊ `~~' ┊ `~~'\n", + " ┊ ┊ .~~. 5\n", + " ┊ ┊~~┊1 ┊)\n", + " ┊ ┊ `~~'\n", + " ┊ ┊ .~~. 5\n", + " ┊ `~~┊2 ┊)\n", + " ┊ 12 `~~'\n", + " ┊ .~~. .~~. 5\n", + " ┊~~┊1 ┊~+~~┊0 ┊)\n", + " ┊ `~~' ┊ `~~'\n", + " ┊ ┊ .~~. 5 .--.\n", + " ┊ ┊~~┊1 ┊-+--|0 |\n", + " ┊ ┊ `~~' |--|1 |\n", + " ┊ ┊ `--|2 |\n", + " ┊ ┊ .~~. 8 `--'\n", + " ┊ `~~┊2 ┊)\n", + " ┊ 15 `~~'\n", + " ┊ .~~. .~~. 8\n", + " `~~┊2 ┊~+~~┊0 ┊)\n", + " 6 `~~' ┊ `~~'\n", + " ┊ .~~. 8\n", + " ┊~~┊1 ┊)\n", + " ┊ `~~'\n", + " ┊ .~~. 8\n", + " `~~┊2 ┊)\n", + " 18 `~~' 8" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `DC-C-DC-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [Coord(1), Sparse(1), HyperSparse(1), Coord(1)]\n", + "\n", + "structure = [doubly_compressed, compressed, doubly_compressed, sparse]\n", + "\n", + "taco_structure = [compressed, dense, compressed, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " DC\n", + " C\n", + " DC\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 1\n", + " 2\n", + " 2\n", + " \n", + " 0\n", + " 0\n", + " 2\n", + " 4\n", + " 2\n", + " 1\n", + " 0\n", + " 3\n", + " 3\n", + " 5\n", + " 3\n", + " 1\n", + " 0\n", + " 3\n", + " \n", + " 1\n", + " 0\n", + " 4\n", + " 1\n", + " 2\n", + " 2\n", + " 8\n", + " 6\n", + " 4\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|DC ----|C -----|DC ----|S -|\n", + ".---. .~~~. .---. .---.\n", + "|i0 |p0 ┊i1 ┊p1 |i2 |p2 |i3 |\n", + "`---' `~~~' `---' `---'\n", + "=============================\n", + ".--. 0 .~~. 0 .--. 0 .--.\n", + "|0 |~+~~┊0 ┊----|0 |-+--|1 |\n", + "`--' ┊ `~~' 1 `--' `--|2 |\n", + " ┊ .~~. .--. 2 |--|\n", + " ┊~~┊1 ┊-+--|0 |-+--|0 |\n", + " ┊ `~~' | `--' `--|2 |\n", + " ┊ .~~. | .--. 4 |--|\n", + " `~~┊2 ┊)`--|1 |----|0 |\n", + " 3 `~~' 3 `--' 5 `--'\n", + ".--. .~~. 3\n", + "|1 |~+~~┊0 ┊)\n", + "`--' ┊ `~~'\n", + " ┊ .~~. 3 .--. .--.\n", + " ┊~~┊1 ┊----|1 |-+--|0 |\n", + " ┊ `~~' 4 `--' |--|1 |\n", + " ┊ .~~. `--|2 |\n", + " `~~┊2 ┊) 8 `--'\n", + " 6 `~~' 4" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "# `DC-DC-C-S`" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "```\n", + "bundled_groups = [HyperSparse(1), Coord(1), Sparse(1), Coord(1)]\n", + "\n", + "structure = [doubly_compressed, doubly_compressed, compressed, sparse]\n", + "\n", + "taco_structure = [compressed, compressed, dense, compressed]\n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/svg+xml": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " i0\n", + " \n", + " i1\n", + " \n", + " i2\n", + " \n", + " i3\n", + " \n", + " 0\n", + " \n", + " 0\n", + " \n", + " 1\n", + " \n", + " 1\n", + " \n", + " DC\n", + " DC\n", + " C\n", + " S\n", + " p0\n", + " p1\n", + " p2\n", + " \n", + " \n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 0\n", + " 1\n", + " 2\n", + " 2\n", + " \n", + " 1\n", + " 2\n", + " 3\n", + " 2\n", + " 1\n", + " 0\n", + " 2\n", + " 2\n", + " 4\n", + " \n", + " 0\n", + " 5\n", + " 2\n", + " 6\n", + " 1\n", + " 1\n", + " 0\n", + " 3\n", + " 5\n", + " \n", + " 0\n", + " 1\n", + " 2\n", + " 8\n", + " 2\n", + " 9\n", + " 2\n", + " 5\n", + " 8\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "" + ], + "text/plain": [ + "|DC ----|DC ----|C -----|S -|\n", + ".---. .---. .~~~. .---.\n", + "|i0 |p0 |i1 |p1 ┊i2 ┊p2 |i3 |\n", + "`---' `---' `~~~' `---'\n", + "=============================\n", + ".--. 0 .--. 0 .~~. 0 .--.\n", + "|0 |-+--|0 |~+~~┊0 ┊-+--|1 |\n", + "`--' | `--' ┊ `~~' `--|2 |\n", + " | ┊ .~~. 2 `--'\n", + " | ┊~~┊1 ┊)\n", + " | ┊ `~~'\n", + " | ┊ .~~. 2\n", + " | `~~┊2 ┊)\n", + " | 3 `~~'\n", + " | .--. .~~. 2 .--.\n", + " `--|1 |~+~~┊0 ┊-+--|0 |\n", + " 2 `--' ┊ `~~' `--|2 |\n", + " ┊ .~~. 4 |--|\n", + " ┊~~┊1 ┊----|0 |\n", + " ┊ `~~' 5 `--'\n", + " ┊ .~~.\n", + " `~~┊2 ┊)\n", + " 6 `~~'\n", + ".--. .--. .~~. 5\n", + "|1 |----|1 |~+~~┊0 ┊)\n", + "`--' 3 `--' ┊ `~~'\n", + " ┊ .~~. 5 .--.\n", + " ┊~~┊1 ┊-+--|0 |\n", + " ┊ `~~' |--|1 |\n", + " ┊ `--|2 |\n", + " ┊ .~~. 8 `--'\n", + " `~~┊2 ┊)\n", + " 9 `~~' 8" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "for sparsity in itertools.product(sparsities, sparsities, sparsities, [\"S\"]):\n", + " if \"C\" not in sparsity:\n", + " continue\n", + " structure = \"-\".join(sparsity)\n", + " IPython.display.display(IPython.display.Markdown(f\"# `{structure}`\"))\n", + " st = SparseTensor(indices, shape=(3, 3, 3, 3), structure=structure)\n", + " display_header(st, seen_taco=seen_taco)\n", + " IPython.display.display(st)" + ] + }, + { + "cell_type": "markdown", + "id": "07f40f47", + "metadata": {}, + "source": [ + "# voilà!\n", + "
" + ] + }, + { + "cell_type": "markdown", + "id": "54777a45-18e2-41f0-aaca-3863ae0d09e4", + "metadata": {}, + "source": [ + "## ✨ _Bonus: brain teasers_ ✨\n", + "\n", + "#### Are any of these valid TACO (or MLIR sparse tensor) formats, and, if so, what do they mean?\n", + "```\n", + "- [compressed, compressed, compressed-nonunique, compressed]\n", + "- [compressed, compressed-nonunique, compressed, compressed]\n", + "- [compressed, compressed-nonunique, compressed-nonunique, compressed]\n", + "- [compressed, compressed-nonunique, compressed-nonunique, singleton]\n", + "- [compressed, compressed-nonunique, singleton, compressed]\n", + "- [compressed, dense, compressed-nonunique, compressed]\n", + "- [compressed, singleton, compressed-nonunique, compressed]\n", + "- [compressed-nonunique, compressed, compressed, compressed]\n", + "- [compressed-nonunique, compressed, compressed-nonunique, compressed]\n", + "- [compressed-nonunique, compressed, compressed-nonunique, singleton]\n", + "- [compressed-nonunique, compressed, dense, compressed]\n", + "- [compressed-nonunique, compressed, singleton, compressed]\n", + "- [compressed-nonunique, compressed-nonunique, compressed, compressed]\n", + "- [compressed-nonunique, compressed-nonunique, compressed-nonunique, compressed]\n", + "- [compressed-nonunique, compressed-nonunique, compressed-nonunique, singleton]\n", + "- [compressed-nonunique, compressed-nonunique, dense, compressed]\n", + "- [compressed-nonunique, compressed-nonunique, singleton, compressed]\n", + "- [compressed-nonunique, compressed-nonunique, singleton, singleton]\n", + "- [compressed-nonunique, dense, compressed-nonunique, compressed]\n", + "- [compressed-nonunique, singleton, compressed, compressed]\n", + "- [compressed-nonunique, singleton, compressed-nonunique, compressed]\n", + "- [compressed-nonunique, singleton, compressed-nonunique, singleton]\n", + "- [compressed-nonunique, singleton, singleton, compressed]\n", + "- [dense, compressed, compressed-nonunique, compressed]\n", + "- [dense, compressed-nonunique, compressed, compressed]\n", + "- [dense, compressed-nonunique, compressed-nonunique, compressed]\n", + "- [dense, compressed-nonunique, compressed-nonunique, singleton]\n", + "- [dense, compressed-nonunique, singleton, compressed]\n", + "- [dense, dense, compressed-nonunique, compressed]\n", + "```" + ] + }, + { + "cell_type": "markdown", + "id": "e40edac3-f736-4899-bcff-216d2b6be344", + "metadata": {}, + "source": [ + "#### What about these?\n", + "```\n", + "- [compressed, compressed, compressed, compressed-nonunique]\n", + "- [compressed, compressed, compressed-nonunique, compressed-nonunique]\n", + "- [compressed, compressed, dense, compressed-nonunique]\n", + "- [compressed, compressed, singleton, compressed-nonunique]\n", + "- [compressed, compressed-nonunique, compressed, compressed-nonunique]\n", + "- [compressed, compressed-nonunique, compressed-nonunique, compressed-nonunique]\n", + "- [compressed, compressed-nonunique, dense, compressed-nonunique]\n", + "- [compressed, compressed-nonunique, singleton, compressed-nonunique]\n", + "- [compressed, dense, compressed, compressed-nonunique]\n", + "- [compressed, dense, compressed-nonunique, compressed-nonunique]\n", + "- [compressed, dense, dense, compressed-nonunique]\n", + "- [compressed, dense, singleton, compressed-nonunique]\n", + "- [compressed, singleton, compressed, compressed-nonunique]\n", + "- [compressed, singleton, compressed-nonunique, compressed-nonunique]\n", + "- [compressed, singleton, dense, compressed-nonunique]\n", + "- [compressed, singleton, singleton, compressed-nonunique]\n", + "- [compressed-nonunique, compressed, compressed, compressed-nonunique]\n", + "- [compressed-nonunique, compressed, compressed-nonunique, compressed-nonunique]\n", + "- [compressed-nonunique, compressed, dense, compressed-nonunique]\n", + "- [compressed-nonunique, compressed, singleton, compressed-nonunique]\n", + "- [compressed-nonunique, compressed-nonunique, compressed, compressed-nonunique]\n", + "- [compressed-nonunique, compressed-nonunique, compressed-nonunique, compressed-nonunique]\n", + "- [compressed-nonunique, compressed-nonunique, dense, compressed-nonunique]\n", + "- [compressed-nonunique, compressed-nonunique, singleton, compressed-nonunique]\n", + "- [compressed-nonunique, dense, compressed, compressed-nonunique]\n", + "- [compressed-nonunique, dense, compressed-nonunique, compressed-nonunique]\n", + "- [compressed-nonunique, dense, dense, compressed-nonunique]\n", + "- [compressed-nonunique, dense, singleton, compressed-nonunique]\n", + "- [compressed-nonunique, singleton, compressed, compressed-nonunique]\n", + "- [compressed-nonunique, singleton, compressed-nonunique, compressed-nonunique]\n", + "- [compressed-nonunique, singleton, dense, compressed-nonunique]\n", + "- [compressed-nonunique, singleton, singleton, compressed-nonunique]\n", + "- [dense, compressed, compressed, compressed-nonunique]\n", + "- [dense, compressed, compressed-nonunique, compressed-nonunique]\n", + "- [dense, compressed, dense, compressed-nonunique]\n", + "- [dense, compressed, singleton, compressed-nonunique]\n", + "- [dense, compressed-nonunique, compressed, compressed-nonunique]\n", + "- [dense, compressed-nonunique, compressed-nonunique, compressed-nonunique]\n", + "- [dense, compressed-nonunique, dense, compressed-nonunique]\n", + "- [dense, compressed-nonunique, singleton, compressed-nonunique]\n", + "- [dense, dense, compressed, compressed-nonunique]\n", + "- [dense, dense, compressed-nonunique, compressed-nonunique]\n", + "- [dense, dense, dense, compressed-nonunique]\n", + "- [dense, dense, singleton, compressed-nonunique]\n", + "- [dense, singleton, compressed, compressed-nonunique]\n", + "- [dense, singleton, compressed-nonunique, compressed-nonunique]\n", + "- [dense, singleton, dense, compressed-nonunique]\n", + "- [dense, singleton, singleton, compressed-nonunique]\n", + "```" + ] + }, + { + "cell_type": "markdown", + "id": "5b3145a2-6db6-4df3-a935-c0d99a4a4143", + "metadata": {}, + "source": [ + "#### Or these?\n", + "```\n", + "- [singleton, compressed, compressed, compressed]\n", + "- [singleton, compressed, compressed, compressed-nonunique]\n", + "- [singleton, compressed, compressed, singleton]\n", + "- [singleton, compressed, compressed-nonunique, compressed]\n", + "- [singleton, compressed, compressed-nonunique, compressed-nonunique]\n", + "- [singleton, compressed, compressed-nonunique, singleton]\n", + "- [singleton, compressed, dense, compressed]\n", + "- [singleton, compressed, dense, compressed-nonunique]\n", + "- [singleton, compressed, dense, singleton]\n", + "- [singleton, compressed, singleton, compressed]\n", + "- [singleton, compressed, singleton, compressed-nonunique]\n", + "- [singleton, compressed, singleton, singleton]\n", + "- [singleton, compressed-nonunique, compressed, compressed]\n", + "- [singleton, compressed-nonunique, compressed, compressed-nonunique]\n", + "- [singleton, compressed-nonunique, compressed, singleton]\n", + "- [singleton, compressed-nonunique, compressed-nonunique, compressed]\n", + "- [singleton, compressed-nonunique, compressed-nonunique, compressed-nonunique]\n", + "- [singleton, compressed-nonunique, compressed-nonunique, singleton]\n", + "- [singleton, compressed-nonunique, dense, compressed]\n", + "- [singleton, compressed-nonunique, dense, compressed-nonunique]\n", + "- [singleton, compressed-nonunique, dense, singleton]\n", + "- [singleton, compressed-nonunique, singleton, compressed]\n", + "- [singleton, compressed-nonunique, singleton, compressed-nonunique]\n", + "- [singleton, compressed-nonunique, singleton, singleton]\n", + "- [singleton, dense, compressed, compressed]\n", + "- [singleton, dense, compressed, compressed-nonunique]\n", + "- [singleton, dense, compressed, singleton]\n", + "- [singleton, dense, compressed-nonunique, compressed]\n", + "- [singleton, dense, compressed-nonunique, compressed-nonunique]\n", + "- [singleton, dense, compressed-nonunique, singleton]\n", + "- [singleton, dense, dense, compressed]\n", + "- [singleton, dense, dense, compressed-nonunique]\n", + "- [singleton, dense, dense, singleton]\n", + "- [singleton, dense, singleton, compressed]\n", + "- [singleton, dense, singleton, compressed-nonunique]\n", + "- [singleton, dense, singleton, singleton]\n", + "- [singleton, singleton, compressed, compressed]\n", + "- [singleton, singleton, compressed, compressed-nonunique]\n", + "- [singleton, singleton, compressed, singleton]\n", + "- [singleton, singleton, compressed-nonunique, compressed]\n", + "- [singleton, singleton, compressed-nonunique, compressed-nonunique]\n", + "- [singleton, singleton, compressed-nonunique, singleton]\n", + "- [singleton, singleton, dense, compressed]\n", + "- [singleton, singleton, dense, compressed-nonunique]\n", + "- [singleton, singleton, dense, singleton]\n", + "- [singleton, singleton, singleton, compressed]\n", + "- [singleton, singleton, singleton, compressed-nonunique]\n", + "- [singleton, singleton, singleton, singleton]\n", + "```" + ] + }, + { + "cell_type": "markdown", + "id": "3c1d13b5-03ee-441f-a448-c004f6be61ca", + "metadata": {}, + "source": [ + "#### Or, finally, these?\n", + "```\n", + "- [compressed, compressed, compressed, singleton]\n", + "- [compressed, compressed, dense, singleton]\n", + "- [compressed, compressed, singleton, singleton]\n", + "- [compressed, compressed-nonunique, compressed, singleton]\n", + "- [compressed, compressed-nonunique, dense, singleton]\n", + "- [compressed, dense, compressed, singleton]\n", + "- [compressed, dense, dense, singleton]\n", + "- [compressed, dense, singleton, compressed]\n", + "- [compressed, dense, singleton, singleton]\n", + "- [compressed, singleton, compressed, singleton]\n", + "- [compressed, singleton, dense, singleton]\n", + "- [compressed, singleton, singleton, singleton]\n", + "- [compressed-nonunique, compressed, compressed, singleton]\n", + "- [compressed-nonunique, compressed, dense, singleton]\n", + "- [compressed-nonunique, compressed, singleton, singleton]\n", + "- [compressed-nonunique, compressed-nonunique, compressed, singleton]\n", + "- [compressed-nonunique, compressed-nonunique, dense, singleton]\n", + "- [compressed-nonunique, dense, compressed, singleton]\n", + "- [compressed-nonunique, dense, dense, singleton]\n", + "- [compressed-nonunique, dense, singleton, compressed]\n", + "- [compressed-nonunique, dense, singleton, singleton]\n", + "- [compressed-nonunique, singleton, compressed, singleton]\n", + "- [compressed-nonunique, singleton, dense, singleton]\n", + "- [dense, compressed, compressed, singleton]\n", + "- [dense, compressed, dense, singleton]\n", + "- [dense, compressed, singleton, singleton]\n", + "- [dense, compressed-nonunique, compressed, singleton]\n", + "- [dense, compressed-nonunique, dense, singleton]\n", + "- [dense, dense, compressed, singleton]\n", + "- [dense, dense, dense, singleton]\n", + "- [dense, dense, singleton, compressed]\n", + "- [dense, dense, singleton, singleton]\n", + "- [dense, singleton, compressed, compressed]\n", + "- [dense, singleton, compressed, singleton]\n", + "- [dense, singleton, compressed-nonunique, compressed]\n", + "- [dense, singleton, compressed-nonunique, singleton]\n", + "- [dense, singleton, dense, compressed]\n", + "- [dense, singleton, dense, singleton]\n", + "- [dense, singleton, singleton, compressed]\n", + "- [dense, singleton, singleton, singleton]\n", + "```" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "ac837a77-1536-4eb1-a7c7-bec44dbc56dc", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['compressed', 'compressed', 'compressed', 'compressed']\n", + "[doubly_compressed, doubly_compressed, doubly_compressed, sparse]\n", + "\n", + "['compressed', 'compressed', 'compressed-nonunique', 'singleton']\n", + "[doubly_compressed, doubly_compressed, sparse, sparse]\n", + "\n", + "['compressed', 'compressed', 'dense', 'compressed']\n", + "[doubly_compressed, doubly_compressed, compressed, sparse]\n", + "\n", + "['compressed', 'compressed', 'singleton', 'compressed']\n", + "[doubly_compressed, sparse, doubly_compressed, sparse]\n", + "\n", + "['compressed', 'compressed-nonunique', 'dense', 'compressed']\n", + "[doubly_compressed, sparse, compressed, sparse]\n", + "\n", + "['compressed', 'compressed-nonunique', 'singleton', 'singleton']\n", + "[doubly_compressed, sparse, sparse, sparse]\n", + "\n", + "['compressed', 'dense', 'compressed', 'compressed']\n", + "[doubly_compressed, compressed, doubly_compressed, sparse]\n", + "\n", + "['compressed', 'dense', 'compressed-nonunique', 'singleton']\n", + "[doubly_compressed, compressed, sparse, sparse]\n", + "\n", + "['compressed', 'dense', 'dense', 'compressed']\n", + "[doubly_compressed, compressed, compressed, sparse]\n", + "\n", + "['compressed', 'singleton', 'compressed', 'compressed']\n", + "[sparse, doubly_compressed, doubly_compressed, sparse]\n", + "\n", + "['compressed', 'singleton', 'compressed-nonunique', 'singleton']\n", + "[sparse, doubly_compressed, sparse, sparse]\n", + "\n", + "['compressed', 'singleton', 'dense', 'compressed']\n", + "[sparse, doubly_compressed, compressed, sparse]\n", + "\n", + "['compressed', 'singleton', 'singleton', 'compressed']\n", + "[sparse, sparse, doubly_compressed, sparse]\n", + "\n", + "['compressed-nonunique', 'dense', 'compressed', 'compressed']\n", + "[sparse, compressed, doubly_compressed, sparse]\n", + "\n", + "['compressed-nonunique', 'dense', 'compressed-nonunique', 'singleton']\n", + "[sparse, compressed, sparse, sparse]\n", + "\n", + "['compressed-nonunique', 'dense', 'dense', 'compressed']\n", + "[sparse, compressed, compressed, sparse]\n", + "\n", + "['compressed-nonunique', 'singleton', 'dense', 'compressed']\n", + "[sparse, sparse, compressed, sparse]\n", + "\n", + "['compressed-nonunique', 'singleton', 'singleton', 'singleton']\n", + "[sparse, sparse, sparse, sparse]\n", + "\n", + "['dense', 'compressed', 'compressed', 'compressed']\n", + "[compressed, doubly_compressed, doubly_compressed, sparse]\n", + "\n", + "['dense', 'compressed', 'compressed-nonunique', 'singleton']\n", + "[compressed, doubly_compressed, sparse, sparse]\n", + "\n", + "['dense', 'compressed', 'dense', 'compressed']\n", + "[compressed, doubly_compressed, compressed, sparse]\n", + "\n", + "['dense', 'compressed', 'singleton', 'compressed']\n", + "[compressed, sparse, doubly_compressed, sparse]\n", + "\n", + "['dense', 'compressed-nonunique', 'dense', 'compressed']\n", + "[compressed, sparse, compressed, sparse]\n", + "\n", + "['dense', 'compressed-nonunique', 'singleton', 'singleton']\n", + "[compressed, sparse, sparse, sparse]\n", + "\n", + "['dense', 'dense', 'compressed', 'compressed']\n", + "[compressed, compressed, doubly_compressed, sparse]\n", + "\n", + "['dense', 'dense', 'compressed-nonunique', 'singleton']\n", + "[compressed, compressed, sparse, sparse]\n", + "\n", + "['dense', 'dense', 'dense', 'compressed']\n", + "[compressed, compressed, compressed, sparse]\n", + "\n" + ] + } + ], + "source": [ + "# Structure conversions from TACO to ours\n", + "for key in sorted(seen_taco):\n", + " print(list(key))\n", + " print(seen_taco[key])\n", + " print()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.6" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/sparsetensorviz/pyproject.toml b/sparsetensorviz/pyproject.toml new file mode 100644 index 0000000..90ccf9c --- /dev/null +++ b/sparsetensorviz/pyproject.toml @@ -0,0 +1,5 @@ +[build-system] +requires = ["setuptools", "wheel"] + +[tool.black] +line-length = 100 diff --git a/sparsetensorviz/requirements.txt b/sparsetensorviz/requirements.txt new file mode 100644 index 0000000..5da331c --- /dev/null +++ b/sparsetensorviz/requirements.txt @@ -0,0 +1,2 @@ +numpy +pandas diff --git a/sparsetensorviz/setup.cfg b/sparsetensorviz/setup.cfg new file mode 100644 index 0000000..ca80453 --- /dev/null +++ b/sparsetensorviz/setup.cfg @@ -0,0 +1,59 @@ +[aliases] +test=pytest + +[flake8] +max-line-length = 100 +inline-quotes = " +exclude = + versioneer.py, +ignore = + E203, + E231, + W503, + B020 +# E203: whitespace before ':' +# E231: Multiple spaces around "," +# W503: line break before binary operator +per-file-ignores = + __init__.py:F401 + +[isort] +sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER +profile = black +skip_gitignore = true +float_to_top = true +default_section = THIRDPARTY +known_first_party = sparsetensorviz +line_length = 100 + +[versioneer] +VCS = git +style = pep440 +versionfile_source = sparsetensorviz/_version.py +versionfile_build = sparsetensorviz/_version.py +tag_prefix= +parentdir_prefix=sparsetensorviz- + +[tool:pytest] +testpaths = sparsetensorviz/tests +markers: + slow: Skipped unless --runslow passed + +[coverage:run] +source = sparsetensorviz +omit = + sparsetensorviz/_version.py + +[coverage:report] +# Regexes for lines to exclude from consideration +exclude_lines = + pragma: no cover + + raise AssertionError + raise NotImplementedError + +ignore_errors = True +precision = 1 +fail_under = 0 +skip_covered = True +skip_empty = True diff --git a/sparsetensorviz/setup.py b/sparsetensorviz/setup.py new file mode 100644 index 0000000..3eece6e --- /dev/null +++ b/sparsetensorviz/setup.py @@ -0,0 +1,49 @@ +from setuptools import find_packages, setup + +import versioneer + +with open("requirements.txt") as f: + install_requires = f.read().strip().split("\n") + +extras_require = { + "test": ["pytest"], + "viz": ["sphinxcontrib-svgbob"], +} +extras_require["complete"] = sorted({v for req in extras_require.values() for v in req}) + +with open("README.md") as f: + long_description = f.read() + +setup( + name="sparsetensorviz", + version=versioneer.get_version(), + cmdclass=versioneer.get_cmdclass(), + description="Explore multidimensional sparse data structures", + long_description=long_description, + long_description_content_type="text/markdown", + author="Erik Welch", + author_email="erik.n.welch@gmail.com", + url="https://github.com/GraphBLAS/binsparse-specification", + packages=find_packages(), + license="BSD", + python_requires=">=3.8", + setup_requires=[], + install_requires=install_requires, + extras_require=extras_require, + include_package_data=True, + classifiers=[ + "Development Status :: 3 - Alpha" "License :: OSI Approved :: BSD License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3 :: Only", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "Topic :: Scientific/Engineering", + "Topic :: Scientific/Engineering :: Mathematics", + ], + zip_safe=False, +) diff --git a/sparsetensorviz/sparsetensorviz/__init__.py b/sparsetensorviz/sparsetensorviz/__init__.py new file mode 100644 index 0000000..641cb08 --- /dev/null +++ b/sparsetensorviz/sparsetensorviz/__init__.py @@ -0,0 +1,5 @@ +from . import _version +from ._core import SparseTensor +from .sparsetype import DC, C, S, compressed, doubly_compressed, sparse + +__version__ = _version.get_versions()["version"] diff --git a/sparsetensorviz/sparsetensorviz/_bundle.py b/sparsetensorviz/sparsetensorviz/_bundle.py new file mode 100644 index 0000000..dc1ffd3 --- /dev/null +++ b/sparsetensorviz/sparsetensorviz/_bundle.py @@ -0,0 +1,131 @@ +import re + +from ._core import SparseTensor + + +def num(match, name, tokenlength=2): + s = match.group(name) + if s is None: + return 0 + return len(s) // tokenlength + + +def trim(ma, s): + start, stop = ma.span(0) + assert start == 0 + return s[stop:] + + +class MatcherBase: + @classmethod + def match(cls, s): + return cls.pattern.match(s) + + +class AllFull(MatcherBase): + """F[-F]""" + + pattern = re.compile("^F(?P(-F)*)$") + + def __new__(cls, ma, s): + numF = num(ma, "F") + return [f"Full({numF + 1})"] + + +class AllCoord(MatcherBase): + """S[-S]""" + + pattern = re.compile("^(?P(S-)*)S$") + + def __new__(cls, ma, s): + numS = num(ma, "S") + return [f"Coord({numS + 1})"] + + +class InitSparse(MatcherBase): + """C-[C-]""" + + pattern = re.compile("^(?P(C-)+)") + + def __new__(cls, ma, s): + numC = num(ma, "C") + return [f"Sparse({numC})"] + + +class CoordSparse(MatcherBase): + """[S-]DC-C-[C-]""" + + pattern = re.compile("^(?P(S-)*)DC-(?P(C-)+)") + + def __new__(cls, ma, s): + numS = num(ma, "S") + numC = num(ma, "C") + return [f"Coord({numS + 1})", f"Sparse({numC})"] + + +class CoordSparseExpanded(MatcherBase): + """[S-]S-C-[C-]""" + + pattern = re.compile("^(?P(S-)+)(?P(C-)+)") + + def __new__(cls, ma, s): + numS = num(ma, "S") + numC = num(ma, "C") + return [f"Coord({numS}, expanded=1)", f"Sparse({numC})"] + + +class HyperSparse(MatcherBase): + """[S-]DC-""" + + pattern = re.compile("^(?P(S-)*)DC-") + + def __new__(cls, ma, s): + numS = num(ma, "S") + return [f"HyperSparse({numS + 1})"] + + +class CoordFull(MatcherBase): + """[S-]S-F[-F]""" + + pattern = re.compile("^(?P(S-)+)F(?P(-F)*)$") + + def __new__(cls, ma, s): + numS = num(ma, "S") + numF = num(ma, "F") + return [f"Coord({numS})", f"Full({numF + 1})"] + + +def to_bundled_groups(s): + if isinstance(s, SparseTensor): + s = s.abbreviation + elif not isinstance(s, str): + raise TypeError( + f"s argument to to_bundled_groups should be str or SparseTnesor; got {type(s)}" + ) + if "-" not in s: + s = "-".join(s) + orig_s = s + if ma := AllFull.match(s): # All F + return AllFull(ma, s) + if ma := AllCoord.match(s): # All S + return AllCoord(ma, s) + rv = [] + if ma := InitSparse.match(s): # Begins with C + rv.extend(InitSparse(ma, s)) + s = trim(ma, s) + matchers = [ + CoordSparse, # [S-]DC-C-[C-] + CoordSparseExpanded, # [S-]S-C-[C-] + HyperSparse, # [S-]DC- + AllCoord, # [S-]S + CoordFull, # [S-]S-F[-F] + ] + while s: + for matcher in matchers: + if ma := matcher.match(s): + rv.extend(matcher(ma, s)) + s = trim(ma, s) + break + else: # pragma: no cover + raise ValueError(f"Invalid structure {orig_s!r}; unable to handle {s!r}") + return rv diff --git a/sparsetensorviz/sparsetensorviz/_core.py b/sparsetensorviz/sparsetensorviz/_core.py new file mode 100644 index 0000000..68d91fd --- /dev/null +++ b/sparsetensorviz/sparsetensorviz/_core.py @@ -0,0 +1,423 @@ +import numpy as np +import pandas as pd + +from .sparsetype import DC, C, S, abbreviate +from .sparsetype import from_taco as _from_taco +from .sparsetype import to_taco as _to_taco +from .sparsetype import unabbreviate + + +def repeatrange(repeat, *args): + """e.g., [0, 1, 2, 0, 1, 2]""" + return np.repeat(np.arange(*args)[None, :], repeat, axis=0).ravel() + + +def issorted(array): + return np.all(array[:-1] <= array[1:]) + + +class SparseTensor: + @classmethod + def from_taco(cls, arrays, shape=None, structure=None, *, group_indices=False): + if structure is not None: + structure = _from_taco(structure) + return cls(arrays, shape=shape, structure=structure, group_indices=group_indices) + + def __init__(self, arrays, shape=None, structure=None, *, group_indices=False): + self.group_indices = group_indices + if not isinstance(arrays, (list, tuple)): + raise TypeError("arrays argument must be a list or tuple of numpy arrays") + if not arrays: + raise ValueError("At least one array must be given") + arrays = [np.array(array) for array in arrays] + if not all(array.ndim == 1 for array in arrays): + raise ValueError("arrays must be a single dimension") + size = arrays[0].size + if not all(array.size == size for array in arrays): + raise ValueError("arrays must be the same size") + if not all(np.issubdtype(array.dtype, np.integer) for array in arrays): + raise ValueError("arrays must be integer dtype") + if not all((array >= 0).all() for array in arrays): + raise ValueError("array values must be positive") + + if shape is not None: + self._shape = tuple(shape) + if not all(dimsize > 0 for dimsize in self._shape): + raise ValueError("Dimension sizes must be greater than 0") + if len(self._shape) != len(arrays): + raise ValueError("shape must be the same length as arrays") + if not all((array < dimsize).all() for array, dimsize in zip(arrays, self._shape)): + raise ValueError("index in array is out of bounds") + else: + self._shape = tuple(int(array.max()) + 1 for array in arrays) + shape = self._shape + + if structure is None: # Assume CSF + self._structure = [DC] * (len(arrays) - 1) + [S] + elif isinstance(structure, str): + self._structure = unabbreviate(structure) + else: + self._structure = unabbreviate(abbreviate(*structure)) + if len(self._structure) != len(arrays): + raise ValueError("structure must be the same length as arrays") + if self._structure[-1] != S: + # C as the final dimension means "dense" + raise ValueError("The final dimension must be sparse structural type") + + # Now the fun part! Generate the compressed structure from COO + df = pd.DataFrame(arrays).T.sort_values(list(range(self.ndim))) + if df.duplicated().any(): + raise ValueError("Duplicate indices found!") + + # First create indices + indices = [] + cols = list(df.columns) + num_s_levels = 0 + prev = None + for sparsity, level in zip(self._structure, range(df.shape[-1])): + if sparsity == S: + num_s_levels += 1 + elif sparsity == DC: + subdf = df[cols[: level + 1]].drop_duplicates() + for i in range(-num_s_levels - 1, 0): + indices.append(subdf.iloc[:, i].values) + num_s_levels = 0 + elif sparsity == C: + if level == 0: + indices.append(np.arange(shape[level])) + elif prev == DC: + subdf = df[cols[:level]].drop_duplicates() + indices.append(repeatrange(len(subdf), shape[level])) + elif prev == S: + subdf = df[cols[:level]].drop_duplicates() + subdf = subdf.join( + pd.DataFrame({cols[level]: range(shape[level])}), how="cross" + ) + for i in range(-num_s_levels - 1, 0): + indices.append(subdf.iloc[:, i].values) + num_s_levels = 0 + else: # prev == C + indices.append(repeatrange(indices[-1].size, shape[level])) + prev = sparsity + for i in range(-num_s_levels, 0): + indices.append(df.iloc[:, i].values) + self._indices = indices + + # Now create pointers + pointers = [] + for sparsity, level in zip(self._structure[:-1], range(df.shape[-1] - 1)): + if sparsity == S: + ptr = np.arange(indices[level].size + 1) + elif self._structure[level + 1] == C: + ptr = np.arange(len(indices[level]) + 1) * shape[level + 1] + if sparsity == C: + # Update subdf to use later + if level == 0: + subdf = pd.DataFrame({cols[level]: range(shape[level])}) + elif self._structure[level - 1] == C: + subdf = subdf.join( + pd.DataFrame({cols[level]: range(shape[level])}), how="cross" + ) + else: + subdf = df[cols[:level]].drop_duplicates() + subdf = subdf.join( + pd.DataFrame({cols[level]: range(shape[level])}), how="cross" + ) + elif sparsity == DC: + if self._structure[level + 1] == DC: + subdf = df[cols[: level + 2]].drop_duplicates() + else: # sparsity[level + 1] == S + # number of "S" immediately after this level + nums = 0 + for item in self._structure[level + 1 :]: + if item == S: + nums += 1 + else: + break + subdf = df[cols[: level + nums + 1]].drop_duplicates() + if len(self._structure) > level + nums + 1: + if self._structure[level + nums + 1] == C: + subdf = subdf.join( + pd.DataFrame( + {cols[level + nums + 1]: range(shape[level + nums + 1])} + ), + how="cross", + ) + elif self._structure[level + nums + 1] == DC: + subdf = df[cols[: level + nums + 2]].drop_duplicates() + ptr = np.zeros(indices[level].size + 1, int) + ptr[1:] = subdf.groupby(cols[: level + 1])[cols[level + 1]].count().cumsum() + elif sparsity == C: + if level > 0: + if self._structure[level - 1] == C: + subdf1 = subdf + else: + subdf1 = df[cols[:level]].drop_duplicates() + subdf = pd.DataFrame({cols[level]: range(shape[level])}) + if level > 0: + subdf = subdf1.join(subdf, how="cross") + if self._structure[level + 1] == DC: + subdf2 = df[cols[: level + 2]].drop_duplicates() + else: # sparsity[level + 1] == S + # number of "S" immediately after this level + nums = 0 + for item in self._structure[level + 1 :]: + if item == S: + nums += 1 + else: + break + subdf2 = df[cols[: level + nums + 1]].drop_duplicates() + if len(self._structure) > level + nums + 1: + if self._structure[level + nums + 1] == C: + subdf2 = subdf2.join( + pd.DataFrame( + {cols[level + nums + 1]: range(shape[level + nums + 1])} + ), + how="cross", + ) + elif self._structure[level + nums + 1] == DC: + subdf2 = df[cols[: level + nums + 2]].drop_duplicates() + subdf3 = subdf.merge(subdf2, how="left") + subdf3[level + 1] = subdf3[level + 1].notnull() + ptr = np.zeros(indices[level].size + 1, int) + ptr[1:] = subdf3.groupby(cols[: level + 1])[level + 1].sum().cumsum() + pointers.append(ptr) + self._pointers = pointers + # TODO: can we detect and change sparsity type to be more efficient? + # For example, so we don't need to store a pointers or indices. + + def _validate(self): + indices = self._indices + pointers = self._pointers + structure = self._structure + ndim = self.ndim + shape = self.shape + assert len(indices) == len(pointers) + 1 == ndim + for idx in indices: + assert idx.dtype == int + for ptr in pointers: + assert ptr.dtype == int + for idx, ptr in zip(indices[:-1], pointers): + assert len(ptr) == len(idx) + 1 + for idx, ptr in zip(indices[1:], pointers): + assert ptr[0] == 0 + assert ptr[-1] == len(idx) + for ptr in pointers: + assert issorted(ptr) + assert issorted(indices[0]) + assert indices[0][0] >= 0 + assert indices[0][-1] < shape[0] + for i, (idx, ptr) in enumerate(zip(indices[1:], pointers), 1): + for start, stop in zip(ptr[:-1], ptr[1:]): + assert issorted(idx[start:stop]) + if start < stop: + assert idx[start] >= 0 + assert idx[stop - 1] < shape[i] + assert structure[-1] == S + for i, (sparsity, idx, ptr) in enumerate(zip(structure[:-1], indices, pointers[:-1])): + if sparsity == C: + if i == 0: + assert len(idx) == shape[0] + elif structure[i - 1] != S: + assert len(idx) == len(self._indices[i - 1]) * shape[i] + elif sparsity == S: + assert len(idx) == len(indices[i + 1]) + elif sparsity == DC: + if i == 0: + assert len(idx) == len(set(idx)) + assert len(ptr) == len(set(ptr)) + else: # pragma: no cover + raise AssertionError() + assert _from_taco(self.taco_structure) == structure + # self.taco_view + + def as_structure(self, structure, *, group_indices=None): + if group_indices is None: + group_indices = self.group_indices + return SparseTensor(self.arrays, self.shape, structure, group_indices=group_indices) + + def get_index(self, dim): + # Let's demonstrate how to compute indices that don't need to be stored + dim = range(self.ndim)[dim] # Make dim positive + if self._structure[dim] == C: + size = 1 + for cur in reversed(range(dim)): + if self._structure[cur] == C: + size *= self._shape[cur] + else: + size *= len(self._indices[cur]) + if self._structure[cur] == S: + size //= self._shape[cur + 1] + break + return repeatrange(size, self._shape[dim]) + else: + return self._indices[dim] + + def get_pointers(self, dim): + # Let's demonstrate how to compute pointers that don't need to be stored + dim = range(self.ndim)[dim] # Make dim positive + if self._structure[dim] == S: + return np.arange(len(self._indices[dim]) + 1) + elif self._structure[dim + 1] == C: + if self._structure[dim] == DC: + size = len(self._indices[dim]) + else: + size = self._shape[dim] + for cur in reversed(range(dim)): + if self._structure[cur] == C: + size *= self._shape[cur] + else: + size *= len(self._indices[cur]) + if self._structure[cur] == S: + size //= self._shape[cur + 1] + break + return np.arange(size + 1) * self._shape[dim + 1] + else: + return self._pointers[dim] + + @property + def indices(self): + rv = list(self._indices) + for i, sparsity in enumerate(self._structure): + if sparsity == C: + rv[i] = None + return rv + + @property + def pointers(self): + rv = list(self._pointers) + for i, sparsity in enumerate(self._structure[:-1]): + if sparsity == S: + rv[i] = None + elif sparsity == C and i > 0: + rv[i - 1] = None + return rv + + @property + def ndim(self): + return len(self._shape) + + @property + def shape(self): + return self._shape + + @property + def structure(self): + return self._structure + + @property + def abbreviation(self): + return abbreviate(self._structure) + + @property + def arrays(self): + return [np.array(array) for array in zip(*_to_coo(self._indices, self._pointers))] + + @property + def taco_structure(self): + return _to_taco(self._structure) + + @property + def taco_view(self): + return TacoView(self) + + @property + def bundled_groups(self): + from ._bundle import to_bundled_groups + + return to_bundled_groups(self) + + def _repr_svg_(self, *, as_taco=False, as_groups=None): + try: + from ._formatting import to_svg + except ImportError: + return + if as_groups is None: + as_groups = self.group_indices + return to_svg(self, as_taco=as_taco, as_groups=as_groups) + + def __repr__(self, *, as_taco=False, as_groups=None): + from ._formatting import to_text + + if as_groups is None: + as_groups = self.group_indices + return to_text(self, as_taco=as_taco, as_groups=as_groups) + + +class TacoView: + def __init__(self, parent): + self._parent = parent + self._fake = object.__new__(SparseTensor) + self._fake.group_indices = self._parent.group_indices + self._fake._structure = [DC] + parent._structure + self._fake._shape = (1,) + parent._shape + self._fake._indices = [np.array([0])] + self._parent._indices + self._fake._pointers = [ + np.array([0, self._parent._indices[0].size]) + ] + self._parent._pointers + # assert self._parent.taco_structure == self._fake.taco_structure[1:] + + def get_index(self, dim): + return self._parent.get_index(dim) + + def get_pointers(self, dim): + dim = range(self.ndim)[dim] # Make dim positive + return self._fake.get_pointers(dim) + + @property + def group_indices(self): + return self._parent.group_indices + + @property + def indices(self): + return self._parent.indices + + @property + def pointers(self): + return self._fake.pointers + + @property + def ndim(self): + return self._parent.ndim + + @property + def shape(self): + return self._parent.shape + + @property + def structure(self): + return self._parent.taco_structure + + @property + def abbreviation(self): + abbv = { + "compressed": "C", + "dense": "D", + "singleton": "S", + "compressed-nonunique": "CN", + } + return "-".join(abbv[x] for x in self.structure) + + @property + def arrays(self): + return self._parent.arrays + + def _repr_svg_(self): + return self._fake._repr_svg_(as_taco=True) + + def __repr__(self): + return self._fake.__repr__(as_taco=True) + + +def _to_coo(indices, pointers, start=0, stop=None): + index, *indices = indices + if stop is None: + stop = len(index) + if not indices: + for idx in index[start:stop]: + yield (idx,) + return + ptrs, *pointers = pointers + for idx, start, stop in zip(index[start:stop], ptrs[start:stop], ptrs[start + 1 : stop + 1]): + for indexes in _to_coo(indices, pointers, start, stop): + yield (idx,) + indexes diff --git a/sparsetensorviz/sparsetensorviz/_formatting.py b/sparsetensorviz/sparsetensorviz/_formatting.py new file mode 100644 index 0000000..9dc4fa6 --- /dev/null +++ b/sparsetensorviz/sparsetensorviz/_formatting.py @@ -0,0 +1,396 @@ +import itertools + +import numpy as np + +concat = itertools.chain.from_iterable + +TACO_ABBV = { + "compressed": "C", + "dense": "D", + "singleton": "S", + "compressed-nonunique": "CN", +} + + +def _to_level(indices, pointers, level=0, start=0, stop=None): + index, *indices = indices + if stop is None: + stop = len(index) + if not indices: + for _ in range(start, stop): + yield level + level += 1 + return + ptrs, *pointers = pointers + for start, stop in zip(ptrs[start:stop], ptrs[start + 1 : stop + 1]): + levels = list(_to_level(indices, pointers, level, start, stop)) + yield [level, levels] + maxlevel = level + while levels: + vals = [val for val in levels if not isinstance(val, list)] + if vals: + maxlevel = max(maxlevel, max(vals)) + levels = list(concat(val for val in levels if isinstance(val, list))) + level = maxlevel + 1 + + +def index_levels(self): + levels = list(_to_level(self._indices, self._pointers)) + if self.ndim == 1: + return [levels] + rv = [] + rv.append([x for x, _ in levels]) + for _ in range(len(self._pointers) - 1): + levels = list(concat(y for _, y in levels)) + rv.append([x for x, _ in levels]) + rv.append(list(concat(y for _, y in levels))) + return rv + + +def _to_group(indices, pointers, group=None, start=0, stop=None, *, compact=None): + if compact is None: + compact = True + index, *indices = indices + if stop is None: + stop = len(index) + if not indices: + for i in range(start, stop): + if group is None: + yield i + else: + yield group + return + if index.size == 0: # Can this happen? + return + ptrs, *pointers = pointers + i = 0 + prev_idx = index[0] + for idx, start, stop in zip(index, ptrs[start:stop], ptrs[start + 1 : stop + 1]): + if group is not None: + cur_group = group + elif not compact: + cur_group = i + i += 1 + elif idx != prev_idx: + i += 1 + cur_group = i + prev_idx = idx + else: + cur_group = i + groups = list(_to_group(indices, pointers, cur_group, start, stop)) + yield [cur_group, groups] + + +def index_groups(self, *, compact=None): + if compact is None: + compact = True + groups = list(_to_group(self._indices, self._pointers, compact=compact)) + if self.ndim == 1: + return [groups] + rv = [] + rv.append([x for x, _ in groups]) + for _ in range(len(self._pointers) - 1): + groups = list(concat(y for _, y in groups)) + rv.append([x for x, _ in groups]) + rv.append(list(concat(y for _, y in groups))) + return rv + + +def get_layout(self, *, squared=False, compact=None): + indices = self._indices + pointers = self._pointers + + # Xs is easy + index_widths = [2 + max(2, len(str(index.max()))) for index in indices] + pointers_widths = [max(4, len(str(ptr.max()))) for ptr in pointers] + index_widths = [2 + max(2, len(str(index.max()))) for index in indices] + pointers_widths = [max(4, len(str(ptr.max()))) for ptr in pointers] + widths = [0] + for ws in zip(index_widths[:-1], pointers_widths): + widths.extend(ws) + xoffsets = np.cumsum(widths) + + # Now we need to determins Ys. Get initial guesses. + groups = index_groups(self, compact=compact) + if self.ndim > 1: + yoffsets = [list(np.arange(len(index)) * 3) for index in indices[:-2]] + last_in_group = np.diff(np.pad(groups[-1], (0, 1)))[ + [min(x, len(groups[-1]) - 1) for x in pointers[-1][:-2]] + ].astype(bool) + diffed = np.diff(pointers[-1]) + yoffsets.append( + np.pad( + (np.maximum(2, diffed[:-1] + last_in_group) + 1 + squared).cumsum(), (1, 0) + ).tolist() + ) + + # I think compact here only affects 2d layouts + if compact: + final_offsets = list(range(len(indices[-1]))) # defer to previous constraints + else: + final_offsets = [] + it = zip(groups[-1], indices[-1]) + cur = 0 + prev_group = 0 + for count in diffed: + for _ in range(count): + group, index = next(it) + if group != prev_group: + cur += 1 + prev_group = group + final_offsets.append(cur) + cur += 1 + cur += 1 + yoffsets.append(final_offsets) + else: + yoffsets = [list(range(len(indices[-1])))] + + # Now update by matching level ys + levels = index_levels(self) + inplay = set(zip(concat(levels), concat(yoffsets))) + for level in sorted({x for x, _ in inplay}): + heights = sorted({y for x, y in inplay if x == level}) + if len(heights) == 1: + continue + max_height = max(heights) + new_yoffsets = [] + for ys, cur_levels in zip(yoffsets, levels): + if level not in cur_levels or ys[cur_levels.index(level)] == max_height: + new_yoffsets.append(ys) + continue + diff = max_height - ys[cur_levels.index(level)] + new_yoffsets.append([y if lvl < level else y + diff for y, lvl in zip(ys, cur_levels)]) + yoffsets = new_yoffsets + inplay = set(zip(concat(levels), concat(yoffsets))) + + return index_widths, pointers_widths, xoffsets, yoffsets + + +def autoexpand(func): + """Make the canvas larger if there is an IndexError""" + + def inner(canvas, *args, **kwargs): + for _ in range(1000): + try: + return func(canvas, *args, **kwargs) + except IndexError: + for row in canvas: + row.append(" ") + canvas.append([" "] * len(canvas[0])) + + return inner + + +@autoexpand +def draw_box(canvas, x, y, width, val, *, dashed=False, square=False, cap_right=False): + h = "~" if dashed else "-" + v = "┊" if dashed else "|" + canvas[y][x] = "+" if square else "." + canvas[y + 1][x] = v + canvas[y + 2][x] = "+" if square else "`" + canvas[y][x + width - 1] = "+" if square else "." + canvas[y + 1][x + width - 1] = v + canvas[y + 2][x + width - 1] = "+" if square else "'" + for w in range(1, width - 1): + canvas[y][x + w] = h + canvas[y + 2][x + w] = h + sval = str(val).center(width - 2) + for c, w in zip(sval, range(1, width - 1)): + canvas[y + 1][x + w] = c + if cap_right: + canvas[y + 1][x + width] = ")" + + +@autoexpand +def draw_final_boxes(canvas, x, ys, width, index, *, square=False): + prev_y = -999 + for y, idx in zip(ys, index): + if y - prev_y > 2: + canvas[y][x] = "+" if square else "." + for w in range(1, width - 1): + canvas[y][x + w] = "-" + canvas[y][x + width - 1] = "+" if square else "." + # Close previous box + if prev_y >= 0: + canvas[prev_y + 2][x] = "+" if square else "`" + for w in range(1, width - 1): + canvas[prev_y + 2][x + w] = "-" + canvas[prev_y + 2][x + width - 1] = "+" if square else "'" + elif y - prev_y == 2: + # Connected, but separate by horizontal line + canvas[y][x] = "|" + for w in range(1, width - 1): + canvas[y][x + w] = "-" + canvas[y][x + width - 1] = "|" + canvas[y + 1][x] = "|" + sval = str(idx).center(width - 2) + for c, w in zip(sval, range(1, width - 1)): + canvas[y + 1][x + w] = c + canvas[y + 1][x + width - 1] = "|" + prev_y = y + # Close last box + canvas[prev_y + 2][x] = "+" if square else "`" + for w in range(1, width - 1): + canvas[prev_y + 2][x + w] = "-" + canvas[prev_y + 2][x + width - 1] = "+" if square else "'" + + +@autoexpand +def draw_line(canvas, x, y, w, *, dashed=False, double=False, chain=False): + c = "~" if dashed else "-" + if double: + c = "=" + for i in range(w): + if dashed and double and i % 2: + continue + if chain: + c = "=" if i % 2 else "-" + canvas[y][x + i] = c + + +@autoexpand +def draw_bendy_line(canvas, x, y1, y2, w, *, dashed=False, squared=False): + h = "~" if dashed else "-" + v = "┊" if dashed else "|" + for i in range(w - 2, w): + canvas[y2][x + i] = h + for i in range(y1 + 1, y2): + canvas[i][x + w - 3] = v + canvas[y1][x + w - 3] = "+" + canvas[y2][x + w - 3] = "+" if squared else "`" + + +@autoexpand +def draw_pointer(canvas, x, y, w, ptr, *, center_right=False, skip_if_nonempty=False): + if center_right and w % 2 != len(str(ptr)) % 2: + sptr = str(ptr).center(w + 1)[:-1] + else: + sptr = str(ptr).center(w) + if skip_if_nonempty: + for i in range(len(sptr)): + if canvas[y][x + i] != " ": + return + for i, c in enumerate(sptr): + canvas[y][x + i] = c + + +def to_text(self, *, squared=False, compact=None, as_taco=False, as_groups=False): + indices = self._indices + pointers = self._pointers + index_widths, pointers_widths, xoffsets, yoffsets = get_layout( + self, squared=squared, compact=compact + ) + # Doesn't need to be perfect: we'll expand the canvas as needed + xmax = max(xoffsets) + 1 + ymax = max(concat(yoffsets)) + 1 + canvas = [[" "] * xmax for _ in range(ymax)] + # Draw boxes of indices + for i, (width, x, ys, index, ptrs) in enumerate( + zip(index_widths[:-1], xoffsets[::2], yoffsets, indices[:-1], pointers) + ): + dashed = self.indices[i] is None + for y, idx, start, stop in zip(ys, index, ptrs[:-1], ptrs[1:]): + cap_right = start == stop + draw_box(canvas, x, y, width, idx, dashed=dashed, square=squared, cap_right=cap_right) + draw_final_boxes( + canvas, xoffsets[-1], yoffsets[-1], index_widths[-1], indices[-1], square=squared + ) + + # Draw lines for pointers + for i, (x, w) in enumerate(zip(xoffsets[1::2], pointers_widths)): + dashed = self.pointers[i] is None + prev_start = 0 + for j, (yinit, start, stop) in enumerate( + zip(yoffsets[i], pointers[i][:-1], pointers[i][1:]) + ): + if j == 0 or prev_start == start: + draw_pointer(canvas, x, yinit, w, start, center_right=True, skip_if_nonempty=True) + for y in yoffsets[i + 1][start:stop]: + if y == yinit: + draw_line(canvas, x, y + 1, w, dashed=dashed) + else: + draw_bendy_line(canvas, x, yinit + 1, y + 1, w, dashed=dashed, squared=squared) + draw_pointer(canvas, x, y + 2, w, stop, center_right=True) + prev_start = start + if start == stop: + draw_pointer( + canvas, + xoffsets[2 * i + 1], + yoffsets[i][-1] + 2, + w, + start, + center_right=True, + skip_if_nonempty=True, + ) + + # Draw header + header = [[" "] * xmax for _ in range(4)] + for i, (x, w, index) in enumerate(zip(xoffsets[::2], index_widths, self.indices)): + if as_taco: + if i == 0: + continue + i -= 1 + draw_box(header, x, 0, w + 1, f"i{i} ", square=squared, dashed=index is None) + for i, (x, w) in enumerate(zip(xoffsets[1::2], pointers_widths)): + draw_pointer(header, x + 1, 1, w - 2, f"p{i}", center_right=False) + draw_line(header, 0, 3, len("".join(header[0]).rstrip()), double=True) + + # Very top: group columns together and display dimension type + w = "".join(header[1]).rindex("|") + top = ["-"] * (w + 1) + top[w] = "|" + structure = self.taco_structure[1:] if as_taco else self._structure + for sparsity, x in zip(structure, xoffsets[1 if as_taco else 0 :: 2]): + if as_taco: + abbv = TACO_ABBV[sparsity] + else: + abbv = sparsity.abbreviation + top[x] = "|" + x += 1 + for c in abbv: + top[x] = c + x += 1 + top[x] = " " + top = ["".join(top)] + + # Strip extra white space + hrows = ["".join(row).rstrip() for row in header] + while hrows and not hrows[-1]: + hrows.pop() + rows = ["".join(row).rstrip() for row in canvas] + while rows and not rows[-1]: + rows.pop() + combined = top + hrows + rows + if as_taco: + combined = [row[xoffsets[1] :] for row in combined] + elif as_groups: + nums = [int(gp[:-1].split("(", 1)[1].split(",", 1)[0]) for gp in self.bundled_groups] + trim_ranges = [] + i = 0 + for num in nums: + for j in range(i, i + num - 1): + trim_ranges.append((xoffsets[2 * j + 1] - 1, xoffsets[2 * j + 2] + 1)) + i += num + + def trim(row, start, stop): + first = row[:start] + last = row[stop:] + if first[-1] == "-" == last[0]: + middle = "-" + elif first[-1] == "=" == last[0]: + middle = "=" + else: + middle = " " + return first + middle + last + + for start, stop in reversed(trim_ranges): + combined = [trim(row, start, stop) for row in combined] + + return "\n".join(combined) + + +def to_svg(self, *, squared=False, compact=None, as_taco=False, as_groups=False): + from sphinxcontrib.svgbob._svgbob import to_svg as _to_svg + + text = to_text(self, squared=squared, compact=compact, as_taco=as_taco, as_groups=as_groups) + return _to_svg(text) diff --git a/sparsetensorviz/sparsetensorviz/_version.py b/sparsetensorviz/sparsetensorviz/_version.py new file mode 100644 index 0000000..b47e5cd --- /dev/null +++ b/sparsetensorviz/sparsetensorviz/_version.py @@ -0,0 +1,689 @@ +# This file helps to compute a version number in source trees obtained from +# git-archive tarball (such as those provided by githubs download-from-tag +# feature). Distribution tarballs (built by setup.py sdist) and build +# directories (produced by setup.py build) will contain a much shorter file +# that just contains the computed version number. + +# This file is released into the public domain. Generated by +# versioneer-0.23 (https://github.com/python-versioneer/python-versioneer) + +"""Git implementation of _version.py.""" + +import errno +import functools +import os +import re +import subprocess +import sys +from typing import Callable, Dict + + +def get_keywords(): + """Get the keywords needed to look up the version information.""" + # these strings will be replaced by git during git-archive. + # setup.py/versioneer.py will grep for the variable names, so they must + # each be defined on a line of their own. _version.py will just call + # get_keywords(). + git_refnames = "$Format:%d$" + git_full = "$Format:%H$" + git_date = "$Format:%ci$" + keywords = {"refnames": git_refnames, "full": git_full, "date": git_date} + return keywords + + +class VersioneerConfig: + """Container for Versioneer configuration parameters.""" + + +def get_config(): + """Create, populate and return the VersioneerConfig() object.""" + # these strings are filled in when 'setup.py versioneer' creates + # _version.py + cfg = VersioneerConfig() + cfg.VCS = "git" + cfg.style = "pep440" + cfg.tag_prefix = "" + cfg.parentdir_prefix = "spz-" + cfg.versionfile_source = "spz/_version.py" + cfg.verbose = False + return cfg + + +class NotThisMethod(Exception): + """Exception raised if a method is not valid for the current scenario.""" + + +LONG_VERSION_PY: Dict[str, str] = {} +HANDLERS: Dict[str, Dict[str, Callable]] = {} + + +def register_vcs_handler(vcs, method): # decorator + """Create decorator to mark a method as the handler of a VCS.""" + + def decorate(f): + """Store f in HANDLERS[vcs][method].""" + if vcs not in HANDLERS: + HANDLERS[vcs] = {} + HANDLERS[vcs][method] = f + return f + + return decorate + + +def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False, env=None): + """Call the given command(s).""" + assert isinstance(commands, list) + process = None + + popen_kwargs = {} + if sys.platform == "win32": + # This hides the console window if pythonw.exe is used + startupinfo = subprocess.STARTUPINFO() + startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW + popen_kwargs["startupinfo"] = startupinfo + + for command in commands: + try: + dispcmd = str([command] + args) + # remember shell=False, so use git.cmd on windows, not just git + process = subprocess.Popen( + [command] + args, + cwd=cwd, + env=env, + stdout=subprocess.PIPE, + stderr=(subprocess.PIPE if hide_stderr else None), + **popen_kwargs, + ) + break + except OSError: + e = sys.exc_info()[1] + if e.errno == errno.ENOENT: + continue + if verbose: + print("unable to run %s" % dispcmd) + print(e) + return None, None + else: + if verbose: + print("unable to find command, tried %s" % (commands,)) + return None, None + stdout = process.communicate()[0].strip().decode() + if process.returncode != 0: + if verbose: + print("unable to run %s (error)" % dispcmd) + print("stdout was %s" % stdout) + return None, process.returncode + return stdout, process.returncode + + +def versions_from_parentdir(parentdir_prefix, root, verbose): + """Try to determine the version from the parent directory name. + + Source tarballs conventionally unpack into a directory that includes both + the project name and a version string. We will also support searching up + two directory levels for an appropriately named parent directory + """ + rootdirs = [] + + for _ in range(3): + dirname = os.path.basename(root) + if dirname.startswith(parentdir_prefix): + return { + "version": dirname[len(parentdir_prefix) :], + "full-revisionid": None, + "dirty": False, + "error": None, + "date": None, + } + rootdirs.append(root) + root = os.path.dirname(root) # up a level + + if verbose: + print( + "Tried directories %s but none started with prefix %s" + % (str(rootdirs), parentdir_prefix) + ) + raise NotThisMethod("rootdir doesn't start with parentdir_prefix") + + +@register_vcs_handler("git", "get_keywords") +def git_get_keywords(versionfile_abs): + """Extract version information from the given file.""" + # the code embedded in _version.py can just fetch the value of these + # keywords. When used from setup.py, we don't want to import _version.py, + # so we do it with a regexp instead. This function is not used from + # _version.py. + keywords = {} + try: + with open(versionfile_abs, "r") as fobj: + for line in fobj: + if line.strip().startswith("git_refnames ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["refnames"] = mo.group(1) + if line.strip().startswith("git_full ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["full"] = mo.group(1) + if line.strip().startswith("git_date ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["date"] = mo.group(1) + except OSError: + pass + return keywords + + +@register_vcs_handler("git", "keywords") +def git_versions_from_keywords(keywords, tag_prefix, verbose): + """Get version information from git keywords.""" + if "refnames" not in keywords: + raise NotThisMethod("Short version file found") + date = keywords.get("date") + if date is not None: + # Use only the last line. Previous lines may contain GPG signature + # information. + date = date.splitlines()[-1] + + # git-2.2.0 added "%cI", which expands to an ISO-8601 -compliant + # datestamp. However we prefer "%ci" (which expands to an "ISO-8601 + # -like" string, which we must then edit to make compliant), because + # it's been around since git-1.5.3, and it's too difficult to + # discover which version we're using, or to work around using an + # older one. + date = date.strip().replace(" ", "T", 1).replace(" ", "", 1) + refnames = keywords["refnames"].strip() + if refnames.startswith("$Format"): + if verbose: + print("keywords are unexpanded, not using") + raise NotThisMethod("unexpanded keywords, not a git-archive tarball") + refs = {r.strip() for r in refnames.strip("()").split(",")} + # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of + # just "foo-1.0". If we see a "tag: " prefix, prefer those. + TAG = "tag: " + tags = {r[len(TAG) :] for r in refs if r.startswith(TAG)} + if not tags: + # Either we're using git < 1.8.3, or there really are no tags. We use + # a heuristic: assume all version tags have a digit. The old git %d + # expansion behaves like git log --decorate=short and strips out the + # refs/heads/ and refs/tags/ prefixes that would let us distinguish + # between branches and tags. By ignoring refnames without digits, we + # filter out many common branch names like "release" and + # "stabilization", as well as "HEAD" and "master". + tags = {r for r in refs if re.search(r"\d", r)} + if verbose: + print("discarding '%s', no digits" % ",".join(refs - tags)) + if verbose: + print("likely tags: %s" % ",".join(sorted(tags))) + for ref in sorted(tags): + # sorting will prefer e.g. "2.0" over "2.0rc1" + if ref.startswith(tag_prefix): + r = ref[len(tag_prefix) :] + # Filter out refs that exactly match prefix or that don't start + # with a number once the prefix is stripped (mostly a concern + # when prefix is '') + if not re.match(r"\d", r): + continue + if verbose: + print("picking %s" % r) + return { + "version": r, + "full-revisionid": keywords["full"].strip(), + "dirty": False, + "error": None, + "date": date, + } + # no suitable tags, so version is "0+unknown", but full hex is still there + if verbose: + print("no suitable tags, using unknown + full revision id") + return { + "version": "0+unknown", + "full-revisionid": keywords["full"].strip(), + "dirty": False, + "error": "no suitable tags", + "date": None, + } + + +@register_vcs_handler("git", "pieces_from_vcs") +def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command): + """Get version from 'git describe' in the root of the source tree. + + This only gets called if the git-archive 'subst' keywords were *not* + expanded, and _version.py hasn't already been rewritten with a short + version string, meaning we're inside a checked out source tree. + """ + GITS = ["git"] + if sys.platform == "win32": + GITS = ["git.cmd", "git.exe"] + + # GIT_DIR can interfere with correct operation of Versioneer. + # It may be intended to be passed to the Versioneer-versioned project, + # but that should not change where we get our version from. + env = os.environ.copy() + env.pop("GIT_DIR", None) + runner = functools.partial(runner, env=env) + + _, rc = runner(GITS, ["rev-parse", "--git-dir"], cwd=root, hide_stderr=True) + if rc != 0: + if verbose: + print("Directory %s not under git control" % root) + raise NotThisMethod("'git rev-parse --git-dir' returned error") + + # if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty] + # if there isn't one, this yields HEX[-dirty] (no NUM) + describe_out, rc = runner( + GITS, + [ + "describe", + "--tags", + "--dirty", + "--always", + "--long", + "--match", + f"{tag_prefix}[[:digit:]]*", + ], + cwd=root, + ) + # --long was added in git-1.5.5 + if describe_out is None: + raise NotThisMethod("'git describe' failed") + describe_out = describe_out.strip() + full_out, rc = runner(GITS, ["rev-parse", "HEAD"], cwd=root) + if full_out is None: + raise NotThisMethod("'git rev-parse' failed") + full_out = full_out.strip() + + pieces = {} + pieces["long"] = full_out + pieces["short"] = full_out[:7] # maybe improved later + pieces["error"] = None + + branch_name, rc = runner(GITS, ["rev-parse", "--abbrev-ref", "HEAD"], cwd=root) + # --abbrev-ref was added in git-1.6.3 + if rc != 0 or branch_name is None: + raise NotThisMethod("'git rev-parse --abbrev-ref' returned error") + branch_name = branch_name.strip() + + if branch_name == "HEAD": + # If we aren't exactly on a branch, pick a branch which represents + # the current commit. If all else fails, we are on a branchless + # commit. + branches, rc = runner(GITS, ["branch", "--contains"], cwd=root) + # --contains was added in git-1.5.4 + if rc != 0 or branches is None: + raise NotThisMethod("'git branch --contains' returned error") + branches = branches.split("\n") + + # Remove the first line if we're running detached + if "(" in branches[0]: + branches.pop(0) + + # Strip off the leading "* " from the list of branches. + branches = [branch[2:] for branch in branches] + if "master" in branches: + branch_name = "master" + elif not branches: + branch_name = None + else: + # Pick the first branch that is returned. Good or bad. + branch_name = branches[0] + + pieces["branch"] = branch_name + + # parse describe_out. It will be like TAG-NUM-gHEX[-dirty] or HEX[-dirty] + # TAG might have hyphens. + git_describe = describe_out + + # look for -dirty suffix + dirty = git_describe.endswith("-dirty") + pieces["dirty"] = dirty + if dirty: + git_describe = git_describe[: git_describe.rindex("-dirty")] + + # now we have TAG-NUM-gHEX or HEX + + if "-" in git_describe: + # TAG-NUM-gHEX + mo = re.search(r"^(.+)-(\d+)-g([0-9a-f]+)$", git_describe) + if not mo: + # unparsable. Maybe git-describe is misbehaving? + pieces["error"] = "unable to parse git-describe output: '%s'" % describe_out + return pieces + + # tag + full_tag = mo.group(1) + if not full_tag.startswith(tag_prefix): + if verbose: + fmt = "tag '%s' doesn't start with prefix '%s'" + print(fmt % (full_tag, tag_prefix)) + pieces["error"] = "tag '%s' doesn't start with prefix '%s'" % (full_tag, tag_prefix) + return pieces + pieces["closest-tag"] = full_tag[len(tag_prefix) :] + + # distance: number of commits since tag + pieces["distance"] = int(mo.group(2)) + + # commit: short hex revision ID + pieces["short"] = mo.group(3) + + else: + # HEX: no tags + pieces["closest-tag"] = None + out, rc = runner(GITS, ["rev-list", "HEAD", "--left-right"], cwd=root) + pieces["distance"] = len(out.split()) # total number of commits + + # commit date: see ISO-8601 comment in git_versions_from_keywords() + date = runner(GITS, ["show", "-s", "--format=%ci", "HEAD"], cwd=root)[0].strip() + # Use only the last line. Previous lines may contain GPG signature + # information. + date = date.splitlines()[-1] + pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1) + + return pieces + + +def plus_or_dot(pieces): + """Return a + if we don't already have one, else return a .""" + if "+" in pieces.get("closest-tag", ""): + return "." + return "+" + + +def render_pep440(pieces): + """Build up version string, with post-release "local version identifier". + + Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you + get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty + + Exceptions: + 1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += plus_or_dot(pieces) + rendered += "%d.g%s" % (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + else: + # exception #1 + rendered = "0+untagged.%d.g%s" % (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + return rendered + + +def render_pep440_branch(pieces): + """TAG[[.dev0]+DISTANCE.gHEX[.dirty]] . + + The ".dev0" means not master branch. Note that .dev0 sorts backwards + (a feature branch will appear "older" than the master branch). + + Exceptions: + 1: no tags. 0[.dev0]+untagged.DISTANCE.gHEX[.dirty] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += plus_or_dot(pieces) + rendered += "%d.g%s" % (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + else: + # exception #1 + rendered = "0" + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += "+untagged.%d.g%s" % (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + return rendered + + +def pep440_split_post(ver): + """Split pep440 version string at the post-release segment. + + Returns the release segments before the post-release and the + post-release version number (or -1 if no post-release segment is present). + """ + vc = str.split(ver, ".post") + return vc[0], int(vc[1] or 0) if len(vc) == 2 else None + + +def render_pep440_pre(pieces): + """TAG[.postN.devDISTANCE] -- No -dirty. + + Exceptions: + 1: no tags. 0.post0.devDISTANCE + """ + if pieces["closest-tag"]: + if pieces["distance"]: + # update the post release segment + tag_version, post_version = pep440_split_post(pieces["closest-tag"]) + rendered = tag_version + if post_version is not None: + rendered += ".post%d.dev%d" % (post_version + 1, pieces["distance"]) + else: + rendered += ".post0.dev%d" % (pieces["distance"]) + else: + # no commits, use the tag as the version + rendered = pieces["closest-tag"] + else: + # exception #1 + rendered = "0.post0.dev%d" % pieces["distance"] + return rendered + + +def render_pep440_post(pieces): + """TAG[.postDISTANCE[.dev0]+gHEX] . + + The ".dev0" means dirty. Note that .dev0 sorts backwards + (a dirty tree will appear "older" than the corresponding clean one), + but you shouldn't be releasing software with -dirty anyways. + + Exceptions: + 1: no tags. 0.postDISTANCE[.dev0] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += ".post%d" % pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + rendered += plus_or_dot(pieces) + rendered += "g%s" % pieces["short"] + else: + # exception #1 + rendered = "0.post%d" % pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + rendered += "+g%s" % pieces["short"] + return rendered + + +def render_pep440_post_branch(pieces): + """TAG[.postDISTANCE[.dev0]+gHEX[.dirty]] . + + The ".dev0" means not master branch. + + Exceptions: + 1: no tags. 0.postDISTANCE[.dev0]+gHEX[.dirty] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += ".post%d" % pieces["distance"] + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += plus_or_dot(pieces) + rendered += "g%s" % pieces["short"] + if pieces["dirty"]: + rendered += ".dirty" + else: + # exception #1 + rendered = "0.post%d" % pieces["distance"] + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += "+g%s" % pieces["short"] + if pieces["dirty"]: + rendered += ".dirty" + return rendered + + +def render_pep440_old(pieces): + """TAG[.postDISTANCE[.dev0]] . + + The ".dev0" means dirty. + + Exceptions: + 1: no tags. 0.postDISTANCE[.dev0] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += ".post%d" % pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + else: + # exception #1 + rendered = "0.post%d" % pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + return rendered + + +def render_git_describe(pieces): + """TAG[-DISTANCE-gHEX][-dirty]. + + Like 'git describe --tags --dirty --always'. + + Exceptions: + 1: no tags. HEX[-dirty] (note: no 'g' prefix) + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"]: + rendered += "-%d-g%s" % (pieces["distance"], pieces["short"]) + else: + # exception #1 + rendered = pieces["short"] + if pieces["dirty"]: + rendered += "-dirty" + return rendered + + +def render_git_describe_long(pieces): + """TAG-DISTANCE-gHEX[-dirty]. + + Like 'git describe --tags --dirty --always -long'. + The distance/hash is unconditional. + + Exceptions: + 1: no tags. HEX[-dirty] (note: no 'g' prefix) + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + rendered += "-%d-g%s" % (pieces["distance"], pieces["short"]) + else: + # exception #1 + rendered = pieces["short"] + if pieces["dirty"]: + rendered += "-dirty" + return rendered + + +def render(pieces, style): + """Render the given version pieces into the requested style.""" + if pieces["error"]: + return { + "version": "unknown", + "full-revisionid": pieces.get("long"), + "dirty": None, + "error": pieces["error"], + "date": None, + } + + if not style or style == "default": + style = "pep440" # the default + + if style == "pep440": + rendered = render_pep440(pieces) + elif style == "pep440-branch": + rendered = render_pep440_branch(pieces) + elif style == "pep440-pre": + rendered = render_pep440_pre(pieces) + elif style == "pep440-post": + rendered = render_pep440_post(pieces) + elif style == "pep440-post-branch": + rendered = render_pep440_post_branch(pieces) + elif style == "pep440-old": + rendered = render_pep440_old(pieces) + elif style == "git-describe": + rendered = render_git_describe(pieces) + elif style == "git-describe-long": + rendered = render_git_describe_long(pieces) + else: + raise ValueError("unknown style '%s'" % style) + + return { + "version": rendered, + "full-revisionid": pieces["long"], + "dirty": pieces["dirty"], + "error": None, + "date": pieces.get("date"), + } + + +def get_versions(): + """Get version information or return default if unable to do so.""" + # I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have + # __file__, we can work backwards from there to the root. Some + # py2exe/bbfreeze/non-CPython implementations don't do __file__, in which + # case we can only use expanded keywords. + + cfg = get_config() + verbose = cfg.verbose + + try: + return git_versions_from_keywords(get_keywords(), cfg.tag_prefix, verbose) + except NotThisMethod: + pass + + try: + root = os.path.realpath(__file__) + # versionfile_source is the relative path from the top of the source + # tree (where the .git directory might live) to this file. Invert + # this to find the root from __file__. + for _ in cfg.versionfile_source.split("/"): + root = os.path.dirname(root) + except NameError: + return { + "version": "0+unknown", + "full-revisionid": None, + "dirty": None, + "error": "unable to find root of source tree", + "date": None, + } + + try: + pieces = git_pieces_from_vcs(cfg.tag_prefix, root, verbose) + return render(pieces, cfg.style) + except NotThisMethod: + pass + + try: + if cfg.parentdir_prefix: + return versions_from_parentdir(cfg.parentdir_prefix, root, verbose) + except NotThisMethod: + pass + + return { + "version": "0+unknown", + "full-revisionid": None, + "dirty": None, + "error": "unable to compute version", + "date": None, + } diff --git a/sparsetensorviz/sparsetensorviz/sparsetype.py b/sparsetensorviz/sparsetensorviz/sparsetype.py new file mode 100644 index 0000000..6743254 --- /dev/null +++ b/sparsetensorviz/sparsetensorviz/sparsetype.py @@ -0,0 +1,165 @@ +from itertools import zip_longest + + +class StructureType: + def __repr__(self): + return self.name + + def __eq__(self, other): + return other is not None and self.name == to_type(other).name + + def __hash__(self): + return hash(self.name) + + def __reduce__(self): + return self.name + + +# Singletons +class sparse(StructureType): + name = "sparse" + abbreviation = "S" + + +class compressed(StructureType): + name = "compressed" + abbreviation = "C" + + +class doubly_compressed(StructureType): + name = "doubly_compressed" + abbreviation = "DC" + + +S = sparse = sparse() +C = compressed = compressed() +DC = doubly_compressed = doubly_compressed() + +_STR_TO_TYPE = { + "s": S, + "sparse": S, + "singleton": S, + "c": C, + "compressed": C, + "dc": DC, + "d": DC, + "doubly_compressed": DC, + "doubly compressed": DC, + "doubly-compressed": DC, + "doublycompressed": DC, +} + + +def to_type(x): + """Convert a string to a StructureType""" + if isinstance(x, StructureType): + return x + return _STR_TO_TYPE[x.lower()] + + +def to_str(x): + return to_type(x).name + + +def abbreviate(*types): + if len(types) == 1 and not isinstance(types[0], (StructureType, str)): + types = types[0] + abbvs = [to_type(x).abbreviation for x in types] + sep = "-" if "DC" in abbvs else "" + return sep.join(abbvs) + + +def unabbreviate(abbr): + rv = [] + for sub in abbr.replace("D-", "DC-").replace("-", "").split("DC"): + for c in sub: + rv.append(to_type(c)) + rv.append(DC) + rv.pop() # One extra DC + return rv + + +def to_taco(structure): + if isinstance(structure, str): + structure = unabbreviate(structure) + else: + structure = unabbreviate(abbreviate(*structure)) + rv = [] + L = [DC] + structure + lookahead = S # backwards-fill S values + for prev, cur, nxt in reversed(list(zip_longest(L[:-1], L[1:], L[2:]))): + if cur == C: + rv.append("dense") + elif prev == S and cur in {S, DC}: + rv.append("singleton") + elif prev in {C, DC} and cur == S and nxt is not None and lookahead in {C, S}: + rv.append("compressed-nonunique") + elif prev in {C, DC}: + rv.append("compressed") + else: + # We should be able to always go to TACO + raise NotImplementedError(f"Unable to convert to TACO structure: {structure}") + if cur != S: + lookahead = cur + rv.reverse() + + # Make some assertions about how we interpret TACO structure + assert rv[0] != "singleton" + assert rv[-1] != "compressed-nonunique" + # "compressed-nonunique" may be followed by any number of "singleton" dimensions + # and then "dense" or end of structure. E.g., "CN-D", "CN-S-D", and "CN-S-S". + is_nonunique = False + for item in rv: + if is_nonunique and item not in {"singleton", "dense"}: # pragma: no cover + raise RuntimeError("Bad TACO format") + if item == "compressed-nonunique": + is_nonunique = True + elif item != "singleton": + is_nonunique = False + + return rv + + +def from_taco(structure): + # We choose a 1-to-1 mapping to and from TACO formats. + # It's possible (even likely) that multiple TACO formats could technically + # map to the same format, but we choose 1-to-1 for clarity. + compressed = "compressed" + dense = "dense" + nonunique = "compressed-nonunique" + singleton = "singleton" + rv = [] + prev_nonS = structure[0] + # fmt: off + for prev, cur, nxt in zip_longest([None] + list(structure[:-1]), structure, structure[1:]): + # These rules were developed via trial and error. Fingers crossed! + # Let's try come up with a clearer way to convert from taco. + if cur == dense and nxt in {dense, nonunique, compressed}: + rv.append(C) + elif ( + prev in {None, dense, singleton, compressed} and cur == compressed + and nxt in {dense, nonunique, compressed} + or cur == singleton and ( + prev == compressed and nxt in {dense, nonunique, compressed} + or prev == singleton and nxt == compressed + or prev == singleton and nxt in {dense, nonunique} and prev_nonS == compressed + ) and not (prev == singleton and nxt == compressed and prev_nonS == nonunique) + ): + rv.append(DC) + elif ( + cur == nonunique and nxt in {dense, singleton} + or cur == compressed and nxt in {None, singleton} + or cur == singleton and ( + prev == nonunique and nxt in {None, dense, singleton} + or prev == compressed and nxt == singleton + or prev == singleton and nxt in {None, singleton} + or prev == singleton and nxt == dense and prev_nonS == nonunique + ) and not (nxt is None and prev_nonS == compressed) + ): + rv.append(S) + else: + raise ValueError(f"Unable to convert from TACO structure: {structure}") + if cur != "singleton": + prev_nonS = cur + # fmt: on + return rv diff --git a/sparsetensorviz/sparsetensorviz/tests/__init__.py b/sparsetensorviz/sparsetensorviz/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/sparsetensorviz/sparsetensorviz/tests/conftest.py b/sparsetensorviz/sparsetensorviz/tests/conftest.py new file mode 100644 index 0000000..2d716ad --- /dev/null +++ b/sparsetensorviz/sparsetensorviz/tests/conftest.py @@ -0,0 +1,18 @@ +import pytest + + +@pytest.fixture(scope="session", autouse=True) +def ic(): + """Make `ic` available everywhere for easier debugging""" + try: + import icecream + except ImportError: + return + icecream.install() + # icecream.ic.disable() # do ic.enable() to re-enable + return icecream.ic + + +def pytest_runtest_setup(item): + if "slow" in item.keywords and not item.config.getoption("--runslow"): + pytest.skip("need --runslow option to run") diff --git a/sparsetensorviz/sparsetensorviz/tests/test_sparsetensor.py b/sparsetensorviz/sparsetensorviz/tests/test_sparsetensor.py new file mode 100644 index 0000000..fec456f --- /dev/null +++ b/sparsetensorviz/sparsetensorviz/tests/test_sparsetensor.py @@ -0,0 +1,138 @@ +import itertools +import random + +import numpy as np +import pandas as pd +import pytest + +from sparsetensorviz import SparseTensor + + +def slow(param): + return pytest.param(param, marks=pytest.mark.slow) + + +@pytest.fixture +def indices1(): + return [ + [0, 0, 0, 0, 0, 1, 1, 1], + [0, 0, 1, 1, 1, 1, 1, 1], + [0, 0, 0, 0, 1, 1, 1, 1], + [1, 2, 0, 2, 0, 0, 1, 2], + ] + + +@pytest.mark.parametrize("shape", [[2, 2, 2, 3], [5, 6, 7, 8], [8, 7, 6, 5]]) +def test_indices1(indices1, shape): + df = pd.DataFrame(indices1).T.sort_values([0, 1, 2, 3]) + sparsities = ["S", "C", "DC"] + for sparsity in itertools.product(sparsities, sparsities, sparsities): + structure = "".join(sparsity) + "S" + st = SparseTensor(indices1, shape, structure) + st._validate() + # st._repr_svg_() + df2 = pd.DataFrame(st.arrays).T + pd.testing.assert_frame_equal(df, df2) + + +def test_rank1(): + for size in range(1, 4): + for num in range(1, size + 1): + for array in itertools.combinations(range(size), num): + array = np.array(array) + st = SparseTensor([array], (size,), "S") + st._validate() + # st._repr_svg_() + [index] = st.arrays + assert np.array_equal(array, index) + + +@pytest.mark.slow +def test_rank2(): + for nrows in range(1, 4): + for ncols in range(1, 4): + size = nrows * ncols + for num in range(1, size + 1): + for array in itertools.combinations(range(size), num): + array = np.array(array) + x = array // ncols + y = array % ncols + for sparsity in ["S", "C", "DC"]: + st = SparseTensor([x, y], (nrows, ncols), sparsity + "S") + st._validate() + # st._repr_svg_() + rows, cols = st.arrays + assert np.array_equal(x, rows) + assert np.array_equal(y, cols) + + +@pytest.mark.slow +def test_rank3(): + for nx in range(1, 3): + for ny in range(1, 3): + for nz in range(1, 3): + size = nx * ny * nz + for num in range(1, size + 1): + for array in itertools.combinations(range(size), num): + array = np.array(array) + x = array // (ny * nz) + y = array // nz % ny + z = array % nz + for sparsity in itertools.product(["S", "C", "DC"], ["S", "C", "DC"]): + if random.random() < 2 / 3: + # Randomly skip two thirds of cases to speed up testing + continue + structure = "".join(sparsity) + "S" + st = SparseTensor([x, y, z], (nx, ny, nz), structure) + st._validate() + # st._repr_svg_() + x2, y2, z2 = st.arrays + assert np.array_equal(x, x2) + assert np.array_equal(y, y2) + assert np.array_equal(z, z2) + + +@pytest.mark.parametrize("N", [1, 2, 3, 4, slow(5), slow(6)]) +def test_rankN(N): + sparsities = [["S", "C", "DC"]] * (N - 1) + for sparsity in itertools.product(*sparsities): + structure = "".join(sparsity) + "S" + # For each structure, randomly choose each dimension to be size 1, 2, 3, or 4 + shape = tuple(random.randint(1, 4) for _ in range(N)) + size = np.multiply.reduce(shape) + # Randomly choose the number of elements + num = random.randint(1, size) + # Randomly add indices for the elements + flat_idx = set() + while len(flat_idx) < num: + flat_idx.add(random.randrange(size)) + array = np.array(sorted(flat_idx)) + if N == 1: + indices = [] + else: + indices = [array // int(np.multiply.reduce(shape[1:]))] + for i in range(1, N - 1): + indices.append(array // np.multiply.reduce(shape[i + 1 :]) % shape[i]) + indices.append(array % shape[-1]) + try: + st = SparseTensor(indices, shape, structure) + except Exception: # pragma: no cover + print("N:", N) + print("array:", array) + print("structure:", structure) + print("shape:", shape) + print("indices:", indices) + raise + try: + st._validate() + except Exception: # pragma: no cover + print("structure:", st.structure) + print("shape:", st.shape) + print("indices:", st._indices) + print("pointers:", st._pointers) + print(st) + raise + # st._repr_svg_() + arrays = st.arrays + for index, arr in zip(indices, arrays): + assert np.array_equal(index, arr) diff --git a/sparsetensorviz/sparsetensorviz/tests/test_sparsetype.py b/sparsetensorviz/sparsetensorviz/tests/test_sparsetype.py new file mode 100644 index 0000000..9bf2fee --- /dev/null +++ b/sparsetensorviz/sparsetensorviz/tests/test_sparsetype.py @@ -0,0 +1,67 @@ +import itertools + +import pytest + +from sparsetensorviz.sparsetype import DC, C, S, abbreviate, from_taco, to_taco, unabbreviate + + +def test_abbreviate(): + expected = "S-C-S-DC-C-S" + assert abbreviate([S, C, S, DC, C, S]) == expected + assert abbreviate(S, C, S, DC, C, S) == expected + assert abbreviate("S", "C", "S", "DC", "C", "S") == expected + assert abbreviate(["S", "c", "Sparse", "D", "compressed", "sparse"]) == expected + + +def test_unabbreviate(): + expected = [S, C, S, DC, C, S] + assert unabbreviate("S-C-S-DC-C-S") == expected + assert unabbreviate("SCSDCCS") == expected + assert unabbreviate("SC-S-D-C-S") == expected + + +@pytest.mark.parametrize("N", range(1, 9)) +def test_from_taco(N): + compressed = "compressed" + dense = "dense" + nonunique = "compressed-nonunique" + singleton = "singleton" + options = [compressed, dense, nonunique, singleton] + results = {} + for taco in itertools.product(*([options] * N)): + try: + structure = tuple(from_taco(taco)) + except ValueError: + continue + if structure in results: # pragma: no cover + print(structure) + print(" ", results[structure]) + print(" ", taco) + raise AssertionError( + "Multiple TACO structures give the same structure: " + f"{taco} and {results[structure]} -> {structure}" + ) + results[structure] = taco + assert tuple(to_taco(structure)) == taco, (taco, structure) + assert len(results) == 3 ** (N - 1) + + +# It's not strictly necessary to have both `test_from_taco` and `test_to_taco`, +# but if changes are made, then it's helpful to have both to help debug. +@pytest.mark.parametrize("N", range(1, 9)) +def test_to_taco(N): + options = [DC, C, S] + results = {} + for structure in itertools.product(*([options] * (N - 1)), [S]): + taco = tuple(to_taco(structure)) + if taco in results: # pragma: no cover + print(taco) + print(" ", results[taco]) + print(" ", structure) + raise AssertionError( + "Multiple TACO structures give the same structure: " + f"{taco} and {results[structure]} -> {structure}" + ) + results[taco] = structure + assert tuple(from_taco(taco)) == structure, (structure, taco) + assert len(results) == 3 ** (N - 1) diff --git a/sparsetensorviz/versioneer.py b/sparsetensorviz/versioneer.py new file mode 100644 index 0000000..8db5abd --- /dev/null +++ b/sparsetensorviz/versioneer.py @@ -0,0 +1,2193 @@ +# Version: 0.23 + +"""The Versioneer - like a rocketeer, but for versions. + +The Versioneer +============== + +* like a rocketeer, but for versions! +* https://github.com/python-versioneer/python-versioneer +* Brian Warner +* License: Public Domain (CC0-1.0) +* Compatible with: Python 3.7, 3.8, 3.9, 3.10 and pypy3 +* [![Latest Version][pypi-image]][pypi-url] +* [![Build Status][travis-image]][travis-url] + +This is a tool for managing a recorded version number in distutils/setuptools-based +python projects. The goal is to remove the tedious and error-prone "update +the embedded version string" step from your release process. Making a new +release should be as easy as recording a new tag in your version-control +system, and maybe making new tarballs. + + +## Quick Install + +* `pip install versioneer` to somewhere in your $PATH +* add a `[versioneer]` section to your setup.cfg (see [Install](INSTALL.md)) +* run `versioneer install` in your source tree, commit the results +* Verify version information with `python setup.py version` + +## Version Identifiers + +Source trees come from a variety of places: + +* a version-control system checkout (mostly used by developers) +* a nightly tarball, produced by build automation +* a snapshot tarball, produced by a web-based VCS browser, like github's + "tarball from tag" feature +* a release tarball, produced by "setup.py sdist", distributed through PyPI + +Within each source tree, the version identifier (either a string or a number, +this tool is format-agnostic) can come from a variety of places: + +* ask the VCS tool itself, e.g. "git describe" (for checkouts), which knows + about recent "tags" and an absolute revision-id +* the name of the directory into which the tarball was unpacked +* an expanded VCS keyword ($Id$, etc) +* a `_version.py` created by some earlier build step + +For released software, the version identifier is closely related to a VCS +tag. Some projects use tag names that include more than just the version +string (e.g. "myproject-1.2" instead of just "1.2"), in which case the tool +needs to strip the tag prefix to extract the version identifier. For +unreleased software (between tags), the version identifier should provide +enough information to help developers recreate the same tree, while also +giving them an idea of roughly how old the tree is (after version 1.2, before +version 1.3). Many VCS systems can report a description that captures this, +for example `git describe --tags --dirty --always` reports things like +"0.7-1-g574ab98-dirty" to indicate that the checkout is one revision past the +0.7 tag, has a unique revision id of "574ab98", and is "dirty" (it has +uncommitted changes). + +The version identifier is used for multiple purposes: + +* to allow the module to self-identify its version: `myproject.__version__` +* to choose a name and prefix for a 'setup.py sdist' tarball + +## Theory of Operation + +Versioneer works by adding a special `_version.py` file into your source +tree, where your `__init__.py` can import it. This `_version.py` knows how to +dynamically ask the VCS tool for version information at import time. + +`_version.py` also contains `$Revision$` markers, and the installation +process marks `_version.py` to have this marker rewritten with a tag name +during the `git archive` command. As a result, generated tarballs will +contain enough information to get the proper version. + +To allow `setup.py` to compute a version too, a `versioneer.py` is added to +the top level of your source tree, next to `setup.py` and the `setup.cfg` +that configures it. This overrides several distutils/setuptools commands to +compute the version when invoked, and changes `setup.py build` and `setup.py +sdist` to replace `_version.py` with a small static file that contains just +the generated version data. + +## Installation + +See [INSTALL.md](./INSTALL.md) for detailed installation instructions. + +## Version-String Flavors + +Code which uses Versioneer can learn about its version string at runtime by +importing `_version` from your main `__init__.py` file and running the +`get_versions()` function. From the "outside" (e.g. in `setup.py`), you can +import the top-level `versioneer.py` and run `get_versions()`. + +Both functions return a dictionary with different flavors of version +information: + +* `['version']`: A condensed version string, rendered using the selected + style. This is the most commonly used value for the project's version + string. The default "pep440" style yields strings like `0.11`, + `0.11+2.g1076c97`, or `0.11+2.g1076c97.dirty`. See the "Styles" section + below for alternative styles. + +* `['full-revisionid']`: detailed revision identifier. For Git, this is the + full SHA1 commit id, e.g. "1076c978a8d3cfc70f408fe5974aa6c092c949ac". + +* `['date']`: Date and time of the latest `HEAD` commit. For Git, it is the + commit date in ISO 8601 format. This will be None if the date is not + available. + +* `['dirty']`: a boolean, True if the tree has uncommitted changes. Note that + this is only accurate if run in a VCS checkout, otherwise it is likely to + be False or None + +* `['error']`: if the version string could not be computed, this will be set + to a string describing the problem, otherwise it will be None. It may be + useful to throw an exception in setup.py if this is set, to avoid e.g. + creating tarballs with a version string of "unknown". + +Some variants are more useful than others. Including `full-revisionid` in a +bug report should allow developers to reconstruct the exact code being tested +(or indicate the presence of local changes that should be shared with the +developers). `version` is suitable for display in an "about" box or a CLI +`--version` output: it can be easily compared against release notes and lists +of bugs fixed in various releases. + +The installer adds the following text to your `__init__.py` to place a basic +version in `YOURPROJECT.__version__`: + + from ._version import get_versions + __version__ = get_versions()['version'] + del get_versions + +## Styles + +The setup.cfg `style=` configuration controls how the VCS information is +rendered into a version string. + +The default style, "pep440", produces a PEP440-compliant string, equal to the +un-prefixed tag name for actual releases, and containing an additional "local +version" section with more detail for in-between builds. For Git, this is +TAG[+DISTANCE.gHEX[.dirty]] , using information from `git describe --tags +--dirty --always`. For example "0.11+2.g1076c97.dirty" indicates that the +tree is like the "1076c97" commit but has uncommitted changes (".dirty"), and +that this commit is two revisions ("+2") beyond the "0.11" tag. For released +software (exactly equal to a known tag), the identifier will only contain the +stripped tag, e.g. "0.11". + +Other styles are available. See [details.md](details.md) in the Versioneer +source tree for descriptions. + +## Debugging + +Versioneer tries to avoid fatal errors: if something goes wrong, it will tend +to return a version of "0+unknown". To investigate the problem, run `setup.py +version`, which will run the version-lookup code in a verbose mode, and will +display the full contents of `get_versions()` (including the `error` string, +which may help identify what went wrong). + +## Known Limitations + +Some situations are known to cause problems for Versioneer. This details the +most significant ones. More can be found on Github +[issues page](https://github.com/python-versioneer/python-versioneer/issues). + +### Subprojects + +Versioneer has limited support for source trees in which `setup.py` is not in +the root directory (e.g. `setup.py` and `.git/` are *not* siblings). The are +two common reasons why `setup.py` might not be in the root: + +* Source trees which contain multiple subprojects, such as + [Buildbot](https://github.com/buildbot/buildbot), which contains both + "master" and "slave" subprojects, each with their own `setup.py`, + `setup.cfg`, and `tox.ini`. Projects like these produce multiple PyPI + distributions (and upload multiple independently-installable tarballs). +* Source trees whose main purpose is to contain a C library, but which also + provide bindings to Python (and perhaps other languages) in subdirectories. + +Versioneer will look for `.git` in parent directories, and most operations +should get the right version string. However `pip` and `setuptools` have bugs +and implementation details which frequently cause `pip install .` from a +subproject directory to fail to find a correct version string (so it usually +defaults to `0+unknown`). + +`pip install --editable .` should work correctly. `setup.py install` might +work too. + +Pip-8.1.1 is known to have this problem, but hopefully it will get fixed in +some later version. + +[Bug #38](https://github.com/python-versioneer/python-versioneer/issues/38) is tracking +this issue. The discussion in +[PR #61](https://github.com/python-versioneer/python-versioneer/pull/61) describes the +issue from the Versioneer side in more detail. +[pip PR#3176](https://github.com/pypa/pip/pull/3176) and +[pip PR#3615](https://github.com/pypa/pip/pull/3615) contain work to improve +pip to let Versioneer work correctly. + +Versioneer-0.16 and earlier only looked for a `.git` directory next to the +`setup.cfg`, so subprojects were completely unsupported with those releases. + +### Editable installs with setuptools <= 18.5 + +`setup.py develop` and `pip install --editable .` allow you to install a +project into a virtualenv once, then continue editing the source code (and +test) without re-installing after every change. + +"Entry-point scripts" (`setup(entry_points={"console_scripts": ..})`) are a +convenient way to specify executable scripts that should be installed along +with the python package. + +These both work as expected when using modern setuptools. When using +setuptools-18.5 or earlier, however, certain operations will cause +`pkg_resources.DistributionNotFound` errors when running the entrypoint +script, which must be resolved by re-installing the package. This happens +when the install happens with one version, then the egg_info data is +regenerated while a different version is checked out. Many setup.py commands +cause egg_info to be rebuilt (including `sdist`, `wheel`, and installing into +a different virtualenv), so this can be surprising. + +[Bug #83](https://github.com/python-versioneer/python-versioneer/issues/83) describes +this one, but upgrading to a newer version of setuptools should probably +resolve it. + + +## Updating Versioneer + +To upgrade your project to a new release of Versioneer, do the following: + +* install the new Versioneer (`pip install -U versioneer` or equivalent) +* edit `setup.cfg`, if necessary, to include any new configuration settings + indicated by the release notes. See [UPGRADING](./UPGRADING.md) for details. +* re-run `versioneer install` in your source tree, to replace + `SRC/_version.py` +* commit any changed files + +## Future Directions + +This tool is designed to make it easily extended to other version-control +systems: all VCS-specific components are in separate directories like +src/git/ . The top-level `versioneer.py` script is assembled from these +components by running make-versioneer.py . In the future, make-versioneer.py +will take a VCS name as an argument, and will construct a version of +`versioneer.py` that is specific to the given VCS. It might also take the +configuration arguments that are currently provided manually during +installation by editing setup.py . Alternatively, it might go the other +direction and include code from all supported VCS systems, reducing the +number of intermediate scripts. + +## Similar projects + +* [setuptools_scm](https://github.com/pypa/setuptools_scm/) - a non-vendored build-time + dependency +* [minver](https://github.com/jbweston/miniver) - a lightweight reimplementation of + versioneer +* [versioningit](https://github.com/jwodder/versioningit) - a PEP 518-based setuptools + plugin + +## License + +To make Versioneer easier to embed, all its code is dedicated to the public +domain. The `_version.py` that it creates is also in the public domain. +Specifically, both are released under the Creative Commons "Public Domain +Dedication" license (CC0-1.0), as described in +https://creativecommons.org/publicdomain/zero/1.0/ . + +[pypi-image]: https://img.shields.io/pypi/v/versioneer.svg +[pypi-url]: https://pypi.python.org/pypi/versioneer/ +[travis-image]: +https://img.shields.io/travis/com/python-versioneer/python-versioneer.svg +[travis-url]: https://travis-ci.com/github/python-versioneer/python-versioneer + +""" +# pylint:disable=invalid-name,import-outside-toplevel,missing-function-docstring +# pylint:disable=missing-class-docstring,too-many-branches,too-many-statements +# pylint:disable=raise-missing-from,too-many-lines,too-many-locals,import-error +# pylint:disable=too-few-public-methods,redefined-outer-name,consider-using-with +# pylint:disable=attribute-defined-outside-init,too-many-arguments + +import configparser +import errno +import functools +import json +import os +import re +import subprocess +import sys +from typing import Callable, Dict + + +class VersioneerConfig: + """Container for Versioneer configuration parameters.""" + + +def get_root(): + """Get the project root directory. + + We require that all commands are run from the project root, i.e. the + directory that contains setup.py, setup.cfg, and versioneer.py . + """ + root = os.path.realpath(os.path.abspath(os.getcwd())) + setup_py = os.path.join(root, "setup.py") + versioneer_py = os.path.join(root, "versioneer.py") + if not (os.path.exists(setup_py) or os.path.exists(versioneer_py)): + # allow 'python path/to/setup.py COMMAND' + root = os.path.dirname(os.path.realpath(os.path.abspath(sys.argv[0]))) + setup_py = os.path.join(root, "setup.py") + versioneer_py = os.path.join(root, "versioneer.py") + if not (os.path.exists(setup_py) or os.path.exists(versioneer_py)): + err = ( + "Versioneer was unable to run the project root directory. " + "Versioneer requires setup.py to be executed from " + "its immediate directory (like 'python setup.py COMMAND'), " + "or in a way that lets it use sys.argv[0] to find the root " + "(like 'python path/to/setup.py COMMAND')." + ) + raise VersioneerBadRootError(err) + try: + # Certain runtime workflows (setup.py install/develop in a setuptools + # tree) execute all dependencies in a single python process, so + # "versioneer" may be imported multiple times, and python's shared + # module-import table will cache the first one. So we can't use + # os.path.dirname(__file__), as that will find whichever + # versioneer.py was first imported, even in later projects. + my_path = os.path.realpath(os.path.abspath(__file__)) + me_dir = os.path.normcase(os.path.splitext(my_path)[0]) + vsr_dir = os.path.normcase(os.path.splitext(versioneer_py)[0]) + if me_dir != vsr_dir: + print( + "Warning: build in %s is using versioneer.py from %s" + % (os.path.dirname(my_path), versioneer_py) + ) + except NameError: + pass + return root + + +def get_config_from_root(root): + """Read the project setup.cfg file to determine Versioneer config.""" + # This might raise OSError (if setup.cfg is missing), or + # configparser.NoSectionError (if it lacks a [versioneer] section), or + # configparser.NoOptionError (if it lacks "VCS="). See the docstring at + # the top of versioneer.py for instructions on writing your setup.cfg . + setup_cfg = os.path.join(root, "setup.cfg") + parser = configparser.ConfigParser() + with open(setup_cfg, "r") as cfg_file: + parser.read_file(cfg_file) + VCS = parser.get("versioneer", "VCS") # mandatory + + # Dict-like interface for non-mandatory entries + section = parser["versioneer"] + + cfg = VersioneerConfig() + cfg.VCS = VCS + cfg.style = section.get("style", "") + cfg.versionfile_source = section.get("versionfile_source") + cfg.versionfile_build = section.get("versionfile_build") + cfg.tag_prefix = section.get("tag_prefix") + if cfg.tag_prefix in ("''", '""', None): + cfg.tag_prefix = "" + cfg.parentdir_prefix = section.get("parentdir_prefix") + cfg.verbose = section.get("verbose") + return cfg + + +class NotThisMethod(Exception): + """Exception raised if a method is not valid for the current scenario.""" + + +# these dictionaries contain VCS-specific tools +LONG_VERSION_PY: Dict[str, str] = {} +HANDLERS: Dict[str, Dict[str, Callable]] = {} + + +def register_vcs_handler(vcs, method): # decorator + """Create decorator to mark a method as the handler of a VCS.""" + + def decorate(f): + """Store f in HANDLERS[vcs][method].""" + HANDLERS.setdefault(vcs, {})[method] = f + return f + + return decorate + + +def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False, env=None): + """Call the given command(s).""" + assert isinstance(commands, list) + process = None + + popen_kwargs = {} + if sys.platform == "win32": + # This hides the console window if pythonw.exe is used + startupinfo = subprocess.STARTUPINFO() + startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW + popen_kwargs["startupinfo"] = startupinfo + + for command in commands: + try: + dispcmd = str([command] + args) + # remember shell=False, so use git.cmd on windows, not just git + process = subprocess.Popen( + [command] + args, + cwd=cwd, + env=env, + stdout=subprocess.PIPE, + stderr=(subprocess.PIPE if hide_stderr else None), + **popen_kwargs, + ) + break + except OSError: + e = sys.exc_info()[1] + if e.errno == errno.ENOENT: + continue + if verbose: + print("unable to run %s" % dispcmd) + print(e) + return None, None + else: + if verbose: + print("unable to find command, tried %s" % (commands,)) + return None, None + stdout = process.communicate()[0].strip().decode() + if process.returncode != 0: + if verbose: + print("unable to run %s (error)" % dispcmd) + print("stdout was %s" % stdout) + return None, process.returncode + return stdout, process.returncode + + +LONG_VERSION_PY[ + "git" +] = r''' +# This file helps to compute a version number in source trees obtained from +# git-archive tarball (such as those provided by githubs download-from-tag +# feature). Distribution tarballs (built by setup.py sdist) and build +# directories (produced by setup.py build) will contain a much shorter file +# that just contains the computed version number. + +# This file is released into the public domain. Generated by +# versioneer-0.23 (https://github.com/python-versioneer/python-versioneer) + +"""Git implementation of _version.py.""" + +import errno +import os +import re +import subprocess +import sys +from typing import Callable, Dict +import functools + + +def get_keywords(): + """Get the keywords needed to look up the version information.""" + # these strings will be replaced by git during git-archive. + # setup.py/versioneer.py will grep for the variable names, so they must + # each be defined on a line of their own. _version.py will just call + # get_keywords(). + git_refnames = "%(DOLLAR)sFormat:%%d%(DOLLAR)s" + git_full = "%(DOLLAR)sFormat:%%H%(DOLLAR)s" + git_date = "%(DOLLAR)sFormat:%%ci%(DOLLAR)s" + keywords = {"refnames": git_refnames, "full": git_full, "date": git_date} + return keywords + + +class VersioneerConfig: + """Container for Versioneer configuration parameters.""" + + +def get_config(): + """Create, populate and return the VersioneerConfig() object.""" + # these strings are filled in when 'setup.py versioneer' creates + # _version.py + cfg = VersioneerConfig() + cfg.VCS = "git" + cfg.style = "%(STYLE)s" + cfg.tag_prefix = "%(TAG_PREFIX)s" + cfg.parentdir_prefix = "%(PARENTDIR_PREFIX)s" + cfg.versionfile_source = "%(VERSIONFILE_SOURCE)s" + cfg.verbose = False + return cfg + + +class NotThisMethod(Exception): + """Exception raised if a method is not valid for the current scenario.""" + + +LONG_VERSION_PY: Dict[str, str] = {} +HANDLERS: Dict[str, Dict[str, Callable]] = {} + + +def register_vcs_handler(vcs, method): # decorator + """Create decorator to mark a method as the handler of a VCS.""" + def decorate(f): + """Store f in HANDLERS[vcs][method].""" + if vcs not in HANDLERS: + HANDLERS[vcs] = {} + HANDLERS[vcs][method] = f + return f + return decorate + + +def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False, + env=None): + """Call the given command(s).""" + assert isinstance(commands, list) + process = None + + popen_kwargs = {} + if sys.platform == "win32": + # This hides the console window if pythonw.exe is used + startupinfo = subprocess.STARTUPINFO() + startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW + popen_kwargs["startupinfo"] = startupinfo + + for command in commands: + try: + dispcmd = str([command] + args) + # remember shell=False, so use git.cmd on windows, not just git + process = subprocess.Popen([command] + args, cwd=cwd, env=env, + stdout=subprocess.PIPE, + stderr=(subprocess.PIPE if hide_stderr + else None), **popen_kwargs) + break + except OSError: + e = sys.exc_info()[1] + if e.errno == errno.ENOENT: + continue + if verbose: + print("unable to run %%s" %% dispcmd) + print(e) + return None, None + else: + if verbose: + print("unable to find command, tried %%s" %% (commands,)) + return None, None + stdout = process.communicate()[0].strip().decode() + if process.returncode != 0: + if verbose: + print("unable to run %%s (error)" %% dispcmd) + print("stdout was %%s" %% stdout) + return None, process.returncode + return stdout, process.returncode + + +def versions_from_parentdir(parentdir_prefix, root, verbose): + """Try to determine the version from the parent directory name. + + Source tarballs conventionally unpack into a directory that includes both + the project name and a version string. We will also support searching up + two directory levels for an appropriately named parent directory + """ + rootdirs = [] + + for _ in range(3): + dirname = os.path.basename(root) + if dirname.startswith(parentdir_prefix): + return {"version": dirname[len(parentdir_prefix):], + "full-revisionid": None, + "dirty": False, "error": None, "date": None} + rootdirs.append(root) + root = os.path.dirname(root) # up a level + + if verbose: + print("Tried directories %%s but none started with prefix %%s" %% + (str(rootdirs), parentdir_prefix)) + raise NotThisMethod("rootdir doesn't start with parentdir_prefix") + + +@register_vcs_handler("git", "get_keywords") +def git_get_keywords(versionfile_abs): + """Extract version information from the given file.""" + # the code embedded in _version.py can just fetch the value of these + # keywords. When used from setup.py, we don't want to import _version.py, + # so we do it with a regexp instead. This function is not used from + # _version.py. + keywords = {} + try: + with open(versionfile_abs, "r") as fobj: + for line in fobj: + if line.strip().startswith("git_refnames ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["refnames"] = mo.group(1) + if line.strip().startswith("git_full ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["full"] = mo.group(1) + if line.strip().startswith("git_date ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["date"] = mo.group(1) + except OSError: + pass + return keywords + + +@register_vcs_handler("git", "keywords") +def git_versions_from_keywords(keywords, tag_prefix, verbose): + """Get version information from git keywords.""" + if "refnames" not in keywords: + raise NotThisMethod("Short version file found") + date = keywords.get("date") + if date is not None: + # Use only the last line. Previous lines may contain GPG signature + # information. + date = date.splitlines()[-1] + + # git-2.2.0 added "%%cI", which expands to an ISO-8601 -compliant + # datestamp. However we prefer "%%ci" (which expands to an "ISO-8601 + # -like" string, which we must then edit to make compliant), because + # it's been around since git-1.5.3, and it's too difficult to + # discover which version we're using, or to work around using an + # older one. + date = date.strip().replace(" ", "T", 1).replace(" ", "", 1) + refnames = keywords["refnames"].strip() + if refnames.startswith("$Format"): + if verbose: + print("keywords are unexpanded, not using") + raise NotThisMethod("unexpanded keywords, not a git-archive tarball") + refs = {r.strip() for r in refnames.strip("()").split(",")} + # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of + # just "foo-1.0". If we see a "tag: " prefix, prefer those. + TAG = "tag: " + tags = {r[len(TAG):] for r in refs if r.startswith(TAG)} + if not tags: + # Either we're using git < 1.8.3, or there really are no tags. We use + # a heuristic: assume all version tags have a digit. The old git %%d + # expansion behaves like git log --decorate=short and strips out the + # refs/heads/ and refs/tags/ prefixes that would let us distinguish + # between branches and tags. By ignoring refnames without digits, we + # filter out many common branch names like "release" and + # "stabilization", as well as "HEAD" and "master". + tags = {r for r in refs if re.search(r'\d', r)} + if verbose: + print("discarding '%%s', no digits" %% ",".join(refs - tags)) + if verbose: + print("likely tags: %%s" %% ",".join(sorted(tags))) + for ref in sorted(tags): + # sorting will prefer e.g. "2.0" over "2.0rc1" + if ref.startswith(tag_prefix): + r = ref[len(tag_prefix):] + # Filter out refs that exactly match prefix or that don't start + # with a number once the prefix is stripped (mostly a concern + # when prefix is '') + if not re.match(r'\d', r): + continue + if verbose: + print("picking %%s" %% r) + return {"version": r, + "full-revisionid": keywords["full"].strip(), + "dirty": False, "error": None, + "date": date} + # no suitable tags, so version is "0+unknown", but full hex is still there + if verbose: + print("no suitable tags, using unknown + full revision id") + return {"version": "0+unknown", + "full-revisionid": keywords["full"].strip(), + "dirty": False, "error": "no suitable tags", "date": None} + + +@register_vcs_handler("git", "pieces_from_vcs") +def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command): + """Get version from 'git describe' in the root of the source tree. + + This only gets called if the git-archive 'subst' keywords were *not* + expanded, and _version.py hasn't already been rewritten with a short + version string, meaning we're inside a checked out source tree. + """ + GITS = ["git"] + if sys.platform == "win32": + GITS = ["git.cmd", "git.exe"] + + # GIT_DIR can interfere with correct operation of Versioneer. + # It may be intended to be passed to the Versioneer-versioned project, + # but that should not change where we get our version from. + env = os.environ.copy() + env.pop("GIT_DIR", None) + runner = functools.partial(runner, env=env) + + _, rc = runner(GITS, ["rev-parse", "--git-dir"], cwd=root, + hide_stderr=True) + if rc != 0: + if verbose: + print("Directory %%s not under git control" %% root) + raise NotThisMethod("'git rev-parse --git-dir' returned error") + + # if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty] + # if there isn't one, this yields HEX[-dirty] (no NUM) + describe_out, rc = runner(GITS, [ + "describe", "--tags", "--dirty", "--always", "--long", + "--match", f"{tag_prefix}[[:digit:]]*" + ], cwd=root) + # --long was added in git-1.5.5 + if describe_out is None: + raise NotThisMethod("'git describe' failed") + describe_out = describe_out.strip() + full_out, rc = runner(GITS, ["rev-parse", "HEAD"], cwd=root) + if full_out is None: + raise NotThisMethod("'git rev-parse' failed") + full_out = full_out.strip() + + pieces = {} + pieces["long"] = full_out + pieces["short"] = full_out[:7] # maybe improved later + pieces["error"] = None + + branch_name, rc = runner(GITS, ["rev-parse", "--abbrev-ref", "HEAD"], + cwd=root) + # --abbrev-ref was added in git-1.6.3 + if rc != 0 or branch_name is None: + raise NotThisMethod("'git rev-parse --abbrev-ref' returned error") + branch_name = branch_name.strip() + + if branch_name == "HEAD": + # If we aren't exactly on a branch, pick a branch which represents + # the current commit. If all else fails, we are on a branchless + # commit. + branches, rc = runner(GITS, ["branch", "--contains"], cwd=root) + # --contains was added in git-1.5.4 + if rc != 0 or branches is None: + raise NotThisMethod("'git branch --contains' returned error") + branches = branches.split("\n") + + # Remove the first line if we're running detached + if "(" in branches[0]: + branches.pop(0) + + # Strip off the leading "* " from the list of branches. + branches = [branch[2:] for branch in branches] + if "master" in branches: + branch_name = "master" + elif not branches: + branch_name = None + else: + # Pick the first branch that is returned. Good or bad. + branch_name = branches[0] + + pieces["branch"] = branch_name + + # parse describe_out. It will be like TAG-NUM-gHEX[-dirty] or HEX[-dirty] + # TAG might have hyphens. + git_describe = describe_out + + # look for -dirty suffix + dirty = git_describe.endswith("-dirty") + pieces["dirty"] = dirty + if dirty: + git_describe = git_describe[:git_describe.rindex("-dirty")] + + # now we have TAG-NUM-gHEX or HEX + + if "-" in git_describe: + # TAG-NUM-gHEX + mo = re.search(r'^(.+)-(\d+)-g([0-9a-f]+)$', git_describe) + if not mo: + # unparsable. Maybe git-describe is misbehaving? + pieces["error"] = ("unable to parse git-describe output: '%%s'" + %% describe_out) + return pieces + + # tag + full_tag = mo.group(1) + if not full_tag.startswith(tag_prefix): + if verbose: + fmt = "tag '%%s' doesn't start with prefix '%%s'" + print(fmt %% (full_tag, tag_prefix)) + pieces["error"] = ("tag '%%s' doesn't start with prefix '%%s'" + %% (full_tag, tag_prefix)) + return pieces + pieces["closest-tag"] = full_tag[len(tag_prefix):] + + # distance: number of commits since tag + pieces["distance"] = int(mo.group(2)) + + # commit: short hex revision ID + pieces["short"] = mo.group(3) + + else: + # HEX: no tags + pieces["closest-tag"] = None + out, rc = runner(GITS, ["rev-list", "HEAD", "--left-right"], cwd=root) + pieces["distance"] = len(out.split()) # total number of commits + + # commit date: see ISO-8601 comment in git_versions_from_keywords() + date = runner(GITS, ["show", "-s", "--format=%%ci", "HEAD"], cwd=root)[0].strip() + # Use only the last line. Previous lines may contain GPG signature + # information. + date = date.splitlines()[-1] + pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1) + + return pieces + + +def plus_or_dot(pieces): + """Return a + if we don't already have one, else return a .""" + if "+" in pieces.get("closest-tag", ""): + return "." + return "+" + + +def render_pep440(pieces): + """Build up version string, with post-release "local version identifier". + + Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you + get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty + + Exceptions: + 1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += plus_or_dot(pieces) + rendered += "%%d.g%%s" %% (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + else: + # exception #1 + rendered = "0+untagged.%%d.g%%s" %% (pieces["distance"], + pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + return rendered + + +def render_pep440_branch(pieces): + """TAG[[.dev0]+DISTANCE.gHEX[.dirty]] . + + The ".dev0" means not master branch. Note that .dev0 sorts backwards + (a feature branch will appear "older" than the master branch). + + Exceptions: + 1: no tags. 0[.dev0]+untagged.DISTANCE.gHEX[.dirty] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += plus_or_dot(pieces) + rendered += "%%d.g%%s" %% (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + else: + # exception #1 + rendered = "0" + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += "+untagged.%%d.g%%s" %% (pieces["distance"], + pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + return rendered + + +def pep440_split_post(ver): + """Split pep440 version string at the post-release segment. + + Returns the release segments before the post-release and the + post-release version number (or -1 if no post-release segment is present). + """ + vc = str.split(ver, ".post") + return vc[0], int(vc[1] or 0) if len(vc) == 2 else None + + +def render_pep440_pre(pieces): + """TAG[.postN.devDISTANCE] -- No -dirty. + + Exceptions: + 1: no tags. 0.post0.devDISTANCE + """ + if pieces["closest-tag"]: + if pieces["distance"]: + # update the post release segment + tag_version, post_version = pep440_split_post(pieces["closest-tag"]) + rendered = tag_version + if post_version is not None: + rendered += ".post%%d.dev%%d" %% (post_version + 1, pieces["distance"]) + else: + rendered += ".post0.dev%%d" %% (pieces["distance"]) + else: + # no commits, use the tag as the version + rendered = pieces["closest-tag"] + else: + # exception #1 + rendered = "0.post0.dev%%d" %% pieces["distance"] + return rendered + + +def render_pep440_post(pieces): + """TAG[.postDISTANCE[.dev0]+gHEX] . + + The ".dev0" means dirty. Note that .dev0 sorts backwards + (a dirty tree will appear "older" than the corresponding clean one), + but you shouldn't be releasing software with -dirty anyways. + + Exceptions: + 1: no tags. 0.postDISTANCE[.dev0] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += ".post%%d" %% pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + rendered += plus_or_dot(pieces) + rendered += "g%%s" %% pieces["short"] + else: + # exception #1 + rendered = "0.post%%d" %% pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + rendered += "+g%%s" %% pieces["short"] + return rendered + + +def render_pep440_post_branch(pieces): + """TAG[.postDISTANCE[.dev0]+gHEX[.dirty]] . + + The ".dev0" means not master branch. + + Exceptions: + 1: no tags. 0.postDISTANCE[.dev0]+gHEX[.dirty] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += ".post%%d" %% pieces["distance"] + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += plus_or_dot(pieces) + rendered += "g%%s" %% pieces["short"] + if pieces["dirty"]: + rendered += ".dirty" + else: + # exception #1 + rendered = "0.post%%d" %% pieces["distance"] + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += "+g%%s" %% pieces["short"] + if pieces["dirty"]: + rendered += ".dirty" + return rendered + + +def render_pep440_old(pieces): + """TAG[.postDISTANCE[.dev0]] . + + The ".dev0" means dirty. + + Exceptions: + 1: no tags. 0.postDISTANCE[.dev0] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += ".post%%d" %% pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + else: + # exception #1 + rendered = "0.post%%d" %% pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + return rendered + + +def render_git_describe(pieces): + """TAG[-DISTANCE-gHEX][-dirty]. + + Like 'git describe --tags --dirty --always'. + + Exceptions: + 1: no tags. HEX[-dirty] (note: no 'g' prefix) + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"]: + rendered += "-%%d-g%%s" %% (pieces["distance"], pieces["short"]) + else: + # exception #1 + rendered = pieces["short"] + if pieces["dirty"]: + rendered += "-dirty" + return rendered + + +def render_git_describe_long(pieces): + """TAG-DISTANCE-gHEX[-dirty]. + + Like 'git describe --tags --dirty --always -long'. + The distance/hash is unconditional. + + Exceptions: + 1: no tags. HEX[-dirty] (note: no 'g' prefix) + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + rendered += "-%%d-g%%s" %% (pieces["distance"], pieces["short"]) + else: + # exception #1 + rendered = pieces["short"] + if pieces["dirty"]: + rendered += "-dirty" + return rendered + + +def render(pieces, style): + """Render the given version pieces into the requested style.""" + if pieces["error"]: + return {"version": "unknown", + "full-revisionid": pieces.get("long"), + "dirty": None, + "error": pieces["error"], + "date": None} + + if not style or style == "default": + style = "pep440" # the default + + if style == "pep440": + rendered = render_pep440(pieces) + elif style == "pep440-branch": + rendered = render_pep440_branch(pieces) + elif style == "pep440-pre": + rendered = render_pep440_pre(pieces) + elif style == "pep440-post": + rendered = render_pep440_post(pieces) + elif style == "pep440-post-branch": + rendered = render_pep440_post_branch(pieces) + elif style == "pep440-old": + rendered = render_pep440_old(pieces) + elif style == "git-describe": + rendered = render_git_describe(pieces) + elif style == "git-describe-long": + rendered = render_git_describe_long(pieces) + else: + raise ValueError("unknown style '%%s'" %% style) + + return {"version": rendered, "full-revisionid": pieces["long"], + "dirty": pieces["dirty"], "error": None, + "date": pieces.get("date")} + + +def get_versions(): + """Get version information or return default if unable to do so.""" + # I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have + # __file__, we can work backwards from there to the root. Some + # py2exe/bbfreeze/non-CPython implementations don't do __file__, in which + # case we can only use expanded keywords. + + cfg = get_config() + verbose = cfg.verbose + + try: + return git_versions_from_keywords(get_keywords(), cfg.tag_prefix, + verbose) + except NotThisMethod: + pass + + try: + root = os.path.realpath(__file__) + # versionfile_source is the relative path from the top of the source + # tree (where the .git directory might live) to this file. Invert + # this to find the root from __file__. + for _ in cfg.versionfile_source.split('/'): + root = os.path.dirname(root) + except NameError: + return {"version": "0+unknown", "full-revisionid": None, + "dirty": None, + "error": "unable to find root of source tree", + "date": None} + + try: + pieces = git_pieces_from_vcs(cfg.tag_prefix, root, verbose) + return render(pieces, cfg.style) + except NotThisMethod: + pass + + try: + if cfg.parentdir_prefix: + return versions_from_parentdir(cfg.parentdir_prefix, root, verbose) + except NotThisMethod: + pass + + return {"version": "0+unknown", "full-revisionid": None, + "dirty": None, + "error": "unable to compute version", "date": None} +''' + + +@register_vcs_handler("git", "get_keywords") +def git_get_keywords(versionfile_abs): + """Extract version information from the given file.""" + # the code embedded in _version.py can just fetch the value of these + # keywords. When used from setup.py, we don't want to import _version.py, + # so we do it with a regexp instead. This function is not used from + # _version.py. + keywords = {} + try: + with open(versionfile_abs, "r") as fobj: + for line in fobj: + if line.strip().startswith("git_refnames ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["refnames"] = mo.group(1) + if line.strip().startswith("git_full ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["full"] = mo.group(1) + if line.strip().startswith("git_date ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["date"] = mo.group(1) + except OSError: + pass + return keywords + + +@register_vcs_handler("git", "keywords") +def git_versions_from_keywords(keywords, tag_prefix, verbose): + """Get version information from git keywords.""" + if "refnames" not in keywords: + raise NotThisMethod("Short version file found") + date = keywords.get("date") + if date is not None: + # Use only the last line. Previous lines may contain GPG signature + # information. + date = date.splitlines()[-1] + + # git-2.2.0 added "%cI", which expands to an ISO-8601 -compliant + # datestamp. However we prefer "%ci" (which expands to an "ISO-8601 + # -like" string, which we must then edit to make compliant), because + # it's been around since git-1.5.3, and it's too difficult to + # discover which version we're using, or to work around using an + # older one. + date = date.strip().replace(" ", "T", 1).replace(" ", "", 1) + refnames = keywords["refnames"].strip() + if refnames.startswith("$Format"): + if verbose: + print("keywords are unexpanded, not using") + raise NotThisMethod("unexpanded keywords, not a git-archive tarball") + refs = {r.strip() for r in refnames.strip("()").split(",")} + # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of + # just "foo-1.0". If we see a "tag: " prefix, prefer those. + TAG = "tag: " + tags = {r[len(TAG) :] for r in refs if r.startswith(TAG)} + if not tags: + # Either we're using git < 1.8.3, or there really are no tags. We use + # a heuristic: assume all version tags have a digit. The old git %d + # expansion behaves like git log --decorate=short and strips out the + # refs/heads/ and refs/tags/ prefixes that would let us distinguish + # between branches and tags. By ignoring refnames without digits, we + # filter out many common branch names like "release" and + # "stabilization", as well as "HEAD" and "master". + tags = {r for r in refs if re.search(r"\d", r)} + if verbose: + print("discarding '%s', no digits" % ",".join(refs - tags)) + if verbose: + print("likely tags: %s" % ",".join(sorted(tags))) + for ref in sorted(tags): + # sorting will prefer e.g. "2.0" over "2.0rc1" + if ref.startswith(tag_prefix): + r = ref[len(tag_prefix) :] + # Filter out refs that exactly match prefix or that don't start + # with a number once the prefix is stripped (mostly a concern + # when prefix is '') + if not re.match(r"\d", r): + continue + if verbose: + print("picking %s" % r) + return { + "version": r, + "full-revisionid": keywords["full"].strip(), + "dirty": False, + "error": None, + "date": date, + } + # no suitable tags, so version is "0+unknown", but full hex is still there + if verbose: + print("no suitable tags, using unknown + full revision id") + return { + "version": "0+unknown", + "full-revisionid": keywords["full"].strip(), + "dirty": False, + "error": "no suitable tags", + "date": None, + } + + +@register_vcs_handler("git", "pieces_from_vcs") +def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command): + """Get version from 'git describe' in the root of the source tree. + + This only gets called if the git-archive 'subst' keywords were *not* + expanded, and _version.py hasn't already been rewritten with a short + version string, meaning we're inside a checked out source tree. + """ + GITS = ["git"] + if sys.platform == "win32": + GITS = ["git.cmd", "git.exe"] + + # GIT_DIR can interfere with correct operation of Versioneer. + # It may be intended to be passed to the Versioneer-versioned project, + # but that should not change where we get our version from. + env = os.environ.copy() + env.pop("GIT_DIR", None) + runner = functools.partial(runner, env=env) + + _, rc = runner(GITS, ["rev-parse", "--git-dir"], cwd=root, hide_stderr=True) + if rc != 0: + if verbose: + print("Directory %s not under git control" % root) + raise NotThisMethod("'git rev-parse --git-dir' returned error") + + # if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty] + # if there isn't one, this yields HEX[-dirty] (no NUM) + describe_out, rc = runner( + GITS, + [ + "describe", + "--tags", + "--dirty", + "--always", + "--long", + "--match", + f"{tag_prefix}[[:digit:]]*", + ], + cwd=root, + ) + # --long was added in git-1.5.5 + if describe_out is None: + raise NotThisMethod("'git describe' failed") + describe_out = describe_out.strip() + full_out, rc = runner(GITS, ["rev-parse", "HEAD"], cwd=root) + if full_out is None: + raise NotThisMethod("'git rev-parse' failed") + full_out = full_out.strip() + + pieces = {} + pieces["long"] = full_out + pieces["short"] = full_out[:7] # maybe improved later + pieces["error"] = None + + branch_name, rc = runner(GITS, ["rev-parse", "--abbrev-ref", "HEAD"], cwd=root) + # --abbrev-ref was added in git-1.6.3 + if rc != 0 or branch_name is None: + raise NotThisMethod("'git rev-parse --abbrev-ref' returned error") + branch_name = branch_name.strip() + + if branch_name == "HEAD": + # If we aren't exactly on a branch, pick a branch which represents + # the current commit. If all else fails, we are on a branchless + # commit. + branches, rc = runner(GITS, ["branch", "--contains"], cwd=root) + # --contains was added in git-1.5.4 + if rc != 0 or branches is None: + raise NotThisMethod("'git branch --contains' returned error") + branches = branches.split("\n") + + # Remove the first line if we're running detached + if "(" in branches[0]: + branches.pop(0) + + # Strip off the leading "* " from the list of branches. + branches = [branch[2:] for branch in branches] + if "master" in branches: + branch_name = "master" + elif not branches: + branch_name = None + else: + # Pick the first branch that is returned. Good or bad. + branch_name = branches[0] + + pieces["branch"] = branch_name + + # parse describe_out. It will be like TAG-NUM-gHEX[-dirty] or HEX[-dirty] + # TAG might have hyphens. + git_describe = describe_out + + # look for -dirty suffix + dirty = git_describe.endswith("-dirty") + pieces["dirty"] = dirty + if dirty: + git_describe = git_describe[: git_describe.rindex("-dirty")] + + # now we have TAG-NUM-gHEX or HEX + + if "-" in git_describe: + # TAG-NUM-gHEX + mo = re.search(r"^(.+)-(\d+)-g([0-9a-f]+)$", git_describe) + if not mo: + # unparsable. Maybe git-describe is misbehaving? + pieces["error"] = "unable to parse git-describe output: '%s'" % describe_out + return pieces + + # tag + full_tag = mo.group(1) + if not full_tag.startswith(tag_prefix): + if verbose: + fmt = "tag '%s' doesn't start with prefix '%s'" + print(fmt % (full_tag, tag_prefix)) + pieces["error"] = "tag '%s' doesn't start with prefix '%s'" % (full_tag, tag_prefix) + return pieces + pieces["closest-tag"] = full_tag[len(tag_prefix) :] + + # distance: number of commits since tag + pieces["distance"] = int(mo.group(2)) + + # commit: short hex revision ID + pieces["short"] = mo.group(3) + + else: + # HEX: no tags + pieces["closest-tag"] = None + out, rc = runner(GITS, ["rev-list", "HEAD", "--left-right"], cwd=root) + pieces["distance"] = len(out.split()) # total number of commits + + # commit date: see ISO-8601 comment in git_versions_from_keywords() + date = runner(GITS, ["show", "-s", "--format=%ci", "HEAD"], cwd=root)[0].strip() + # Use only the last line. Previous lines may contain GPG signature + # information. + date = date.splitlines()[-1] + pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1) + + return pieces + + +def do_vcs_install(versionfile_source, ipy): + """Git-specific installation logic for Versioneer. + + For Git, this means creating/changing .gitattributes to mark _version.py + for export-subst keyword substitution. + """ + GITS = ["git"] + if sys.platform == "win32": + GITS = ["git.cmd", "git.exe"] + files = [versionfile_source] + if ipy: + files.append(ipy) + try: + my_path = __file__ + if my_path.endswith(".pyc") or my_path.endswith(".pyo"): + my_path = os.path.splitext(my_path)[0] + ".py" + versioneer_file = os.path.relpath(my_path) + except NameError: + versioneer_file = "versioneer.py" + files.append(versioneer_file) + present = False + try: + with open(".gitattributes", "r") as fobj: + for line in fobj: + if line.strip().startswith(versionfile_source): + if "export-subst" in line.strip().split()[1:]: + present = True + break + except OSError: + pass + if not present: + with open(".gitattributes", "a+") as fobj: + fobj.write(f"{versionfile_source} export-subst\n") + files.append(".gitattributes") + run_command(GITS, ["add", "--"] + files) + + +def versions_from_parentdir(parentdir_prefix, root, verbose): + """Try to determine the version from the parent directory name. + + Source tarballs conventionally unpack into a directory that includes both + the project name and a version string. We will also support searching up + two directory levels for an appropriately named parent directory + """ + rootdirs = [] + + for _ in range(3): + dirname = os.path.basename(root) + if dirname.startswith(parentdir_prefix): + return { + "version": dirname[len(parentdir_prefix) :], + "full-revisionid": None, + "dirty": False, + "error": None, + "date": None, + } + rootdirs.append(root) + root = os.path.dirname(root) # up a level + + if verbose: + print( + "Tried directories %s but none started with prefix %s" + % (str(rootdirs), parentdir_prefix) + ) + raise NotThisMethod("rootdir doesn't start with parentdir_prefix") + + +SHORT_VERSION_PY = """ +# This file was generated by 'versioneer.py' (0.23) from +# revision-control system data, or from the parent directory name of an +# unpacked source archive. Distribution tarballs contain a pre-generated copy +# of this file. + +import json + +version_json = ''' +%s +''' # END VERSION_JSON + + +def get_versions(): + return json.loads(version_json) +""" + + +def versions_from_file(filename): + """Try to determine the version from _version.py if present.""" + try: + with open(filename) as f: + contents = f.read() + except OSError: + raise NotThisMethod("unable to read _version.py") + mo = re.search(r"version_json = '''\n(.*)''' # END VERSION_JSON", contents, re.M | re.S) + if not mo: + mo = re.search(r"version_json = '''\r\n(.*)''' # END VERSION_JSON", contents, re.M | re.S) + if not mo: + raise NotThisMethod("no version_json in _version.py") + return json.loads(mo.group(1)) + + +def write_to_version_file(filename, versions): + """Write the given version number to the given _version.py file.""" + os.unlink(filename) + contents = json.dumps(versions, sort_keys=True, indent=1, separators=(",", ": ")) + with open(filename, "w") as f: + f.write(SHORT_VERSION_PY % contents) + + print("set %s to '%s'" % (filename, versions["version"])) + + +def plus_or_dot(pieces): + """Return a + if we don't already have one, else return a .""" + if "+" in pieces.get("closest-tag", ""): + return "." + return "+" + + +def render_pep440(pieces): + """Build up version string, with post-release "local version identifier". + + Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you + get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty + + Exceptions: + 1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += plus_or_dot(pieces) + rendered += "%d.g%s" % (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + else: + # exception #1 + rendered = "0+untagged.%d.g%s" % (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + return rendered + + +def render_pep440_branch(pieces): + """TAG[[.dev0]+DISTANCE.gHEX[.dirty]] . + + The ".dev0" means not master branch. Note that .dev0 sorts backwards + (a feature branch will appear "older" than the master branch). + + Exceptions: + 1: no tags. 0[.dev0]+untagged.DISTANCE.gHEX[.dirty] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += plus_or_dot(pieces) + rendered += "%d.g%s" % (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + else: + # exception #1 + rendered = "0" + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += "+untagged.%d.g%s" % (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + return rendered + + +def pep440_split_post(ver): + """Split pep440 version string at the post-release segment. + + Returns the release segments before the post-release and the + post-release version number (or -1 if no post-release segment is present). + """ + vc = str.split(ver, ".post") + return vc[0], int(vc[1] or 0) if len(vc) == 2 else None + + +def render_pep440_pre(pieces): + """TAG[.postN.devDISTANCE] -- No -dirty. + + Exceptions: + 1: no tags. 0.post0.devDISTANCE + """ + if pieces["closest-tag"]: + if pieces["distance"]: + # update the post release segment + tag_version, post_version = pep440_split_post(pieces["closest-tag"]) + rendered = tag_version + if post_version is not None: + rendered += ".post%d.dev%d" % (post_version + 1, pieces["distance"]) + else: + rendered += ".post0.dev%d" % (pieces["distance"]) + else: + # no commits, use the tag as the version + rendered = pieces["closest-tag"] + else: + # exception #1 + rendered = "0.post0.dev%d" % pieces["distance"] + return rendered + + +def render_pep440_post(pieces): + """TAG[.postDISTANCE[.dev0]+gHEX] . + + The ".dev0" means dirty. Note that .dev0 sorts backwards + (a dirty tree will appear "older" than the corresponding clean one), + but you shouldn't be releasing software with -dirty anyways. + + Exceptions: + 1: no tags. 0.postDISTANCE[.dev0] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += ".post%d" % pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + rendered += plus_or_dot(pieces) + rendered += "g%s" % pieces["short"] + else: + # exception #1 + rendered = "0.post%d" % pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + rendered += "+g%s" % pieces["short"] + return rendered + + +def render_pep440_post_branch(pieces): + """TAG[.postDISTANCE[.dev0]+gHEX[.dirty]] . + + The ".dev0" means not master branch. + + Exceptions: + 1: no tags. 0.postDISTANCE[.dev0]+gHEX[.dirty] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += ".post%d" % pieces["distance"] + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += plus_or_dot(pieces) + rendered += "g%s" % pieces["short"] + if pieces["dirty"]: + rendered += ".dirty" + else: + # exception #1 + rendered = "0.post%d" % pieces["distance"] + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += "+g%s" % pieces["short"] + if pieces["dirty"]: + rendered += ".dirty" + return rendered + + +def render_pep440_old(pieces): + """TAG[.postDISTANCE[.dev0]] . + + The ".dev0" means dirty. + + Exceptions: + 1: no tags. 0.postDISTANCE[.dev0] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += ".post%d" % pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + else: + # exception #1 + rendered = "0.post%d" % pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + return rendered + + +def render_git_describe(pieces): + """TAG[-DISTANCE-gHEX][-dirty]. + + Like 'git describe --tags --dirty --always'. + + Exceptions: + 1: no tags. HEX[-dirty] (note: no 'g' prefix) + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"]: + rendered += "-%d-g%s" % (pieces["distance"], pieces["short"]) + else: + # exception #1 + rendered = pieces["short"] + if pieces["dirty"]: + rendered += "-dirty" + return rendered + + +def render_git_describe_long(pieces): + """TAG-DISTANCE-gHEX[-dirty]. + + Like 'git describe --tags --dirty --always -long'. + The distance/hash is unconditional. + + Exceptions: + 1: no tags. HEX[-dirty] (note: no 'g' prefix) + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + rendered += "-%d-g%s" % (pieces["distance"], pieces["short"]) + else: + # exception #1 + rendered = pieces["short"] + if pieces["dirty"]: + rendered += "-dirty" + return rendered + + +def render(pieces, style): + """Render the given version pieces into the requested style.""" + if pieces["error"]: + return { + "version": "unknown", + "full-revisionid": pieces.get("long"), + "dirty": None, + "error": pieces["error"], + "date": None, + } + + if not style or style == "default": + style = "pep440" # the default + + if style == "pep440": + rendered = render_pep440(pieces) + elif style == "pep440-branch": + rendered = render_pep440_branch(pieces) + elif style == "pep440-pre": + rendered = render_pep440_pre(pieces) + elif style == "pep440-post": + rendered = render_pep440_post(pieces) + elif style == "pep440-post-branch": + rendered = render_pep440_post_branch(pieces) + elif style == "pep440-old": + rendered = render_pep440_old(pieces) + elif style == "git-describe": + rendered = render_git_describe(pieces) + elif style == "git-describe-long": + rendered = render_git_describe_long(pieces) + else: + raise ValueError("unknown style '%s'" % style) + + return { + "version": rendered, + "full-revisionid": pieces["long"], + "dirty": pieces["dirty"], + "error": None, + "date": pieces.get("date"), + } + + +class VersioneerBadRootError(Exception): + """The project root directory is unknown or missing key files.""" + + +def get_versions(verbose=False): + """Get the project version from whatever source is available. + + Returns dict with two keys: 'version' and 'full'. + """ + if "versioneer" in sys.modules: + # see the discussion in cmdclass.py:get_cmdclass() + del sys.modules["versioneer"] + + root = get_root() + cfg = get_config_from_root(root) + + assert cfg.VCS is not None, "please set [versioneer]VCS= in setup.cfg" + handlers = HANDLERS.get(cfg.VCS) + assert handlers, "unrecognized VCS '%s'" % cfg.VCS + verbose = verbose or cfg.verbose + assert cfg.versionfile_source is not None, "please set versioneer.versionfile_source" + assert cfg.tag_prefix is not None, "please set versioneer.tag_prefix" + + versionfile_abs = os.path.join(root, cfg.versionfile_source) + + # extract version from first of: _version.py, VCS command (e.g. 'git + # describe'), parentdir. This is meant to work for developers using a + # source checkout, for users of a tarball created by 'setup.py sdist', + # and for users of a tarball/zipball created by 'git archive' or github's + # download-from-tag feature or the equivalent in other VCSes. + + get_keywords_f = handlers.get("get_keywords") + from_keywords_f = handlers.get("keywords") + if get_keywords_f and from_keywords_f: + try: + keywords = get_keywords_f(versionfile_abs) + ver = from_keywords_f(keywords, cfg.tag_prefix, verbose) + if verbose: + print("got version from expanded keyword %s" % ver) + return ver + except NotThisMethod: + pass + + try: + ver = versions_from_file(versionfile_abs) + if verbose: + print("got version from file %s %s" % (versionfile_abs, ver)) + return ver + except NotThisMethod: + pass + + from_vcs_f = handlers.get("pieces_from_vcs") + if from_vcs_f: + try: + pieces = from_vcs_f(cfg.tag_prefix, root, verbose) + ver = render(pieces, cfg.style) + if verbose: + print("got version from VCS %s" % ver) + return ver + except NotThisMethod: + pass + + try: + if cfg.parentdir_prefix: + ver = versions_from_parentdir(cfg.parentdir_prefix, root, verbose) + if verbose: + print("got version from parentdir %s" % ver) + return ver + except NotThisMethod: + pass + + if verbose: + print("unable to compute version") + + return { + "version": "0+unknown", + "full-revisionid": None, + "dirty": None, + "error": "unable to compute version", + "date": None, + } + + +def get_version(): + """Get the short version string for this project.""" + return get_versions()["version"] + + +def get_cmdclass(cmdclass=None): + """Get the custom setuptools subclasses used by Versioneer. + + If the package uses a different cmdclass (e.g. one from numpy), it + should be provide as an argument. + """ + if "versioneer" in sys.modules: + del sys.modules["versioneer"] + # this fixes the "python setup.py develop" case (also 'install' and + # 'easy_install .'), in which subdependencies of the main project are + # built (using setup.py bdist_egg) in the same python process. Assume + # a main project A and a dependency B, which use different versions + # of Versioneer. A's setup.py imports A's Versioneer, leaving it in + # sys.modules by the time B's setup.py is executed, causing B to run + # with the wrong versioneer. Setuptools wraps the sub-dep builds in a + # sandbox that restores sys.modules to it's pre-build state, so the + # parent is protected against the child's "import versioneer". By + # removing ourselves from sys.modules here, before the child build + # happens, we protect the child from the parent's versioneer too. + # Also see https://github.com/python-versioneer/python-versioneer/issues/52 + + cmds = {} if cmdclass is None else cmdclass.copy() + + # we add "version" to setuptools + from setuptools import Command + + class cmd_version(Command): + description = "report generated version string" + user_options = [] + boolean_options = [] + + def initialize_options(self): + pass + + def finalize_options(self): + pass + + def run(self): + vers = get_versions(verbose=True) + print("Version: %s" % vers["version"]) + print(" full-revisionid: %s" % vers.get("full-revisionid")) + print(" dirty: %s" % vers.get("dirty")) + print(" date: %s" % vers.get("date")) + if vers["error"]: + print(" error: %s" % vers["error"]) + + cmds["version"] = cmd_version + + # we override "build_py" in setuptools + # + # most invocation pathways end up running build_py: + # distutils/build -> build_py + # distutils/install -> distutils/build ->.. + # setuptools/bdist_wheel -> distutils/install ->.. + # setuptools/bdist_egg -> distutils/install_lib -> build_py + # setuptools/install -> bdist_egg ->.. + # setuptools/develop -> ? + # pip install: + # copies source tree to a tempdir before running egg_info/etc + # if .git isn't copied too, 'git describe' will fail + # then does setup.py bdist_wheel, or sometimes setup.py install + # setup.py egg_info -> ? + + # pip install -e . and setuptool/editable_wheel will invoke build_py + # but the build_py command is not expected to copy any files. + + # we override different "build_py" commands for both environments + if "build_py" in cmds: + _build_py = cmds["build_py"] + else: + from setuptools.command.build_py import build_py as _build_py + + class cmd_build_py(_build_py): + def run(self): + root = get_root() + cfg = get_config_from_root(root) + versions = get_versions() + _build_py.run(self) + if getattr(self, "editable_mode", False): + # During editable installs `.py` and data files are + # not copied to build_lib + return + # now locate _version.py in the new build/ directory and replace + # it with an updated value + if cfg.versionfile_build: + target_versionfile = os.path.join(self.build_lib, cfg.versionfile_build) + print("UPDATING %s" % target_versionfile) + write_to_version_file(target_versionfile, versions) + + cmds["build_py"] = cmd_build_py + + if "build_ext" in cmds: + _build_ext = cmds["build_ext"] + else: + from setuptools.command.build_ext import build_ext as _build_ext + + class cmd_build_ext(_build_ext): + def run(self): + root = get_root() + cfg = get_config_from_root(root) + versions = get_versions() + _build_ext.run(self) + if self.inplace: + # build_ext --inplace will only build extensions in + # build/lib<..> dir with no _version.py to write to. + # As in place builds will already have a _version.py + # in the module dir, we do not need to write one. + return + # now locate _version.py in the new build/ directory and replace + # it with an updated value + target_versionfile = os.path.join(self.build_lib, cfg.versionfile_build) + if not os.path.exists(target_versionfile): + print( + f"Warning: {target_versionfile} does not exist, skipping " + "version update. This can happen if you are running build_ext " + "without first running build_py." + ) + return + print("UPDATING %s" % target_versionfile) + write_to_version_file(target_versionfile, versions) + + cmds["build_ext"] = cmd_build_ext + + if "cx_Freeze" in sys.modules: # cx_freeze enabled? + from cx_Freeze.dist import build_exe as _build_exe + + # nczeczulin reports that py2exe won't like the pep440-style string + # as FILEVERSION, but it can be used for PRODUCTVERSION, e.g. + # setup(console=[{ + # "version": versioneer.get_version().split("+", 1)[0], # FILEVERSION + # "product_version": versioneer.get_version(), + # ... + + class cmd_build_exe(_build_exe): + def run(self): + root = get_root() + cfg = get_config_from_root(root) + versions = get_versions() + target_versionfile = cfg.versionfile_source + print("UPDATING %s" % target_versionfile) + write_to_version_file(target_versionfile, versions) + + _build_exe.run(self) + os.unlink(target_versionfile) + with open(cfg.versionfile_source, "w") as f: + LONG = LONG_VERSION_PY[cfg.VCS] + f.write( + LONG + % { + "DOLLAR": "$", + "STYLE": cfg.style, + "TAG_PREFIX": cfg.tag_prefix, + "PARENTDIR_PREFIX": cfg.parentdir_prefix, + "VERSIONFILE_SOURCE": cfg.versionfile_source, + } + ) + + cmds["build_exe"] = cmd_build_exe + del cmds["build_py"] + + if "py2exe" in sys.modules: # py2exe enabled? + from py2exe.distutils_buildexe import py2exe as _py2exe + + class cmd_py2exe(_py2exe): + def run(self): + root = get_root() + cfg = get_config_from_root(root) + versions = get_versions() + target_versionfile = cfg.versionfile_source + print("UPDATING %s" % target_versionfile) + write_to_version_file(target_versionfile, versions) + + _py2exe.run(self) + os.unlink(target_versionfile) + with open(cfg.versionfile_source, "w") as f: + LONG = LONG_VERSION_PY[cfg.VCS] + f.write( + LONG + % { + "DOLLAR": "$", + "STYLE": cfg.style, + "TAG_PREFIX": cfg.tag_prefix, + "PARENTDIR_PREFIX": cfg.parentdir_prefix, + "VERSIONFILE_SOURCE": cfg.versionfile_source, + } + ) + + cmds["py2exe"] = cmd_py2exe + + # sdist farms its file list building out to egg_info + if "egg_info" in cmds: + _sdist = cmds["egg_info"] + else: + from setuptools.command.egg_info import egg_info as _egg_info + + class cmd_egg_info(_egg_info): + def find_sources(self): + # egg_info.find_sources builds the manifest list and writes it + # in one shot + super().find_sources() + + # Modify the filelist and normalize it + root = get_root() + cfg = get_config_from_root(root) + self.filelist.append("versioneer.py") + if cfg.versionfile_source: + # There are rare cases where versionfile_source might not be + # included by default, so we must be explicit + self.filelist.append(cfg.versionfile_source) + self.filelist.sort() + self.filelist.remove_duplicates() + + # The write method is hidden in the manifest_maker instance that + # generated the filelist and was thrown away + # We will instead replicate their final normalization (to unicode, + # and POSIX-style paths) + from setuptools import unicode_utils + + normalized = [ + unicode_utils.filesys_decode(f).replace(os.sep, "/") for f in self.filelist.files + ] + + manifest_filename = os.path.join(self.egg_info, "SOURCES.txt") + with open(manifest_filename, "w") as fobj: + fobj.write("\n".join(normalized)) + + cmds["egg_info"] = cmd_egg_info + + # we override different "sdist" commands for both environments + if "sdist" in cmds: + _sdist = cmds["sdist"] + else: + from setuptools.command.sdist import sdist as _sdist + + class cmd_sdist(_sdist): + def run(self): + versions = get_versions() + self._versioneer_generated_versions = versions + # unless we update this, the command will keep using the old + # version + self.distribution.metadata.version = versions["version"] + return _sdist.run(self) + + def make_release_tree(self, base_dir, files): + root = get_root() + cfg = get_config_from_root(root) + _sdist.make_release_tree(self, base_dir, files) + # now locate _version.py in the new base_dir directory + # (remembering that it may be a hardlink) and replace it with an + # updated value + target_versionfile = os.path.join(base_dir, cfg.versionfile_source) + print("UPDATING %s" % target_versionfile) + write_to_version_file(target_versionfile, self._versioneer_generated_versions) + + cmds["sdist"] = cmd_sdist + + return cmds + + +CONFIG_ERROR = """ +setup.cfg is missing the necessary Versioneer configuration. You need +a section like: + + [versioneer] + VCS = git + style = pep440 + versionfile_source = src/myproject/_version.py + versionfile_build = myproject/_version.py + tag_prefix = + parentdir_prefix = myproject- + +You will also need to edit your setup.py to use the results: + + import versioneer + setup(version=versioneer.get_version(), + cmdclass=versioneer.get_cmdclass(), ...) + +Please read the docstring in ./versioneer.py for configuration instructions, +edit setup.cfg, and re-run the installer or 'python versioneer.py setup'. +""" + +SAMPLE_CONFIG = """ +# See the docstring in versioneer.py for instructions. Note that you must +# re-run 'versioneer.py setup' after changing this section, and commit the +# resulting files. + +[versioneer] +#VCS = git +#style = pep440 +#versionfile_source = +#versionfile_build = +#tag_prefix = +#parentdir_prefix = + +""" + +OLD_SNIPPET = """ +from ._version import get_versions +__version__ = get_versions()['version'] +del get_versions +""" + +INIT_PY_SNIPPET = """ +from . import {0} +__version__ = {0}.get_versions()['version'] +""" + + +def do_setup(): + """Do main VCS-independent setup function for installing Versioneer.""" + root = get_root() + try: + cfg = get_config_from_root(root) + except (OSError, configparser.NoSectionError, configparser.NoOptionError) as e: + if isinstance(e, (OSError, configparser.NoSectionError)): + print("Adding sample versioneer config to setup.cfg", file=sys.stderr) + with open(os.path.join(root, "setup.cfg"), "a") as f: + f.write(SAMPLE_CONFIG) + print(CONFIG_ERROR, file=sys.stderr) + return 1 + + print(" creating %s" % cfg.versionfile_source) + with open(cfg.versionfile_source, "w") as f: + LONG = LONG_VERSION_PY[cfg.VCS] + f.write( + LONG + % { + "DOLLAR": "$", + "STYLE": cfg.style, + "TAG_PREFIX": cfg.tag_prefix, + "PARENTDIR_PREFIX": cfg.parentdir_prefix, + "VERSIONFILE_SOURCE": cfg.versionfile_source, + } + ) + + ipy = os.path.join(os.path.dirname(cfg.versionfile_source), "__init__.py") + if os.path.exists(ipy): + try: + with open(ipy, "r") as f: + old = f.read() + except OSError: + old = "" + module = os.path.splitext(os.path.basename(cfg.versionfile_source))[0] + snippet = INIT_PY_SNIPPET.format(module) + if OLD_SNIPPET in old: + print(" replacing boilerplate in %s" % ipy) + with open(ipy, "w") as f: + f.write(old.replace(OLD_SNIPPET, snippet)) + elif snippet not in old: + print(" appending to %s" % ipy) + with open(ipy, "a") as f: + f.write(snippet) + else: + print(" %s unmodified" % ipy) + else: + print(" %s doesn't exist, ok" % ipy) + ipy = None + + # Make VCS-specific changes. For git, this means creating/changing + # .gitattributes to mark _version.py for export-subst keyword + # substitution. + do_vcs_install(cfg.versionfile_source, ipy) + return 0 + + +def scan_setup_py(): + """Validate the contents of setup.py against Versioneer's expectations.""" + found = set() + setters = False + errors = 0 + with open("setup.py", "r") as f: + for line in f.readlines(): + if "import versioneer" in line: + found.add("import") + if "versioneer.get_cmdclass()" in line: + found.add("cmdclass") + if "versioneer.get_version()" in line: + found.add("get_version") + if "versioneer.VCS" in line: + setters = True + if "versioneer.versionfile_source" in line: + setters = True + if len(found) != 3: + print("") + print("Your setup.py appears to be missing some important items") + print("(but I might be wrong). Please make sure it has something") + print("roughly like the following:") + print("") + print(" import versioneer") + print(" setup( version=versioneer.get_version(),") + print(" cmdclass=versioneer.get_cmdclass(), ...)") + print("") + errors += 1 + if setters: + print("You should remove lines like 'versioneer.VCS = ' and") + print("'versioneer.versionfile_source = ' . This configuration") + print("now lives in setup.cfg, and should be removed from setup.py") + print("") + errors += 1 + return errors + + +if __name__ == "__main__": + cmd = sys.argv[1] + if cmd == "setup": + errors = do_setup() + errors += scan_setup_py() + if errors: + sys.exit(1) diff --git a/spec/latest/index.bs b/spec/latest/index.bs new file mode 100644 index 0000000..03224b2 --- /dev/null +++ b/spec/latest/index.bs @@ -0,0 +1,834 @@ + + +Introduction {#intro} +===================== + +The Binsparse Specification (name tentative) provides a cross-platform format +for efficiently storing data, particularly sparse multidimensional arrays, in +binary format. Binsparse is designed to be both a standalone and embeddable +format. It consists of two parts: + +- a JSON *descriptor* detailing the structure of the chosen binary storage format +- one or more *binary arrays*, each stored under a predefined dataset name based + on the format + +Both the descriptor and binary arrays are stored in a supported *binary container*. + +Definitions {#defs} +=================== + +Binsparse is intended to support multidimensional *sparse arrays*, meaning arrays +in which not every location has a value. We refer to each location in the array +with a value as a *stored value*. Stored values have associated with them a +*scalar value*, which is the value stored in that location in the array, and one +or more *indices*, which describe the location where the stored value is located +in the array. Some or all of these indices may be stored explicitly, or they may +be implicitly derived, depending on storage format. When stored explicitly, +indices are 0-based positive integers. + + +Binsparse JSON Descriptors {#descriptor} +======================================== + +Binsparse descriptors are key-value metadata that describe the binary format of sparse +data. The key-value data is namespaced as "binsparse" to avoid any conflict with other +metadata in the container. The required entries in the "binsparse" entry are listed +below. Optional attributes may be defined to hold additional metadata and must be stored +outside of the "binsparse" namespace. + +
+ +Example of a JSON descriptor for a compressed-sparse column (CSC) matrix with 10 +rows and 12 columns, containing float32 values, along with user-defined +attributes. + +```json +{ + "binsparse": { + "version": "0.1", + "format": "CSC", + "shape": [10, 12], + "data_types": { + "pointers_to_1": "uint64", + "indices_1": "uint64", + "values": "float32" + } + }, + "original_source": "https://url/of/original/file.mtx", + "author": "John Doe" +} +``` + +
+ +Version {#key_version} +---------------------- + +Version indicates the version of the Binsparse specification used here. +This is a two digit specifier of the form `major.minor`. +Any minor updates should be backwards compatible with the previous version, e.g. must be a superset of the previous versions within the major release series. +Major versions may break backwards compatibility. + +Shape {#key_shape} +------------------ + +The `shape` key must be present and shall define the shape of the sparse tensor. +It shall contain a JSON array of integers, with index `i` containing the size of +the `i`'th dimension. For matrices, index `0` shall contain the number of rows, +and index `1` shall contain the number of columns. For vectors, index `0` shall +contain the vector's dimension. + +Note: a matrix has shape [`number_of_rows`, `number_of_columns`] regardless of whether +the format orientation is row-wise or column-wise. + +Fill {#key_fill} +-------------------- +The `fill` key may be present. If the `fill` key is present, it shall have a +boolean value. If the value is true, it signifies the presence of a `fill_value` +array, whose single element defines the value at indices not specified +by the sparse tensor structure. + +Format {#key_format} +-------------------- + +The `format` key must be present and shall describe the binary storage format +of dense arrays used to represent the sparse array. The format +defined by the `format` key determines the named binary arrays that shall exist +in the binary storage container. + +### Pre-defined Formats ### {#predefined_formats} + +The following is a list of all pre-defined formats and the arrays that shall +be present in the binary container. `number_of_elements` refers to the number +of stored values, `number_of_rows` refers to the number of rows, and `number_of_columns` +refers to the number of columns. + +#### DVEC #### {#dvec_format} + +Dense Vector format + +: values +:: Array of size `number_of_elements` containing stored values. + +The element of the vector located at index `i` has scalar value +`values[i]`. + +#### DMATR #### {#dmatr_format} + +Row-Major Dense Matrix format + +: values +:: Array of size `number_of_elements` containing stored values. + +The element of the vector located at index `i, j` has scalar value +`values[i * number_of_columns + j]`. + +#### DMATC #### {#dmatc_format} + +Column-Major Dense Matrix format + +: values +:: Array of size `number_of_elements` containing stored values. + +The element of the vector located at index `i, j` has scalar value +`values[i + j * number_of_rows]`. + +#### DMAT #### {#DMAT_format} + +DMAT format is an alias for [[#dmatr_format]] format. + +#### CVEC #### {#cvec_format} + +Compressed Sparse Vector format + +: indices_0 +:: Array of size `number_of_elements` containing indices. +: values +:: Array of size `number_of_elements` containing stored values. + +The element of the vector located at index `indices_0[i]` has scalar value +`values[i]`. Elements shall be sorted by index and must not be duplicated. + +#### CSR #### {#csr_format} + +Compressed-Sparse Row format + +: pointers_to_1 +:: Array of size `number_of_rows + 1` containing start and end positions by row. +: indices_1 +:: Array of size `number_of_elements` containing 0-based column indices. +: values +:: Array of size `number_of_elements` containing stored values. + +The column indices of the stored values located in row `i` are located in the range +`[pointers_to_1[i], pointers_to_1[i+1])` in the `indices_1` array. The scalar values for +each of those stored values is stored in the corresponding index in the `values` array. + +Within a row, elements shall be sorted by column index and must not be duplicated. + +#### CSC #### {#csc_format} + +Compressed-Sparse Column format + +: pointers_to_1 +:: Array of size `number_of_columns + 1` containing start and end positions by column. +: indices_1 +:: Array of size `number_of_elements` containing 0-based row indices. +: values +:: Array of size `number_of_elements` containing stored values. + +The rows indices of the stored values located in column `j` are located in the range +`[pointers_to_1[j], pointers_to_1[j+1])` in the `indices_1` array. The scalar values for +each of those stored values is stored in the corresponding index in the `values` array. + +Within a column, elements shall be sorted by row index and must not be duplicated. + +#### DCSR #### {#dcsr_format} + +Doubly Compressed-Sparse Row format + +: indices_0 +:: Array of size `number_of_nonempty_rows` containing 0-based row indices corresponding + to positions within `pointers_to_1`. +: pointers_to_1 +:: Array of size `number_of_nonempty_rows + 1` containing start and end positions. +: indices_1 +:: Array of size `number_of_elements` containing 0-based column indices. +: values +:: Array of size `number_of_elements` containing stored values. + +DCSR is similar to CSR, except that rows which are entirely empty are not stored. `pointers_to_1` +contains no repeated values. Because the position within `pointers_to_1` no longer dictates the +corresponding row index, `indices_0` provides the row index. + +Rows shall be sorted and must not be duplicated. +Within each row, elements shall be sorted by column index and must not be duplicated. + +#### DCSC #### {#dcsc_format} + +Doubly Compressed-Sparse Column format + +: indices_0 +:: Array of size `number_of_nonempty_columns` containing 0-based column indices + corresponding to positions within `pointers_to_1`. +: pointers_to_1 +:: Array of size `number_of_nonempty_columns + 1` containing start and end positions. +: indices_1 +:: Array of size `number_of_elements` containing 0-based row indices. +: values +:: Array of size `number_of_elements` containing stored values. + +DCSC is similar to CSC, except that columns which are entirely empty are not stored. `pointers_to_1` +contains no repeated values. Because the position within `pointers_to_1` no longer dictates the +corresponding column index, `indices_0` provides the column index. + +Columns shall be sorted and not duplicated. +Within each column, elements shall be sorted by row index and must not be duplicated. + +#### COOR #### {#coor_format} + +Row-wise Coordinate format + +: indices_0 +:: Array of size `number_of_elements` containing 0-based row indices. +: indices_1 +:: Array of size `number_of_elements` containing 0-based column indices. +: values +:: Array of size `number_of_elements` containing stored values. + +Pairs of (row index, column index) shall be sorted first by row and then by column. +Pairs must not be duplicated. + +#### COOC #### {#cooc_format} + +Column-wise Coordinate format + +: indices_0 +:: Array of size `number_of_elements` containing 0-based column indices. +: indices_1 +:: Array of size `number_of_elements` containing 0-based row indices. +: values +:: Array of size `number_of_elements` containing stored values. + +Pairs of (column index, row index) shall be sorted first by column and then by row. +Pairs must not be duplicated. + +#### COO #### {#coo_format} + +Coordinate format is an alias for [[#coor_format]] format. + +### Version 2.0 only: Custom Formats ### {#custom_formats} + +The contents of this section will be finalized with the release of Binsparse +V2.0, and are subject to change until then. + +Binsparse describes custom multidimensional formats hierarchically. We can +understand these formats as arrays of arrays, where the parent array and +child arrays might use different formats. For example, we could have a dense +outer array which contains sparse inner arrays, so the first index would be +dense and the second index would be sparse. To achieve efficient storage, all +arrays in the same level are stored contiguously in a specialized datastructure +called a level. + +A level is a collection of zero or more arrays which all have the same format. +The elements of arrays in a level may be subarrays in a sublevel. The global +array we wish to store is represented by a level that holds a single root array. + +For example, the simplest level is the element format, which represents a +collection of scalars. We can represent a collection of dense vectors with a +dense level format. Each vector in the collection would be composed from +contiguous scalars in an element level (analogously to the numpy.stack +operator). We can represent a collection of sparse vectors using a sparse level. +The sparse level format represents sparse vectors by listing the locations of +nonzeros, and storing only the nonzero scalars inside an element level. + +In addition to storing scalars, dense and sparse levels may themselves store +multidimensional arrays. This leads to multiple ways to store sparse matrices +and tensors. For example, a dense vector of sparse vectors is equivalent to the +CSR matrix format, and a sparse vector of sparse vectors is equivalent to the +hypersparse DCSR matrix format. + +When defining a custom format, the outermost `subformat` key is defined as the +root level descriptor (a level which will only hold one array). If a level holds +many different arrays, we refer to the `p`th array as the array in position `p`. + +Levels are row-major by default (adding an outer level adds a row dimension). +The format descriptor may optionally define a `transpose` key, equal to a list of +the described dimensions in the order they should appear. If the tensor we wish +to represent is `A` and the tensor described by the format descriptor is `B`, +then `A[i_1, ..., i_n] = B[i_(transpose[1]), ..., i_(transpose[n])]`. `transpose` must +be a permutation. + +If the format key is a dictionary, the `level` key must be present and shall +describe the storage format of the level used to represent the sparse array. + +The level descriptors are dictionaries defined as follows: + +#### Element #### {#element_level} + +If the level key is "element", the level represents zero or more scalars. + +: values +:: Array of size `number_of_positions` whose `p`th element holds the value of the scalar at position `p`. + +#### Dense #### {#dense_level} + +If the level key is "dense", the `subformat` key must be present. The `rank` +key must be present, and set to an integer `r` greater than or equal to 1. The +dense level represents zero or more r-dimensional dense arrays whose elements +are themselves arrays specified by `subformat`. For example, a dense level +of +rank 2 represents a collection of dense matrices of subarrays. + +Assuming that the level describes arrays of shape `I_0, ..., I_(N - 1)`, the +array at position `p` in a dense level of rank `r` is an array whose slice + +`A[i_0, ..., i_(r - 1), :, ..., :]` + +is described by the row-major position + +`q = (((((p * I_0) + i_0) * I_1) + i_1) * I_2 + i_2) * ... + i_(r - 1)` + +of the sublevel. + +#### Sparse #### {#sparse_level} + +If the level key is "sparse", the `subformat` key must be present. The +`rank` key must be present, and set to an integer `r` greater than or equal to +`1`. The sparse level represents zero or more `r`-dimensional sparse arrays +whose non-implicit elements are themselves arrays specified by `subformat`. For +example, a sparse level of rank 1 represents a collection of sparse vectors of +subarrays. + +Assume that this level represents `n`-dimensional subarrays and the root array +is `N`-dimensional. The sparse level implies the following binary arrays are +present: + +: pointers_to_(N - n) +:: Array of size `number_of_positions + 1` whose 1st element is equal to `0` and whose `p + 1`th element is equal to the sum of `pointers_to_(N - n)[p]` and the number of explicitly represented slices in the `p`th position. + +: indices_(N - n), ..., indices(N - n + r - 1) +:: There are `r` such arrays. When `A[i_0, ..., i_(r - 1), :, ..., :]` is explicitly represented by the subarray in position `q`, `indices_(N-n+s)[q] = i_s`. The arrays must be ordered such that the tuples `(indices_(N-n)[q], ..., indices_(N-n+r-1)[q])` are unique and appear in lexicographic order for all `q` in each range `pointers_to_(N-n)[p] <= q < pointers_to_(N-n)[p + 1]`. This array must contain no other elements. + +Special note: If the sparse level is the root level, the `pointers` array should +be ommitted, as its first value will be `0` and its last value will be the +length of any of the `indices` arrays in this level. + + +### Equivalent Formats ### {#equivalent_formats} + +The following formats are equivalent + +#### DVEC #### {#dvec_format_equiv} + +```json +"format": { + "subformat": { + "level": "dense", + "rank": 1, + "subformat": { + "level": "element", + } + } +} +``` + +#### DMATR #### {#dmatr_format_equiv} + +```json +"format": { + "subformat": { + "level": "dense", + "rank": 1, + "subformat": { + "level": "dense", + "rank": 1, + "subformat": { + "level": "element", + } + } + } +} +``` + +#### DMATC #### {#dmatr_format_equiv} + +```json +"format": { + "transpose": [1, 0], + "subformat": { + "level": "dense", + "rank": 1, + "subformat": { + "level": "dense", + "rank": 1, + "subformat": { + "level": "element", + } + } + } +} +``` + +#### CVEC #### {#cvec_format_equiv} + +```json +"format": { + "subformat": { + "level": "sparse", + "rank": 1, + "subformat": { + "level": "element", + } + } +} +``` + +#### CSR #### {#csr_format_equiv} + +```json +"format": { + "subformat": { + "level": "dense", + "rank": 1, + "subformat": { + "level": "sparse", + "rank": 1, + "subformat": { + "level": "element", + } + } + } +} +``` + +#### CSC #### {#csc_format_equiv} + +```json +"format": { + "transpose": [1, 0], + "subformat": { + "level": "dense", + "rank": 1, + "subformat": { + "level": "sparse", + "rank": 1, + "subformat": { + "level": "element", + } + } + } +} +``` + +#### DCSR #### {#dcsr_format_equiv} + +```json +"format": { + "subformat": { + "level": "sparse", + "rank": 1, + "subformat": { + "level": "sparse", + "rank": 1, + "subformat": { + "level": "element", + } + } + } +} +``` + +#### DCSC #### {#dcsc_format_equiv} + +```json +"format": { + "transpose": [1, 0], + "subformat": { + "level": "sparse", + "rank": 1, + "subformat": { + "level": "sparse", + "rank": 1, + "subformat": { + "level": "element", + } + } + } +} +``` + +#### COOR #### {#coor_format_equiv} + +```json +"format": { + "subformat": { + "level": "sparse", + "rank": 2, + "subformat": { + "level": "element", + } + } +} +``` + +#### COOC #### {#cooc_format_equiv} + +Column-wise Coordinate format + +```json +"format": { + "transpose": [1, 0], + "subformat": { + "level": "sparse", + "rank": 2, + "subformat": { + "level": "element", + } + } +} +``` + +Data Types {#key_data_types} +---------------------------- + +The `data_types` key must be present and shall define the data types of all required +arrays based on the [[#key_format]]. The data type declares the type of both the +on-disk array as well as the in-memory array. + +For a given [[#key_format]], all named binary arrays for that format shall have a +corresponding name in `data_types`. + +The following strings shall be used to describe data types: +: "uint8" +:: unsigned 8-bit integer +: "uint16" +:: unsigned 16-bit integer +: "uint32" +:: unsigned 32-bit integer +: "uint64" +:: unsigned 64-bit integer +: "int8" +:: signed 8-bit integer +: "int16" +:: signed 16-bit integer +: "int32" +:: signed 32-bit integer +: "int64" +:: signed 64-bit integer +: "float32" +:: IEEE binary32 floating point number +: "float64" +:: IEEE binary64 floating point number +: "bint8" +:: An unsigned 8-bit integer, to be reinterpreted as a Boolean number, however + that is represented in the host language. The value 0 shall map to false and the + value 1 shall map to true. When parsing, implementations may choose to interpret + values other than 0 or 1 as true, or throw an error. + +## Value Modifiers ## {#value_modifiers} + +When the value array is meant to be reinterpreted before reading, a special bracket syntax is +provided to indicate modifications to the underlying element level. + +### Complex Values (complex) ### {#complex_level} + +When a value array is composed of alternating real and imaginary components of +complex numbers, the type is written as `complex[]`. For example, a value +array of complex `float64` would have a datatype of `complex[float64]` The real +component of the `i`th element in the modified array shall be stored at position +`2i` in the original array, and the imaginary component of the `i`th element in +the modified array shall be at position `2i + 1` in the underlying array. +The `complex` value modifier may only be used with the types `float32` and +`float64`. + +### All Values the Same (ISO) ### {#iso_level} + +When all values of a sparse array are the same identical value, the type is +written as `iso[]`. This indicates that the array will store only a single +element which is common to all stored indices. All elements in the modified +array shall be stored at position 0 of the underlying array. + +
+ +Example of a CSR Matrix whose values are all 7. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
01234
0...7.
1.7..7
2.....
3.77..
4...7.
+ +```json +{ + "version": "0.1", + "format": "CSR", + "shape": [5, 5], + "data_types": { + "pointers_to_1": "uint64", + "indices_1": "uint64", + "values": "iso[int8]" + } +} +``` + +- `pointers_to_1` = [0, 1, 3, 3, 5, 6] +- `indices_1` = [3, 1, 4, 1, 2, 3] +- `values` = [7] + +
+ +Note: Structure-only matrices (allowed in matrix market format) can be stored + using this technique with a value of 1. This adds only a small amount of + overhead while describing essentially the same matrix. + +Structure {#key_structure} +-------------------------- +The `structure` key, if present, denotes a special matrix structure in which +only one triangle of the matrix is stored and the structure and values in the +other triangle are inferred. + +### Pre-Defined Structures ### {#predefined_structure} + +The follow pre-defined values can be supplied for the `structure` key to indicate +the structure of the matrix. + +#### symmetric_lower #### {#symmetric_lower_structure} + +The `symmetric_lower` value indicates that the matrix has a symmetric structure +with only the lower triangle stored. For all matrix entries with row and column +indices `i,j` and value `v`, `i >= j`. If `i != j`, the entry implies the +presence of an entry at row and column index `j,i` with value `v`. + +#### symmetric_upper #### {#symmetric_upper_structure} + +The `symmetric_upper` value indicates that the matrix has a symmetric structure +with only the upper triangle stored. For all matrix entries with row and column +indices `i,j` and value `v`, `i <= j`. If `i != j`, the entry implies the +presence of an entry at row and column index `j,i` with value `v`. + +#### hermitian_lower #### {#hermitian_lower_structure} + +The `hermitian_lower` value indicates that the matrix has a Hermitian structure +with only the lower triangle stored. For all matrix entries with row and column +indices `i,j` and value `v`, `i >= j`. If `i != j`, the entry implies the +presence of an entry at row and column index `j,i` with a value equal to the +complex conjugate of `v`. The matrix's value type must be complex. + +#### hermitian_upper #### {#hermitian_upper_structure} + +The `hermitian_upper` value indicates that the matrix has a Hermitian structure +with only the upper triangle stored. For all matrix entries with row and column +indices `i,j` and value `v`, `i <= j`. If `i != j`, the entry implies the +presence of an entry at row and column index `j,i` with a value equal to the +complex conjugate of `v`. The matrix's value type must be complex. + +#### skew_symmetric_lower #### {#skew_symmetric_lower_structure} + +The `skew_symmetric_lower` value indicates that the matrix has a skew-symmetric structure +with only the lower triangle stored. For all matrix entries with row and column +indices `i,j` and value `v`, `i >= j`. If `i != j`, the entry implies the +presence of an entry at row and column index `j,i` with value `-v`. + +#### skew_symmetric_upper #### {#skew_symmetric_upper_structure} + +The `symmetric_upper` value indicates that the matrix has a skew-symmetric structure +with only the upper triangle stored. For all matrix entries with row and column +indices `i,j` and value `v`, `i <= j`. If `i != j`, the entry implies the +presence of an entry at row and column index `j,i` with value `-v`. + +
+ +Example of a symmetric CSR matrix. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
01234
01....
129...
27.2..
3.2.3.
4..3.7
+ +```json +{ + "version": "0.1", + "format": "CSR", + "shape": [5, 5], + "structure": "symmetric_lower", + "data_types": { + "pointers_to_1": "uint64", + "indices_1": "uint64", + "values": "int8" + } +} +``` + +- `pointers_to_1` = [0, 1, 3, 5, 7, 9] +- `indices_1` = [0, 0, 1, 0, 2, 1, 3, 2, 4] +- `values` = [1, 2, 9, 7, 2, 2, 3, 3, 7] + +
+ +Binary Containers {#binary_container} +===================================== +Binary containers must store binary arrays in a standardized, cross-platform +manner, using the corresponding dataset names previously defined. + +Supported Binary Containers {#supported_containers} +--------------------------------------------------- + +Currently supported binary containers include HDF5 and NetCDF (but should include more). +