pymc-devs / pymc-devs/pytensor
Scan NIT-SOT with 0 steps have wrong shape
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 644
- Forks
- 208
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 16
Description
Description
import pytensor
import pytensor.tensor as pt
x0 = pt.vector("x0")
n = pt.iscalar("n")
outs, _ = pytensor.scan(lambda xtm1: (xtm1 + 1, xtm1), outputs_info=[x0, None], n_steps=n)
fn = pytensor.function([n, x0], outs)
fn(n=0, x0=[1, 2, 3])
# [array([], shape=(0, 3), dtype=float64),
# array([], shape=(0, 0), dtype=float64)]
Unless the nitsot have static output shape I don't think we can figure out the correct shape without evaluating the function atleast once. We should raise or add some extra logic to handle that case.
Originally Scan didn't allow 0 steps, that was relaxed in https://github.com/aesara-devs/aesara/pull/741
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
Reproduce the reported case using pytensor.scan with n_steps=0 and inspect the scan shape-inference path that handles the NIT-SOT output. Determine whether the intended behavior is to infer the shape or raise an error, then add a regression test covering the zero-step result and verify the reported output shapes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 38/100