Share memory in single session without user specification #1
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
Removed is_shared_initializer from the decision to cache pre-packed weights. This allows memory to be shared within a single session even if the user does not specify it, thus reducing memory usage.
Motivation and Context
In the current implementation, memory is not shared even if the model shares parameters among multiple layers. There is a mechanism to share memory specified by the user, but the memory usage is large. By modifying the code slightly, we found that memory can be shared within a single session even if the user does not specify it, thus reducing memory usage.
In the current implementation, the decision to share or not to share memory is based on whether the memory is specified by the user or not.
onnxruntime/onnxruntime/core/framework/session_state.cc
Lines 426 to 430 in 5930e7e
Even if this conditional branch is removed, memory that should not be shared will not be shared because there will be a conditional branch later in the Murmur hash to check whether the memory contents are the same or not.
onnxruntime/onnxruntime/core/framework/session_state.cc
Lines 460 to 465 in 5930e7e