Repository navigation
TF-TRT Improve matrix multiplication conversion and enable dynamic shape mode - #47215
Merged
copybara-service[bot] merged 1 commit intoFeb 26, 2021
Merged
Conversation
bixia1
reviewed
Feb 18, 2021
bixia1
left a comment
Contributor
There was a problem hiding this comment.
Thanks for your work!
I finished reviewing the code, but not the test yet. Sending out the comments I have now.
tfeher
force-pushed
the
trt_matmul_dynamic_shape6
branch
from
February 22, 2021 21:15
f9a52b0 to
f7fb167
Compare
tfeher
commented
Feb 22, 2021
bixia1
reviewed
Feb 23, 2021
bixia1
left a comment
Contributor
There was a problem hiding this comment.
Please remember to rebase and squash.
tfeher
force-pushed
the
trt_matmul_dynamic_shape6
branch
from
February 24, 2021 11:18
f7fb167 to
2fb6a21
Compare
tfeher
commented
Feb 24, 2021
bixia1
reviewed
Feb 24, 2021
bixia1
left a comment
Contributor
There was a problem hiding this comment.
Thanks for your work! Just one remaining thing: there is one place where you said you put a more detail description but I couldn't find it by searching the string in the code.
tfeher
force-pushed
the
trt_matmul_dynamic_shape6
branch
from
February 24, 2021 17:39
2fb6a21 to
5136ce1
Compare
bixia1
approved these changes
Feb 24, 2021
Contributor
Author
|
I have fixed the missing comment. |
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 improves the MatMul and BatchMatMul converters.
IMatrixMultiplyLayeris not necessary, becauseIMatrixMultiplyLayercan directly pass the transpose flags to the underlaying GEMM call, which can use it to access elements with the correct stride without any actual transposition.IFullyConnectedLayer(FC) usage fixed:IMatrixMultiplybecause it is expected to give better performance. Moreover, currently only FC layer supprorts INT8 precision.BatchMatMulto FC: broadcast now preserves the information whether the input is tensor or weight, so that we can correctly check FC compatibility condition.BatchMatMulinvolves a potential broadcast step. TRT requires that the input tensors have the same rank, with 1 values filled in the dimensions which need to be broadcasted. A helper functionBroadcastTensorswas added to make the tensors match in rank. In dynamic shape mode we need shape inference for this step. TheDynamicReshapefunction was modified to allow insertion of multiple singleton dimensions.Tagging @bixia1 for review and @DEKHTIARJonathan for visibility.
Tracker: #45481