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

Add is_sparse and to_torch_coo_tensor #6003

Merged
merged 9 commits into from
Nov 21, 2022
Merged

Add is_sparse and to_torch_coo_tensor #6003

merged 9 commits into from
Nov 21, 2022

Conversation

EdisonLeeeee
Copy link
Contributor

@EdisonLeeeee EdisonLeeeee commented Nov 18, 2022

This PR aims to

  • Add is_sparse to check if the input is either torch.sparse.Tensor or torch_sparse.SparseTensor
  • Add to_torch_coo_tensor to convert edge_index and edge_weight to torch.sparse.Tensor (in COO format)
  • Move is_torch_sparse_tensor from torch_sparse_tensor.py to sparse.py. I think this makes the structure in torch_geometric.utils clearer.
  • Clean up duplicated code in message_passing.py.

@codecov
Copy link

codecov bot commented Nov 18, 2022

Codecov Report

Merging #6003 (26dc1de) into master (009abc2) will decrease coverage by 1.96%.
The diff coverage is 63.15%.

❗ Current head 26dc1de differs from pull request most recent head 904e7db. Consider uploading reports for the commit 904e7db to get more accurate results

@@            Coverage Diff             @@
##           master    #6003      +/-   ##
==========================================
- Coverage   86.64%   84.67%   -1.97%     
==========================================
  Files         361      360       -1     
  Lines       19860    19860              
==========================================
- Hits        17207    16816     -391     
- Misses       2653     3044     +391     
Impacted Files Coverage Δ
torch_geometric/utils/sparse.py 75.86% <53.33%> (-24.14%) ⬇️
torch_geometric/nn/conv/message_passing.py 98.91% <100.00%> (-0.02%) ⬇️
torch_geometric/utils/spmm.py 88.88% <100.00%> (ø)
torch_geometric/nn/models/dimenet_utils.py 0.00% <0.00%> (-75.52%) ⬇️
torch_geometric/nn/models/dimenet.py 14.90% <0.00%> (-52.76%) ⬇️
torch_geometric/profile/profile.py 36.73% <0.00%> (-27.56%) ⬇️
torch_geometric/nn/conv/utils/typing.py 81.25% <0.00%> (-17.50%) ⬇️
torch_geometric/nn/pool/asap.py 92.10% <0.00%> (-7.90%) ⬇️
torch_geometric/nn/inits.py 67.85% <0.00%> (-7.15%) ⬇️
torch_geometric/nn/dense/linear.py 87.40% <0.00%> (-5.93%) ⬇️
... and 15 more

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

Copy link
Member

@rusty1s rusty1s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM besides the missing test of to_sparse_coo_tensor. Do you plan to integrate that in this PR?

@EdisonLeeeee
Copy link
Contributor Author

Yep, will finish it tomorrow.

@github-actions github-actions bot added the nn label Nov 19, 2022
@EdisonLeeeee EdisonLeeeee requested a review from rusty1s November 19, 2022 03:36
@rusty1s rusty1s enabled auto-merge (squash) November 21, 2022 16:20
@rusty1s rusty1s merged commit 01037db into master Nov 21, 2022
@rusty1s rusty1s deleted the sparse branch November 21, 2022 19:09
JakubPietrakIntel pushed a commit to JakubPietrakIntel/pytorch_geometric that referenced this pull request Nov 25, 2022
This PR aims to
+ Add `is_sparse` to check if the input is either `torch.sparse.Tensor`
or `torch_sparse.SparseTensor`
+ Add `to_torch_coo_tensor` to convert `edge_index` and `edge_weight` to
`torch.sparse.Tensor` (in COO format)
+ Move `is_torch_sparse_tensor` from `torch_sparse_tensor.py` to
`sparse.py`. I think this makes the structure in `torch_geometric.utils`
clearer.
+ Clean up duplicated code in `message_passing.py`.

Co-authored-by: rusty1s <matthias.fey@tu-dortmund.de>
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.

2 participants