Rework parts of Graph::Resolve to reduce memory usage#12176
Merged
skottmckay merged 6 commits intomasterfrom Aug 5, 2022
Merged
Rework parts of Graph::Resolve to reduce memory usage#12176skottmckay merged 6 commits intomasterfrom
skottmckay merged 6 commits intomasterfrom
Conversation
…aphResolveMemoryCost
…aphResolveMemoryCost
…aphResolveMemoryCost
hariharans29
reviewed
Aug 4, 2022
| std::unordered_map<std::string_view, NodeIndex> node_name_to_index; | ||
| std::unordered_set<Node*> nodes_with_subgraphs; | ||
|
|
||
| // check if the provided name is an input/initialize/node output of this Graph instance during Graph::Resolve. |
hariharans29
reviewed
Aug 5, 2022
| std::unordered_map<std::string, NodeIndex> node_name_to_index; | ||
| std::unordered_map<std::string_view, std::pair<Node*, int>> output_args; | ||
| std::unordered_set<std::string_view> inputs_and_initializers; | ||
| std::unordered_map<std::string_view, NodeIndex> node_name_to_index; |
Member
There was a problem hiding this comment.
Since we are touching these anyway, any chance we want to start using InlinedHashMaps here ?
Contributor
Author
There was a problem hiding this comment.
IIRC the usage of those are small collections where we're trying to avoid a memory allocation by having a small stack allocated buffer. These collections will most likely be quite large so are very unlikely to be able to use the stack allocated buffer.
hariharans29
approved these changes
Aug 5, 2022
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.
Description:
Motivation and Context
Reduce memory consumption for models that have a lot of subgraphs, especially if there are multiple levels of nesting.
Saves 7MB of peak memory loading 1P model.