-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[TMVA][SOFIE] Memory Optimization for Intermediate tensors - v1 #17532
Open
sanjibansg
wants to merge
36
commits into
root-project:master
Choose a base branch
from
sanjibansg:sofie/mem_optim_v1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+561
−110
Conversation
This file contains 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
Test Results 18 files 18 suites 4d 2h 36m 12s ⏱️ For more details on these failures, see this check. Results for commit 310e38b. ♻️ This comment has been updated with latest results. |
…RModel fInputTensorNames as std::vectors instead of std::unordered_set
d57c063
to
e2eda75
Compare
…constant operator case
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 PR brings the first version for the memory optimization for intermediate tensors.
Currently, in the inference code, all the intermediate tensors are initialized at first and are allocated memory, thus no memory reuse takes place. Since not all the intermediate tensors are required till the end, we can flush some of them, and reuse the memory that they release.
This first edition of memory optimization for intermediate tensors uses a simple mechanism, where the total memory required is first calculated along with the count of operators who need a particular intermediate tensor as their input.
While adding a operator into the RModel during the Parsing stage, its input operators are taken into account into an unordered map (added as a new key-value pair if not already present, otherwise frequency is incremented). During the initialize phase, we calculate the total memory required by the tensors. We keep two separate containers - total memory (for calculating the total memory required by all the tensors) and available memory (for accounting all the reusable memory - memory that was flushed and can be reused). During the generate phase, we Initialize the intermediate tensors when a particular operator needs it as an output, and flush them when no operator no longer needs it as an input.