Search code examples
pytorchmatrix-multiplication

What is the difference between mm and spmm in Pytorch


What is the difference between mm and spmm in Pytorch? I know that spmm does sparse matrix multiplication, but what exactly does that mean? Why would you ever choose mm as opposed to spmm if spmm has the potential to save space?


Solution

  • In order to use spmm you need your tensor arguments to actually be of sparse type.

    Although torch.sparse representation does have the potential of saving space, sparse support does not yet covers all tensor operations and functions.