Skip to content

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

@VeritasYin

Description

@VeritasYin

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'

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions