-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Fix data.num_edges
for torch.sparse.Tensor
#7104
Conversation
Fixes zero `num_edges` when using native PyTorch sparse tensor.
for more information, see https://pre-commit.ci
Codecov Report
@@ Coverage Diff @@
## master #7104 +/- ##
==========================================
- Coverage 91.66% 91.25% -0.42%
==========================================
Files 436 436
Lines 23914 23913 -1
==========================================
- Hits 21921 21821 -100
- Misses 1993 2092 +99
... and 20 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for catching!
torch_geometric/data/storage.py
Outdated
@@ -418,6 +418,9 @@ def num_edges(self) -> int: | |||
for value in self.values('adj', 'adj_t'): | |||
if isinstance(value, SparseTensor): | |||
return value.nnz() | |||
elif isinstance(value, Tensor) and (value.is_sparse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use torch_geometric.utils.is_torch_sparse_tensor
instead?
Fixes zero
num_edges
when using native PyTorch sparse tensor (#7103).