pymc-devs / pymc-devs/pytensor
Investigate infer_shape database
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 644
- Forks
- 208
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 16
Description
Description
This includes some rewrites that get called to figure out static shape for ops whose shapes depend on numerical values (not just their shapes), like Alloc / RandomVariable(size=...), and likely some more. They serve to figure out static shape and (more critical) broadcastability.
However the rewrites are chosen semi-hazardly. We should do a proper investigation of the minimum subset needed. I suspect we sometimes end up doing more work to arrive at the same solution. Or ordering may be suboptimal, like if we have shape(x) where x has static shape, we should run the rewrite that replaces it by static shape first, and not spend cycles rewriting x.
Then the question of including or excluding "shape_unsafe" rewrites.
This is important to get right, because when rewriting graphs with these operations, the inner rewrite pass will be called every time we create such nodes.
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 locating the infer_shape database and the inner rewrite pass that handles nodes such as Alloc and RandomVariable(size=...). Trace which rewrites are selected, their ordering, and whether shape_unsafe rewrites are included. Done means identifying and validating the minimum rewrite subset needed for static shape and broadcastability.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100