- What I want
I want to do element-wise matrix multiplication of two matrix:
-
sparse matrix
A
with shape (3,4,5) -
dense matrix
B
with shape (100,10,4,5)
I am expecting to do element-wise matrix multiplication on the last 2 dimensions of these matrix
So the resulting matrix C=A*B
have shape (100,10,3,4,5)
I want to do this more efficiently. What can I do?
- What I currently do
I checked the docment of the Pytorch.sparse, which indicates to use the operator *
to do element-wise matrix multiplication.
However, this operator only support 2-dimension matrix. I have to iterate over the first dimension of matrix A
and the first two dimensions of matrix B
to do 2d*2d
matrix multiplication to get the right results, which is not efficient.