Skip to content

Commit

Permalink
Prevent model compilation on custom propagate functions (#9079)
Browse files Browse the repository at this point in the history
  • Loading branch information
rusty1s committed Mar 21, 2024
1 parent c641331 commit 27367b4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

### Fixed

- Prevent model compilation on custom `propagate` functions ([#9079](https://github.com/pyg-team/pytorch_geometric/pull/9079))
- Ignore `self.propagate` appearances in comments when parsing `MessagePassing` implementation ([#9044](https://github.com/pyg-team/pytorch_geometric/pull/9044))
- Fixed `OSError` on read-only file systems within `MessagePassing` ([#9032](https://github.com/pyg-team/pytorch_geometric/pull/9032))
- Fixed metaclass conflict in `Dataset` ([#8999](https://github.com/pyg-team/pytorch_geometric/pull/8999))
Expand Down
8 changes: 8 additions & 0 deletions torch_geometric/nn/conv/message_passing.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ def __init__(
# Optimize `propagate()` via `*.jinja` templates:
if not self.propagate.__module__.startswith(jinja_prefix):
try:
if 'propagate' in self.__class__.__dict__:
raise ValueError("Cannot compile custom 'propagate' "
"method")

module = module_from_template(
module_name=f'{jinja_prefix}_propagate',
template_path=osp.join(root_dir, 'propagate.jinja'),
Expand Down Expand Up @@ -198,6 +202,10 @@ def __init__(
if (self.inspector.implements('edge_update')
and not self.edge_updater.__module__.startswith(jinja_prefix)):
try:
if 'edge_updater' in self.__class__.__dict__:
raise ValueError("Cannot compile custom 'edge_updater' "
"method")

module = module_from_template(
module_name=f'{jinja_prefix}_edge_updater',
template_path=osp.join(root_dir, 'edge_updater.jinja'),
Expand Down

0 comments on commit 27367b4

Please sign in to comment.