Repository navigation
Add TF-TRT optimization profiles for testing - #45588
Conversation
tfeher
left a comment
There was a problem hiding this comment.
Thanks @bixia1 for the review. There is a misunderstanding where the accumulation for min/max profiles should take place: that should go to InitProfiles(), or subroutines called from initprofiles. OptimizationProfileConfig::SetDimensions just enforces consistency with the network input shape. I have updated the docstring for the latter, please have a look.
33d8ce0 to
40243d8
Compare
|
@tfeher Can you please check @DEKHTIARJonathan's comments and keep us posted ? Thanks! |
|
It has been 15 days with no activity and the |
40243d8 to
b768e0f
Compare
b768e0f to
d702b80
Compare
|
One more thing: with this PR, now tensorflow/python/compiler/tensorrt:trt_mode_test fails in TF2 with cuda 11 and TensorRT 7 (--test_env=TF2_BEHAVIOR=1). Here is one subtest and error message: google3.third_party.tensorflow.python.framework.errors_impl.AbortedError: User disallowed engine native segment execution |
d702b80 to
bd38eb1
Compare
|
@tfeher Can you please resolve conflicts? Thanks! |
|
We are having some offline discussion on the solution to workaround the TensorRT bugs mentioned in the PR. |
0a6a7f8 to
1b0b5aa
Compare
|
@bixia1, I have updated the PR based on our offline discussion: the TRT bug workaround is handled now in any optimization profile strategy by adjusting profile parameters for input tensors that are shape value compatible. Additionally, the error in the python test is fixed. Please have a look. |
1bfb148 to
00903b4
Compare
00903b4 to
0e9bc4d
Compare
tfeher
left a comment
There was a problem hiding this comment.
Hi @bixia1, sorry missing the test error, I have corrected that together with the remaining issues.
I have also found an issue with trt_engine_op_test. While from fixing that, I have modifed trt_engine_op not to throw on error in dynamic shape mode if shape information for optimization profiles were not collected. This is achieved by adding a default profile for the current input shape if no profiles were collected.
Additionally, two bugs are fixed:
- The profile index in case of newly created engine was not set,
- Error was not handled while setting the input binding size.
I have updated the PR description accordingly.
0e9bc4d to
5af4a62
Compare
Additionally, profile handling improved in dynamic shape mode: if profile generation mode was not used, then we create a a single implicit batch like profile using the current input shape.
|
@bixia1, this seems to be stuck. Can you have a look? |
|
I couldn't figure out what is going on either. I tried to do it manually, and got this error. Trying to seek help internally. |
5af4a62 to
f5c929c
Compare
TF-TRT dynamic shape feature requires the creation of optimization profiles. Currently just a basic optimization profile is created where we set min = opt = max = input_shape. Let's call this
optimalprofile.This PR implements an additional optimization profile generation strategies:
For any shape tensor compatible input the profile is adjusted to have max > min. The goal here is to enable unit testing of converters that have shape input. This requires optimization profile where max != min. Otherwise the shape input tensor is known at build time (equals with min=opt=max), and TRT7 drops it from the list of input bindings. (This problem will probably be corrected in an upcoming version of TRT).
Additionally, profile handling improved in dynamic shape mode. Previously it required to run
profile_generation_mode, otherwise engine creation failed. This condition was relaxed: if profile generation mode was not used, then we create a single implicit batch like profile using the current input shape. This improves testing of the trt_engine_op, additionally this will provide an implicit batch mode compatible fall-back for users that do not wish to build the engine in advance.A follow up PR shall implement additional optimization profile strategies.
Additionally, two bugs are fixed:
Tagging @bixia1 for review and @DEKHTIARJonathan for visibility.