Skip to content

Conversation

@cthoyt
Copy link
Contributor

@cthoytcthoyt commented Feb 8, 2022

This pull request implements a to() function on the PackedGraph class. Many models expect a function like this available for shuttling between CPU and GPU.

  • Handle when a str is passed (done in bd3482b)
  • Handle when a torch.device is passed (done in 84aa285)

Question: should it be able to handle other things?

@cthoytcthoyt marked this pull request as ready for review February 8, 2022 14:50
@KiddoZhu
Copy link
Member

That's a good feature! I feel it might not be robust to parse the string in that way. For example, in multi-GPU training mode, one may want to specify which GPU they want to send the data structure to.

A safer way is to convert the string (or whatever argument) into torch.device and then dispatch it with data.Graph.cpu or data.Graph.cuda. I will refine it.

@cthoyt
Copy link
ContributorAuthor

It’s definitely not the goal to implement a robust string parser - just to make it possible to do a few common things very quickly. Note that the function also handles torch devices directly as well in the next part of the conditional

@KiddoZhuKiddoZhu merged commit 17477ca into DeepGraphLearning:masterFeb 17, 2022
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@cthoyt@KiddoZhu