pymc-devs / pymc-devs/pytensor
Use numpy C-API einsum for unoptimized Einsum
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 644
- Forks
- 208
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 16
Description
Description
When Einsum can't be optimized (because we don't know the static shapes) it stays as an OpFromGraph. We could replace it by a COp (as a cxx_only rewrite) in this case, that calls the numpy C function:
https://numpy.org/devdocs/reference/c-api/array.html#c.PyArray_EinsteinSum
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the einsum rewrite in pytensor/tensor/rewriting/einsum.py, especially lines 39-53, and review NumPy's PyArray_EinsteinSum C-API documentation. Determine how the unoptimized OpFromGraph can be replaced by a cxx_only COp. Done means the unoptimized case calls the NumPy C function while preserving the einsum behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- compilers, performance
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100