I have two matrices: A with size [D,N,M] and B with size[D,M,S]. My target is to multiply two matrices with respect to the dim_1 and dim_2, which is like A[d,:,:] * B[d,:,:] for d from 1:D. Currently I’m doing it with a for loop. I’m wondering if there is any other method I can use to make this operation more efficient.