Allow taking ownership of convolution weights#32
Merged
mtavenrath merged 1 commit intorustnn:mainfrom Apr 1, 2026
Merged
Conversation
15e2ceb to
34c86d7
Compare
It's difficult for users of trtx to create temporary weights for convolutions if they decide to perform the swizzling themselves (they could also swizzle using TensorRT layers). The ownership model expects that the user can prove that weights remain valid throughout the whole lifetime of `NetworkDefinition`. This is typically done by non-exclusively borrowing from weights from somewhere. If they want to create new weights they typically need a mutual borrow and unsafe code as a mutual borrow could also delete weights prematurely. Since we already have a storage for owned small weights already we can store such weights on behave of the user and ensure the weights stay alive during the lifetime of `NetworkDefinition`.
34c86d7 to
dec817b
Compare
theHamsta
commented
Apr 1, 2026
| /// Same as [`Self::add_convolution`] but allows to set weights later (e.g. dynamic kernel and bias) | ||
| /// | ||
| /// See [`trtx_sys::nvinfer1::INetworkDefinition::addConvolutionNd`]. | ||
| pub fn add_convolution_deferrred_weights( |
Contributor
Author
There was a problem hiding this comment.
we could not add this method and then also make kernel weights optional. but maybe an explicit function for that gives a hint that this is possible at all
Contributor
There was a problem hiding this comment.
It looks like a deficit in the original TRT-RTX interface. Your solution is a good workaround for now.
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.
feat: allow to take ownership of ConvWeights
It's difficult for users of trtx to create temporary weights for convolutions
if they decide to perform the swizzling themselves (they could also swizzle using TensorRT layers).
The ownership model expects that the user can prove that weights remain
valid throughout the whole lifetime of
NetworkDefinition. This istypically done by non-exclusively borrowing from weights from somewhere.
If they want to create new weights they typically need a mutual borrow and
unsafe code as a mutual borrow could also delete weights prematurely.
Since we already have a storage for owned small weights already we can store such
weights on behave of the user and ensure the weights stay alive during
the lifetime of
NetworkDefinition.