Support device as Dict key#65079
Closed
pbelevich wants to merge 8 commits intogh/pbelevich/156/basefrom
Closed
Conversation
[ghstack-poisoned]
Contributor
🔗 Helpful links
💊 CI failures summary and remediationsAs of commit 6e3345e (more details on the Dr. CI page):
1 failure not recognized by patterns:
This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions to the (internal) Dr. CI Users group. |
This is required to use RPC DeviceMap aka Dict[torch.device, torch.device] in torchscript [ghstack-poisoned]
This is required to use RPC DeviceMap aka Dict[torch.device, torch.device] in torchscript [ghstack-poisoned]
This is required to use RPC DeviceMap aka Dict[torch.device, torch.device] in torchscript [ghstack-poisoned]
This is required to use RPC DeviceMap aka Dict[torch.device, torch.device] in torchscript [ghstack-poisoned]
This is required to use RPC DeviceMap aka Dict[torch.device, torch.device] in torchscript [ghstack-poisoned]
This is required to use RPC DeviceMap aka Dict[torch.device, torch.device] in torchscript [ghstack-poisoned]
lw
approved these changes
Sep 20, 2021
Contributor
lw
left a comment
There was a problem hiding this comment.
Overall looks good to me (with one suggestion).
aten/src/ATen/core/Dict_inl.h
Outdated
| } else if (ivalue.isTensor()) { | ||
| return std::hash<TensorImpl*>()(ivalue.toTensor().unsafeGetTensorImpl()); | ||
| } else if (ivalue.isDevice()) { | ||
| return std::hash<std::string>()(ivalue.toDevice().str()); |
Contributor
There was a problem hiding this comment.
There already exists a specialization of std::hash for devices:
Line 137 in b9fc656
Hence this could be simplified, and made more idiomatic and efficient, by doing:
Suggested change
| return std::hash<std::string>()(ivalue.toDevice().str()); | |
| return std::hash<Device>()(ivalue.toDevice()); |
Contributor
Author
There was a problem hiding this comment.
Thanks for suggestion!
This is required to use RPC DeviceMap aka Dict[torch.device, torch.device] in torchscript [ghstack-poisoned]
Contributor
Author
|
@pbelevich has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Contributor
|
@pbelevich merged this pull request in 19a1063. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is required to use RPC DeviceMap aka Dict[torch.device, torch.device] in torchscript
Stack from ghstack:
Differential Revision: D31072626