pytensor
pytensor copied to clipboard
Rewrite to remove useless Reshape
Description
With static types it is possible to find out cases where we know the reshape is useless at compile time. We should remove it when that's the case.
Sometimes the Reshape may also just be expanding dims, pt.scalar().reshape(1, -1)
(which showed up in the use of tensordot in #722), which should also be rewritten, as we have many rewrites that reason about Dimshuffles but not Reshapes