pytensor
pytensor copied to clipboard
Add numpy `multi_dot` helper and graph rewrites
Description
https://numpy.org/doc/stable/reference/generated/numpy.linalg.multi_dot.html#
The helper should just use pytensor dot/ matmul under the hood while matching the call signature of numpy.
The fun part is to add a graph rewriter that identifies sequences of dot products and reorders them based on available static shape information so as to reduce number of operations needed
https://en.m.wikipedia.org/wiki/Matrix_chain_multiplication