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 reverse support in aggregation_resolver #5084

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

lightaime
Copy link
Contributor

@lightaime lightaime commented Jul 28, 2022

This PR added the reverse support in aggregation_resolver to resolve Aggregation to strings. This will keep message_and_aggregate functionality intact if an aggr is FUSE_AGGRS but passed with Aggregation instance.

Addresses #4712.

@codecov
Copy link

codecov bot commented Jul 28, 2022

Codecov Report

Merging #5084 (1b132c1) into master (412ae53) will decrease coverage by 1.88%.
The diff coverage is 83.87%.

@@            Coverage Diff             @@
##           master    #5084      +/-   ##
==========================================
- Coverage   84.86%   82.97%   -1.89%     
==========================================
  Files         332      332              
  Lines       18304    18324      +20     
==========================================
- Hits        15534    15205     -329     
- Misses       2770     3119     +349     
Impacted Files Coverage Δ
torch_geometric/nn/conv/message_passing.py 98.84% <75.00%> (+<0.01%) ⬆️
torch_geometric/nn/resolver.py 87.67% <85.18%> (-6.33%) ⬇️
torch_geometric/nn/models/dimenet_utils.py 0.00% <0.00%> (-75.52%) ⬇️
torch_geometric/nn/models/dimenet.py 14.51% <0.00%> (-53.00%) ⬇️
torch_geometric/nn/conv/utils/typing.py 81.25% <0.00%> (-17.50%) ⬇️
torch_geometric/profile/profile.py 32.94% <0.00%> (-15.30%) ⬇️
torch_geometric/nn/inits.py 67.85% <0.00%> (-7.15%) ⬇️
torch_geometric/transforms/add_self_loops.py 94.44% <0.00%> (-5.56%) ⬇️
torch_geometric/io/tu.py 93.90% <0.00%> (-2.44%) ⬇️
... and 10 more

Help us with your feedback. Take ten seconds to tell us how you rate us.

@Padarn
Copy link
Contributor

Padarn commented Jul 29, 2022

This seems important, but I wonder if we could just define the equivalent aggregation on the aggregation class itself.

class SomeAggregation:
    @property
    def resolve_str():
        return "some_aggregation"

Not sure if its better. Just a thoguht.

@lightaime
Copy link
Contributor Author

This seems important, but I wonder if we could just define the equivalent aggregation on the aggregation class itself.

class SomeAggregation:
    @property
    def resolve_str():
        return "some_aggregation"

Not sure if its better. Just a thoguht.

Thanks for the suggestion. I am open to this solution as well.

@lightaime lightaime requested a review from rusty1s August 4, 2022 13:18
@rusty1s
Copy link
Member

rusty1s commented Aug 5, 2022

Sorry for the delay in review.

base_cls_repr = camel_to_snake(base_cls.__name__)

if not isinstance(query, base_cls):
choices = {base_cls_repr} | set(
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we should have a test case covering this? the logic is not trivial

@@ -80,14 +122,21 @@ def normalization_resolver(query: Union[Any, str], *args, **kwargs):
# Aggregation Resolver ########################################################


def aggregation_resolver(query: Union[Any, str], *args, **kwargs):
def aggregation_resolver(query: Union[Any, str], *args, reverse: bool = False,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not certain I like having a 'reverse' flag because it makes the logic for 'query' a bit complicated. What do you think about splitting this into reverse_aggregation_resolver?

Copy link
Contributor

@Padarn Padarn left a comment

Choose a reason for hiding this comment

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

I have a few nits about the design here, but I think its probably more important to get things merged, overall looks okay.

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