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

Pytorch Sparse tensor support: AntiSymmetricConv, CGConv, and TransformerConv #6633

Merged
merged 7 commits into from
Feb 8, 2023

Conversation

EdisonLeeeee
Copy link
Contributor

A minor change on nn.MessagePassing layer, where edge_attr and edge_type are None by default if the sparse adjacency matrix is 2-dimensional.

@codecov
Copy link

codecov bot commented Feb 7, 2023

Codecov Report

Merging #6633 (7bff4de) into master (98626c6) will decrease coverage by 1.61%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #6633      +/-   ##
==========================================
- Coverage   89.33%   87.73%   -1.61%     
==========================================
  Files         422      422              
  Lines       22926    22887      -39     
==========================================
- Hits        20482    20080     -402     
- Misses       2444     2807     +363     
Impacted Files Coverage Δ
torch_geometric/nn/conv/message_passing.py 98.90% <100.00%> (ø)
torch_geometric/nn/models/dimenet_utils.py 0.00% <0.00%> (-75.52%) ⬇️
torch_geometric/nn/models/dimenet.py 17.66% <0.00%> (-49.78%) ⬇️
torch_geometric/visualization/graph.py 68.25% <0.00%> (-26.99%) ⬇️
torch_geometric/nn/conv/utils/typing.py 83.75% <0.00%> (-15.00%) ⬇️
torch_geometric/nn/pool/asap.py 91.89% <0.00%> (-8.11%) ⬇️
torch_geometric/nn/inits.py 67.85% <0.00%> (-7.15%) ⬇️
torch_geometric/resolver.py 82.75% <0.00%> (-6.90%) ⬇️
torch_geometric/nn/dense/linear.py 89.13% <0.00%> (-5.84%) ⬇️
torch_geometric/transforms/add_self_loops.py 94.44% <0.00%> (-5.56%) ⬇️
... and 33 more

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

Comment on lines 320 to 322
out['edge_attr'] = None if values.dim() == 1 else values
if out.get('edge_type', None) is None:
out['edge_type'] = values
out['edge_type'] = None if values.dim() == 1 else values
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain? Not sure I understand.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unlike torch_sparse.SparseTensor, edge_attr will never be None for PyTorch SparseTensor, which is not applicable for layers that accept edge_attr, e.g. TransformerConv

if edge_attr is not None:
out = out + edge_attr

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I see. This is tricky. I reverted the edge_type chance back since the values are always expected to be one-dimensional, but otherwise, I think the fix looks good to me.

torch_geometric/nn/conv/message_passing.py Outdated Show resolved Hide resolved
@rusty1s rusty1s merged commit 2ea3c2d into master Feb 8, 2023
@rusty1s rusty1s deleted the sparse_tensor branch February 8, 2023 09:23
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