Where is the source code of torch.spmm?


(Yiru Shen) #1

I have found torch.mm and got no luck of torch.spmm. Where can I find it? Thanks!


(Thomas V) #2

There is a trick: rgrep -w spmm tools/autograd/ gives

tools/autograd/templates/python_torch_functions.cpp:  {"spmm", (PyCFunction)THPVariable_mm, METH_VARARGS | METH_KEYWORDS | METH_STATIC, NULL},

so it dispatches to mm.
You found that already, if you had not, I could offer a writeup of how PyTorch functions are generated.

Best regards

Thomas


(Yiru Shen) #3

Thank you for your reply. It helps a lot!