I would like to compute the product of a matrix X with shape (a, b) and a tensor Y with shape (a, b, c) such that the result Z has shape (a, c), and row i (i = 1...a) of Z is the product of row i of X and the matrix slice (i, :, :) of Y.
Is there a convenient way to do this in NumPy and Theano, ideally using built-in functions, and without using loops or computing unnecessary matrix products?