I have two matrices A of sizes (16, 8, 400) , B of size(16, 50, 400) ; where 16 is the batch size.
Now what I need to do is this:
For every batch in A, I want to compute the inner product of each row in a single batch of A with each row in a single batch of B and then get the max inner product value. In other words, for every batch, I have a (8, 400) matrix on left-hand side (A) and a (50, 400) matrix on right-hand side (B). Now for each row (8 * 400) in A, I want to compute inner product of that row with each of the (1 * 400) rows in B, one by one, and get the max inner product. The inner product operation would thus result in a (8 * 1) sized vector, and then get the max value of the 8 values. Done for each batch it would result in (16, 50, 1) sized matrix, which is the preferred dimension of my output.
The mathematical formula is shown in the figure enter image description here
How do I go about doing this? I do not want to use for loops, since that would be inefficient. I also do not want to use repeat method for the same reason.