I am trying to run sample codes of 'Automatically Converting GNN Models' from PyG documentation. I found that torch.fx.Tracer has no attribute named '_module_getattr'. How to resolve this problem? I am attaching my codes and error bellow.
import torch_geometric.transforms as T
from torch_geometric.datasets import OGB_MAG
from torch_geometric.nn import SAGEConv, to_hetero as t_heter
import torch
dataset = OGB_MAG(root='./data', preprocess='metapath2vec', transform=T.ToUndirected())
data = dataset[0]
class GNN(torch.nn.Module):
def __init__(self, hidden_channels, out_channels):
super().__init__()
self.conv1 = SAGEConv((-1, -1), hidden_channels)
self.conv2 = SAGEConv((-1, -1), out_channels)
def forward(self, x, edge_index):
x = self.conv1(x, edge_index).relu()
x = self.conv2(x, edge_index)
return x
model = GNN(hidden_channels=64, out_channels=dataset.num_classes)
model = t_heter(model, data.metadata(), aggr='sum')
``` Error Message
Traceback (most recent call last):
File "/u/wyr6fx/PyG/GNNModel/HeterogenousGraph.py", line 22, in <module>
model = t_heter(model, data.metadata(), aggr='sum')
File "/u/wyr6fx/myenv/lib/python3.9/site-packages/torch_geometric/nn/to_hetero_transformer.py", line 117, in to_hetero
transformer = ToHeteroTransformer(module, metadata, aggr, input_map, debug)
File "/u/wyr6fx/myenv/lib/python3.9/site-packages/torch_geometric/nn/to_hetero_transformer.py", line 141, in __init__
super().__init__(module, input_map, debug)
File "/u/wyr6fx/myenv/lib/python3.9/site-packages/torch_geometric/nn/fx.py", line 73, in __init__
self.gm = symbolic_trace(module)
File "/u/wyr6fx/myenv/lib/python3.9/site-packages/torch_geometric/nn/fx.py", line 358, in symbolic_trace
return GraphModule(module, Tracer().trace(module, concrete_args))
File "/u/wyr6fx/myenv/lib/python3.9/site-packages/torch_geometric/nn/fx.py", line 351, in trace
'output', 'output', (self.create_arg(fn(*args)), ), {},
File "/u/wyr6fx/PyG/GNNModel/HeterogenousGraph.py", line 16, in forward
x = self.conv1(x, edge_index).relu()
File "/u/wyr6fx/myenv/lib/python3.9/site-packages/torch_geometric/nn/fx.py", line 322, in module_getattr_wrapper
return self._module_getattr(attr, attr_val,
AttributeError: 'Tracer' object has no attribute '_module_getattr'
### Environment
* PyG version: 2.0.4
* PyTorch version: 1.13.0
* OS: macOS
* Python version: 3.9.7
* CUDA/cuDNN version: cpu
* How you installed PyTorch and PyG (`conda`, `pip`, source): pip
* Any other relevant information (*e.g.*, version of `torch-scatter`): torch-scatter 2.0.9
🐛 Describe the bug
I am trying to run sample codes of 'Automatically Converting GNN Models' from PyG documentation. I found that torch.fx.Tracer has no attribute named '_module_getattr'. How to resolve this problem? I am attaching my codes and error bellow.