pydata / pydata/sparse

Enh: Request for the tensor Contraction with high order sparse tensor

Open
#897 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
668
Forks
141
Avg merge
2d 8h
Merged PRs (30d)
4

Description

Please describe the purpose of the new feature or describe the problem to solve.

In the numerical simulation, especailly the reduce order model, we need to deal with a high order sparse tensor. For example, we consider a 4th-order sparse tensor A with shape (100, 100, 200, 200). We multiply A along its 4th axis(l) with a vector B of shape (200,) to obtain a 3rd-order tensor C of shape (100, 100, 200). We do not have appropriate tool to deal with such a high order sparse tensor.

Suggest a solution if possible.

For tensor A, we have coords = [i,j,k,l] and values. we can get C with sparse.COO(newcoords = [i,j,k], newvalues = values*B[l], shape=(A.shape[0], A.shape[1], A.shape[2] ).

If you have tried alternatives, please describe them below.

No response

Additional information that may help us understand your needs.

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the sparse.COO entry point and reviewing how existing sparse tensor operations handle coordinates, values, shapes, and axis arguments. Define the contraction behavior for a high-order tensor and vector, then add coverage demonstrating the stated 4th-axis example produces the expected 3rd-order result.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.