pymc-devs / pytensor

PyTensor allows you to define, optimize, and efficiently evaluate mathematical expressions involving multi-dimensional arrays.

Home Page:https://pytensor.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Get rid of join view flag

ricardoV94 opened this issue · comments

Description

Join has a view flag that allows it to work inplace in one of the inputs if all the remaining ones have length 0 (are empty) along the axis. This happens at eval time, but pytensor needs to know the candidate input in advance with the view flag.

The only place where this is used is in scan_checkpoints:

join = Join(view=0)

Funnily enough that code branch is completely broken, the code was never tested apparently. See a fix in: #754

Unlike theano, we have more static shapes than 1/None, so I suggest we get rid of this flag. We can have a rewrite that removes inputs with shape 0 along the axis from Join, and if all are removed the join is useless and can be discarded. This inplace is just a runtime version of this optimization.