Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whether SparseTensor supports element-wise operations (add, mul)? #236

Open
VeritasYin opened this issue Jun 8, 2022 · 3 comments
Open
Labels
enhancement New feature or request

Comments

@VeritasYin
Copy link

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'
@rusty1s
Copy link
Owner

rusty1s commented Jun 9, 2022

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.

@VeritasYin
Copy link
Author

Thanks for the quick response. I will certainly look into it.

@github-actions
Copy link

github-actions bot commented Dec 7, 2022

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?

@github-actions github-actions bot added the stale label Dec 7, 2022
@rusty1s rusty1s added enhancement New feature or request and removed stale labels Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants