Open ricardoV94 opened 1 year ago
@ricardoV94 Looks like we can check inner graph for nodes that we need to replace, and if any found - create new Scan
or OpFromGraph
node with changed fgraph and replace old one. In you opinion will this approach work?
Actually for Scan
there might be a shortcut, as Scan
has it's own mode
object. We can simple replace the old scan by a clone whose mode includes the rewrite we want to apply.
Eventually we want to get rid of this inner mode thing, but hopefully by that time we will have made Scan simpler so that's easier to manipulate anyway.
But we can do either way. The priority is more with Scan
We include these rewrites when compiling logp graphs, but this won't replace inner logp graphs (e.g, inside Scan or not-inlined OpFromGraph)
https://github.com/pymc-devs/pymc/blob/371472dcf1c44f99a9ad4e7317606404b2a47a0e/pymc/pytensorf.py#L1142-L1144
The example in #6696 suffers from this. Sampling is quite faster when the rewrite is manually added