pymc-devs / pymc-devs/pytensor
Add numba dispatch for `sort` and `argsort`
Open
Nobody has claimed this yet.
beginner friendly
enhancement
numba
NumPy compatibility
- Dominant language
- Python
- Stars
- 644
- Forks
- 208
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 16
Description
Description
import pytensor.tensor as pt
import pytensor
x = pt.dvector('x')
y = pt.sort(x)
f = pytensor.function([x], y, mode='NUMBA')
We can support this graph when sort = "quicksort", so we should. Numba does not support the kind argument for np.sort. For argsort, the kind argument is support for quicksort and mergesort, so we can support those.
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 at the pt.sort and pt.argsort graphs in the example and trace the NUMBA-mode dispatch path for these operations. Confirm completion by compiling and evaluating sort with quicksort, plus argsort with quicksort and mergesort, while preserving the stated limitation on np.sort's kind argument.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100