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

combine_frames doesn't allow for no edges #7826

Open
lilyminium opened this issue Oct 16, 2024 · 0 comments
Open

combine_frames doesn't allow for no edges #7826

lilyminium opened this issue Oct 16, 2024 · 0 comments
Labels
bug:confirmed Something isn't working

Comments

@lilyminium
Copy link

🐛 Bug

To Reproduce

This is a niche corner case, but hopefully one with an easy-ish solution. If I create a DGL heterograph with no edges, trying to convert it with to_homogeneous raises an error from having no edges.

import dgl

heterograph = dgl.heterograph(
    {("node", "forward", "node"): ([], []), ("node", "reverse", "node"): ([], [])},
    num_nodes_dict={"node": 1}
)
dgl.to_homogeneous(heterograph)

raises the error:

TypeError                                 Traceback (most recent call last)
Cell In[24], line 1
----> 1 dgl.to_homogeneous(heterograph)

File dgl/convert.py:1026, in to_homogeneous(G, ndata, edata, store_type, return_count)
   1022     edata = []
   1023 comb_nf = combine_frames(
   1024     G._node_frames, range(len(G.ntypes)), col_names=ndata
   1025 )
-> 1026 comb_ef = combine_frames(
   1027     G._edge_frames, range(len(G.etypes)), col_names=edata
   1028 )
   1029 if comb_nf is not None:
   1030     retg.ndata.update(comb_nf)

File dgl/heterograph.py:6579, in combine_frames(frames, ids, col_names)
   6576         else:
   6577             del schemes[key]
-> 6579 if len(schemes) == 0:
   6580     return None
   6582 # concatenate the columns

TypeError: object of type 'NoneType' has no len()

Expected behavior

I was hoping DGL would simply be able to batch this through with all the other normal graphs. I think the error is due to this initial definition of schemes as None, and then skipping over each frame as they have 0 rows.

schemes = None

Would it be possible to incorporate a check for None for schemes?

Environment

  • DGL Version (e.g., 1.0):
  • Backend Library & Version (e.g., PyTorch 0.4.1, MXNet/Gluon 1.3):
  • OS (e.g., Linux):
  • How you installed DGL (conda, pip, source):
  • Build command you used (if compiling from source):
  • Python version:
  • CUDA/cuDNN version (if applicable):
  • GPU models and configuration (e.g. V100):
  • Any other relevant information:

Additional context

@lilyminium lilyminium changed the title combine_frames doesn't allow for edges combine_frames doesn't allow for no edges Oct 16, 2024
@rudongyu rudongyu added the bug:confirmed Something isn't working label Oct 24, 2024
@github-project-automation github-project-automation bot moved this to 🏠 Backlog in DGL Project Tracker Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug:confirmed Something isn't working
Projects
Status: 🏠 Backlog
Development

No branches or pull requests

2 participants