Repository navigation
TensorRT profile generation mode - #36729
Merged
tensorflow-copybara merged 15 commits intoFeb 28, 2020
Merged
Conversation
Contributor
|
@tfeher Could you please resolve the conflicts? Thanks! |
Contributor
|
@tfeher Still, conflicts are appearing. Can you please resolve? Thanks! |
bixia1
reviewed
Feb 25, 2020
Currently we do not have a build() equivalent in the C++ API, therfore we cannot generate profiles. Without profiles we cannot test in explicit batch mode (which includes dynamic shapes mode too).
tfeher
commented
Feb 26, 2020
tfeher
left a comment
Contributor
Author
There was a problem hiding this comment.
Hi @bixia1, thank you for the constructive comments! I have updated the PR accordingly.
I had to disable those trt_engine_op tests that use explicit_batch_mode, because build mode (to generate profiles) is not available using the cpp API. We have python tests in trt_mode_test.py to cover these cases.
bixia1
approved these changes
Feb 27, 2020
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.
This PR adds a profile generation to dynamic shapes mode.
This features completes the ground work for dynamic shapes mode. Profile generation mode is enabled during build(), and collects information of the input shapes for TRT engines. This information is used to generate a singe engine with multiple profiles.
Dynamic shape mode is an experimental feature. The advantage of dynamic shapes is that we can use a single TensorRT engine with multiple profiles to handle input data with different shapes. This saves memory: all input profiles for an engine can share the same weights. Input dimensions that do not influence the number of model parameters can be dynamic (batch size, sequence length, even image dimensions for fully convolutional networks). Currently we generate a separate profile for each input shape that was provided during build mode.
This feature does not support defining profiles during runtime, only during build mode. This makes it important for users to feed data to build() with all interesting shapes so that the single engine can execute those shapes. Currently this feature does not support INT8 calibration.
This feature is not supposed to change any of the existing behavior of TF-TRT in implicit batch mode. Explicit batch mode is changed: it is now required to use build() to generate the engines.
It is expected to use this feature for elementwise ops. We are soon going to enable all the existing converters to work with this feature. An example on how to use this feature: