pytensor icon indicating copy to clipboard operation
pytensor copied to clipboard

Scan NIT-SOT with 0 steps have wrong shape

Open ricardoV94 opened this issue 9 months ago • 0 comments

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

ricardoV94 avatar Mar 12 '25 09:03 ricardoV94