Repository: snap-stanford/ogb
Issue: Replacing GCNConv as defined in ogbn-protein example with torch_geometric.nn.GCNConv causes error
Root cause: Interface Contract Mismatch

Hi, 
I wanted to know why the GCNConv that is provided with torch_geometric.nn does not work with the examples. Using the layer definition that is provided in the examples work fine. This the the error that I am getting. Would really like it if someone sheds some light on this issue. 

`TypeError                                 Traceback (most recent call last)
<ipython-input-18-01dc0c48e63c> in <module>
     16     for epoch in range(1, 1 + args.epochs):
     17 
---> 18         loss = train(model, x, adj, y_true, train_idx, optimizer)
     19 
     20         if epoch % args.eval_steps == 0:

<ipython-input-14-501bd9949f0c> in train(model, x, adj, y_true, train_idx, optimizer)
      4 
      5     optimizer.zero_grad()
----> 6     out = model(x, adj)[train_idx]
      7     loss = criterion(out, y_true[train_idx].to(torch.float))
      8     loss.backward()

/opt/conda/lib/python3.7/site-packages/torch/nn/modules/module.py in __call__(self, *input, **kwargs)
    548             result = self._slow_forward(*input, **kwargs)
    549         else:
--> 550             result = self.forward(*input, **kwargs)
    551         for hook in self._forward_hooks.values():
    552             hook_result = hook(self, input, result)

<ipython-input-13-f1ba88cce835> in forward(self, x, adj)
      7 
      8     def forward(self, x, adj):
----> 9         x = self.init(x,adj)
     10         x = self.dense(x,adj)
     11         x = self.out(x,adj)

/opt/conda/lib/python3.7/site-packages/torch/nn/modules/module.py in __call__(self, *input, **kwargs)
    548             result = self._slow_forward(*input, **kwargs)
    549         else:
--> 550             result = self.forward(*input, **kwargs)
    551         for hook in self._forward_hooks.values():
    552             hook_result = hook(self, input, result)

/opt/conda/lib/python3.7/site-packages/torch_geometric/nn/conv/gcn_conv.py in forward(self, x, edge_index, edge_weight)
    100             if self.normalize:
    101                 edge_index, norm = self.norm(edge_index, x.size(
--> 102                     self.node_dim), edge_weight, self.improved, x.dtype)
    103             else:
    104                 norm = edge_weight

/opt/conda/lib/python3.7/site-packages/torch_geometric/nn/conv/gcn_conv.py in norm(edge_index, num_nodes, edge_weight, improved, dtype)
     71         if edge_weight is None:
     72             edge_weight = torch.ones((edge_index.size(1), ), dtype=dtype,
---> 73                                      device=edge_index.device)
     74 
     75         fill_value = 1 if not improved else 2

TypeError: ones() received an invalid combination of arguments - got (tuple, device=method, dtype=torch.dtype), but expected one of:
 * (tuple of ints size, *, tuple of names names, torch.dtype dtype, torch.layout layout, torch.device device, bool pin_memory, bool requires_grad)
 * (tuple of ints size, *, Tensor out, torch.dtype dtype, torch.layout layout, torch.device device, bool pin_memory, bool requires_grad)

`

Because the `ogbn-proteins` example utilizes `torch_sparse.SparseTensor` for message propagation, which enables us to implement a more efficient and more memory-friendly message aggregation scheme without running out of GPU memory. I am currently in the process of updating all PyG ops to also work with `torch_sparse.SparseTensor`, and will update the OGB examples to utilize PyG ops after its proper release (should be around this week). Please stay patient :)

Thanks a lot. 
I'm just learning PyG and hence it's a little confusing for me. 

I will keep you updated :)

This is now fixed in PyTorch Geometric 1.6.0. I updated the examples accordingly. You can have a look at the [PyG tutorial](https://pytorch-geometric.readthedocs.io/en/latest/notes/sparse_tensor.html) to understand the changes I made.