Description
Description
vectorize_node implicitly assumes that whenever we want to vectorize a node, we will return a new node that has a 1-to-1 mapping with the original outputs, but this is too restrictive. It could be the case we want to vectorize a single node with two variables coming from different nodes, or a single output from a multi-valued node. There's no reason why we need a one node -> one node mapping.
pytensor/pytensor/graph/replace.py
Lines 208 to 211 in 79ff97a
For backwards compatibility we should check if the returned object is an Apply and issue a warning that this form is deprecated (but still use it) and instead a list of outputs (like in the rewrites) should be returned. All our implementations in PyTensor should switch to returning a list of variables.
The catch/warning could be done here:
pytensor/pytensor/graph/replace.py
Lines 214 to 217 in 79ff97a
Then everything that calls vectorize_node
should now expect a list as output. Like here:
pytensor/pytensor/graph/replace.py
Lines 301 to 308 in 79ff97a