pytorch_sparse
pytorch_sparse copied to clipboard
Whether SparseTensor supports element-wise operations (add, mul)?
Hello,
Recently, I work on a task needs better support of SparseTensor for Pytorch and pytorch-sparse helps me a lot. It seems like currently it does not support operations between two SparseTensors. As I checked, the func 'add' and 'mul' can only accept one sparse tensor and one dense tensor. Is there a way to get around this? Thanks!
~/anaconda3/lib/python3.8/site-packages/torch_sparse/mul.py in <lambda>(self, other)
64
65
---> 66 SparseTensor.mul = lambda self, other: mul(self, other)
67 SparseTensor.mul_ = lambda self, other: mul_(self, other)
68 SparseTensor.mul_nnz = lambda self, other, layout=None: mul_nnz(
~/anaconda3/lib/python3.8/site-packages/torch_sparse/mul.py in mul(src, other)
15 else:
16 raise ValueError(
---> 17 f'Size mismatch: Expected size ({src.size(0)}, 1, ...) or '
18 f'(1, {src.size(1)}, ...), but got size {other.size()}.')
19
TypeError: size() missing 1 required positional argument: 'dim'
Thanks for your interest. We have support for add between two SparseTensor instances (see here), but mul is indeed missing. Happy to accept any PR on this one if you are interested.
Thanks for the quick response. I will certainly look into it.
This issue had no activity for 6 months. It will be closed in 2 weeks unless there is some new activity. Is this issue already resolved?