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

Fix data.num_edges for torch.sparse.Tensor #7104

Merged
merged 3 commits into from
Apr 3, 2023
Merged

Conversation

sisaman
Copy link
Contributor

@sisaman sisaman commented Apr 2, 2023

Fixes zero num_edges when using native PyTorch sparse tensor (#7103).

sisaman and others added 2 commits April 2, 2023 16:04
Fixes zero `num_edges` when using native PyTorch sparse tensor.
@codecov
Copy link

codecov bot commented Apr 2, 2023

Codecov Report

Merging #7104 (0fb7094) into master (8555970) will decrease coverage by 0.42%.
The diff coverage is 0.00%.

❗ Current head 0fb7094 differs from pull request most recent head 3b13c3c. Consider uploading reports for the commit 3b13c3c to get more accurate results

@@            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     
Impacted Files Coverage Δ
torch_geometric/data/storage.py 81.49% <0.00%> (-0.39%) ⬇️

... and 20 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Contributor

@EdisonLeeeee EdisonLeeeee left a 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!

@@ -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
Copy link
Contributor

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?

@rusty1s rusty1s changed the title fix #7103 Fix data.num_edges for torch.sparse.Tensor Apr 3, 2023
@rusty1s rusty1s enabled auto-merge (squash) April 3, 2023 06:48
@rusty1s rusty1s merged commit 3c15018 into pyg-team:master Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants