-
Notifications
You must be signed in to change notification settings - Fork 363
Adds support for serialization and deseralization for compiled TorchScript modules #74
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
Merged
Conversation
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
making generated TorchScript programs portable Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
will serve as a replacement to trtorchexec and act like a GCC style compiler for TorchScript Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
deserializing modules in python Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
dynamic inputs Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
tensorrt internal custom classes Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
dynamic, to use in converters for handling it seperately Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
converter implementations Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
method Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
serialized TRTorch programs Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
about what is going on Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
frank-wei
pushed a commit
that referenced
this pull request
Jun 4, 2022
…roperly (#74) Summary: Pull Request resolved: https://github.com/pytorch/fx2trt/pull/74 ## Root cause We have code like: ``` x = ... # result shape is [batch_size, N] y = mean(y, dim=1, keepdim=False) # result shape is [batch_size] z = y + 0.5 # result shape is [batch_size] ``` For TRT with implicit batch dimension it should look like: ``` x = ... # result shape is [N] y = mean(y, dim=1, keepdim=False) # result shape is [] z = y + 0.5 # result shape is [] ``` However, because we convert scalar to `TRTTensor` and don't do dimensions squeeze for it, the resulting tensor `z` would have shape `[1]`, and this is gonna break the rest of the net. ## Solution Convert the scalar value to `torch.Tensor`, because we have dimensions squeeze logic implemented for them. ## P.S.: Also added support for `sqrt` tracing. Reviewed By: yinghai, houseroad Differential Revision: D36336816 fbshipit-source-id: 412e44e99f25ab3549df540a87bd005e6b3fe08a
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
Adds support for embedded TensorRT engines into TorchScript modules, allowing serialization and deserialization of compiled TorchScript modules. Also introduces trtorchc, a CLI for the compiler which can compile then serialize modules to load into Python or C++ via standard PyTorch APIs. Various code tweaks and fixing two operators which broke on dynamic input.
Closes #40
Type of change
Please delete options that are not relevant and/or add your own.
Checklist:
make html
in docsrc)