[Bug] u_mul_e is broken on a heterogeneous graph with only one ntype
- Dominant language
- Python
- Stars
- 14.3k
- Forks
- 3.1k
- PR merge metrics
- No merged PRs in 30d
Description
## 🐛 Bug
dgl.function.u_mul_e is broken on a heterogeneous graph with only one ntype.
## To Reproduce
Steps to reproduce the behavior:
```python
import dgl
import torch as th
import dgl.function as fn
graph_data = {
('drug', 'interacts', 'drug'): (th.tensor([0, 1]), th.tensor([1, 2])),
('drug', 'treats', 'drug'): (th.tensor([1]), th.tensor([2]))
}
g = dgl.heterograph(graph_data)
g.srcdata['h'] = th.zeros(3)
g.edges['interacts'].data['w'] = th.ones(2)
g.edges['treats'].data['w'] = th.ones(1)
g.apply_edges(fn.u_mul_e('h', 'w', 'm'))
```
## Expected behavior
```
g.apply_edges(fn.u_mul_e('h', 'w', 'm'))
File "/home/ec2-user/anaconda3/envs/py39/lib/python3.9/site-packages/dgl/heterograph.py", line 4458, in apply_edges
edata = core.invoke_gsddmm(g, func)
File "/home/ec2-user/anaconda3/envs/py39/lib/python3.9/site-packages/dgl/core.py", line 264, in invoke_gsddmm
x = data_dict_to_list(graph, x, func, lhs_target)
File "/home/ec2-user/anaconda3/envs/py39/lib/python3.9/site-packages/dgl/core.py", line 214, in data_dict_to_list
output_list[src_id] = data_dict[srctype]
IndexError: too many indices for tensor of dimension 1
```
## Environment
- DGL Version (e.g., 1.0): 0.9.1
- Backend Library & Version (e.g., PyTorch 0.4.1, MXNet/Gluon 1.3): PyTorch 1.10.0
- OS (e.g., Linux): Linux
- How you installed DGL (`conda`, `pip`, source): pip
- Python version: 3.9.7
- CUDA/cuDNN version (if applicable): 102
- GPU models and configuration (e.g. V100): T4
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.