rusty1s / pytorch_sparse

PyTorch Extension Library of Optimized Autograd Sparse Matrix Operations
MIT License
1.01k stars 147 forks source link

Is there a convenient way to Substract two vectors? #358

Closed KukumavMozolo closed 9 months ago

KukumavMozolo commented 9 months ago

Hi there, thank you for this project! I am trying to subtract two sparse vectors from each other and I have not found a convenient way to do so.

What would be the most memory efficient way of doing that?

rusty1s commented 9 months ago

SparseTensor + SparseTensor should be supported in the latest release, so I would assume you can just do mat1 + mat.mul_nnz(-1). There doesn't exist a more convenient call for this right now :(

KukumavMozolo commented 9 months ago

That looks a lot better then what i was doing, thanks a lot!