I would like to know if there is a way to multiply multiple matrices as a chain.
Let’s say I have matrices M1, M2, … M23, and I want to do: M1 @ M2 @ M3 @ ... @ M23.
I see only a for loop or a recursive function for that … that wouldn’t be very effective I guess.
I would recommend to use torch.chain_matmul as it should be more efficient.
From the docs:
This product is efficiently computed using the matrix chain order algorithm which selects the order in which incurs the lowest cost in terms of arithmetic operations.