Skip to content

Commit

Permalink
Fix inheritance in MessagePassing (#8973)
Browse files Browse the repository at this point in the history
Fixes #8968

Accidentally merged
c22bb89.

Follow-up.
  • Loading branch information
rusty1s committed Feb 26, 2024
1 parent c22bb89 commit b812cff
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

### Fixed

- Fixed import errors on `MessagePassing` modules with nested inheritance ([#8973](https://github.com/pyg-team/pytorch_geometric/pull/8973))

### Removed

## \[2.5.0\] - 2024-02-16
Expand Down
9 changes: 7 additions & 2 deletions test/nn/conv/test_graph_conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,13 @@ def test_graph_conv():

class EdgeGraphConv(GraphConv):
def message(self, x_j, edge_weight):
return x_j if edge_weight is None else edge_weight * x_j
return edge_weight.view(-1, 1) * x_j


def test_inheritance():
conv = EdgeGraphConv(16, 16)
x = torch.randn(4, 8)
edge_index = torch.tensor([[0, 1, 2, 3], [0, 0, 1, 1]])
edge_weight = torch.rand(4)

conv = EdgeGraphConv(8, 16)
assert conv(x, edge_index, edge_weight).size() == (4, 16)
1 change: 0 additions & 1 deletion torch_geometric/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def module_from_template(
env = Environment(loader=FileSystemLoader(osp.dirname(template_path)))
template = env.get_template(osp.basename(template_path))
module_repr = template.render(**kwargs)
print(module_repr)

instance_dir = osp.join(get_home_dir(), tmp_dirname)
os.makedirs(instance_dir, exist_ok=True)
Expand Down

0 comments on commit b812cff

Please sign in to comment.