inducer / inducer/pytato

CSR-based sparse arrays?

Open
#211 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
15
Forks
16
Avg merge
17m
Merged PRs (30d)
1

Description

@inducer @kaushikcfd As discussed earlier today, the motivation is to extend the syntax to support batching across a sparse array.

For example, given an expression for per-box map (I am using python syntax to represent expression IOs):
```python
def per_box_expr(box_data: Array[dtype, (ndim_in, _n_box_points)]
) -> Array[dtype, (ndim_out, _n_box_points)]:
...
return per_box_output
```
A "CSR batching" here means applying the per-box map to a list of boxes with inhomogeneous point counts, which does the equivalent of the following:
```python
def csr_apply(
expr: Array[dtype, (ndim_out, _n_box_points)],
data_lists: Array[dtype, (ndim_in, n_total_points)],
data_starts: Array[int, (n_boxes + 1, )],
axis: int=0) -> Array[dtype, (ndim_out, n_total_points)]:

# this specifies the computation to be carried out, not a valid implementation
output = Array(dtype, (ndim_out, n_total_points))
for ib in range(n_boxes):
start, stop = (data_starts[ib], data_starts[ib+1])
box_data = data_lists[:, start:stop]
output[:, start:stop] = per_box_expr(box_data)

return output
```
Note that `start, stop, _n_box_points` needs to be special placeholders in order to handle data-dependency.

@kaushikcfd also suggested a more general interface by supplying CSR arrays similar interface to normal arrays, and add the equivalence of `numpy.apply_along_axis` support for arrays.

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue names no files, tests, or entry points. Start by locating the existing array syntax and batching implementation, then compare it with the CSR examples and the proposed numpy.apply_along_axis-style interface; the work is done when a concrete supported interface and its behavior for inhomogeneous point counts are defined and implemented.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
backend-api-design, data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.