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 size=None explanation to jittable MessagePassing modules #4850

Merged
merged 3 commits into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

## [2.0.5] - 2022-MM-DD
### Added
- Added `size=None` explanation to jittable `MessagePassing` modules in the documentation ([#4850](https://github.com/pyg-team/pytorch_geometric/pull/4850))
- Added documentation to the `DataLoaderIterator` class ([#4838](https://github.com/pyg-team/pytorch_geometric/pull/4838))
- Added `GraphStore` support to `Data` and `HeteroData` ([#4816](https://github.com/pyg-team/pytorch_geometric/pull/4816))
- Added `FeatureStore` support to `Data` and `HeteroData` ([#4807](https://github.com/pyg-team/pytorch_geometric/pull/4807))
Expand Down
11 changes: 9 additions & 2 deletions docs/source/notes/jit.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ However, if you want your own GNN module to be jittable, you need to account for
def forward(self, x: Tensor, edge_index: Tensor,
edge_weight: Optional[Tensor]) -> Tensor:

return self.propagate(edge_index, x=x, edge_weight=edge_weight)
return self.propagate(edge_index, x=x, edge_weight=edge_weight,
size=None)

2. Declaring the type of propagation arguments as a comment anywhere inside your module:

Expand All @@ -115,4 +116,10 @@ However, if you want your own GNN module to be jittable, you need to account for
edge_weight: Optional[Tensor]) -> Tensor:

# propagate_type: (x: Tensor, edge_weight: Optional[Tensor])
return self.propagate(edge_index, x=x, edge_weight=edge_weight)
return self.propagate(edge_index, x=x, edge_weight=edge_weight,
size=None)

.. warning::

Importantly, due to TorchScript limitations, one also has to pass in the :obj:`size` attribute to :meth:`~torch_geometric.nn.conv.message_passing.MessagePassing.propagate`.
In most cases, this can be simply set to :obj:`None` in which case it will be automatically inferred.