Optimize LazyValues and SparseValues with Caching Mechanism#4138
Open
Phoenix8215 wants to merge 2 commits intoNVIDIA:release/10.4from
Open
Optimize LazyValues and SparseValues with Caching Mechanism#4138Phoenix8215 wants to merge 2 commits intoNVIDIA:release/10.4from
Phoenix8215 wants to merge 2 commits intoNVIDIA:release/10.4from
Conversation
pull 10.4
Signed-off-by: Phoenix <861062923@qq.com>
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.
Title: Optimize LazyValues and SparseValues with Caching Mechanism
Description:
This PR introduces a caching mechanism to the
LazyValuesandSparseValuesclasses in the ONNX GraphSurgeon module of TensorRT. By caching the loaded tensor values, we can avoid redundant data loading operations, improving performance, especially when dealing with large tensors or when theloadmethod is called multiple times.Motivation:
The
loadmethods in bothLazyValuesandSparseValuesclasses currently reload tensor data every time they are called, which can be inefficient. Adding a simple caching mechanism ensures that tensor data is loaded once and reused, reducing computational overhead and improving the efficiency of the code.Changes:
_cached_valuesattribute to both classes to store the loaded tensor data.loadmethods to check for cached data before loading.Code Changes:
Testing:
loadmethod returns the correct tensor data on first and subsequent calls.Request for Review:
Please review the proposed changes and let me know if there are any concerns or suggestions for improvement. I'm open to feedback and willing to make adjustments as needed.