pymc-devs / pymc-devs/pytensor

Add numba dispatch for `sort` and `argsort`

Open
#1,151 0 comments 1 reaction 0 assignees View on GitHub

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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.