Repository navigation
Test Squeeze op converter in dynamic shape mode - #38146
Conversation
| void AddTestTensor( | ||
| const string& name, const std::vector<int32>& dims, int batch_size = 1, | ||
| bool HasStaticShape(std::vector<int> dims) const { | ||
| return !absl::c_any_of(dims, [](int i) { return i == -1; }); |
There was a problem hiding this comment.
The existing code uses comparison i < 0, and there is a reason for this -- if the dimension values come from graph properties, the negative values actually represent the group of the symbolic dimension value.
tensorflow/tensorflow/compiler/tf2tensorrt/convert/convert_nodes_test.cc
Lines 1345 to 1351 in 958d2c1
There was a problem hiding this comment.
The dimension values come from the test parameters that we define. I do not mind changing it to i < 0 to be on the safe side. Originally, I have assumed that the dimensions represent a PartialTensorShape. Is there any valid negative value apart from -1 for a PartialTensorShape?
|
Thanks @bixia1 for the review. I am working on fixing the issues, I will update soon. |
tfeher
left a comment
There was a problem hiding this comment.
I have addressed the the issues. As part of making the test Value-Parameterized, I have done some additional changes:
- Introduced
TrtTestModeenum to enumerate test options: implicit/explicit batch & dynamic shape mode. - Added more test params (apart from TrtTestMode):
Converterprecision and input tensor dtype.
Using these the test coverage of ConvertSqueeze is improved:
- Now all the test run in dynamic shape mode (earlier only those run in dynamic shape mode where we defined partial_input_dims manually).
- The converter can be tested for multiple input types and conversion precision.
Additional changes:
-
Previously, precision mode was set through the
precision_mode_to_test_member variable ofOpConverterTest. Removed the member variable and addedprecision_mode_to_testas an argument ofOpConverterTest::Reset().Resetcalls the constructor of theConverterand sets the TensorRT precision mode there. -
Noticed that
precision_modearg ofOpConverterTest::BuildAndRunis not used. Removed it.
To facilitate reusing the same set of changes for other OpConverterTests, I have moved all the inptut tensor initializing result checking code into helper routines:
AddTestTensor(withtrt_modearg),RunValidationAndConversion,BuildAndRunConvertedNetwork
| void AddTestTensor( | ||
| const string& name, const std::vector<int32>& dims, int batch_size = 1, | ||
| bool HasStaticShape(std::vector<int> dims) const { | ||
| return !absl::c_any_of(dims, [](int i) { return i == -1; }); |
There was a problem hiding this comment.
The dimension values come from the test parameters that we define. I do not mind changing it to i < 0 to be on the safe side. Originally, I have assumed that the dimensions represent a PartialTensorShape. Is there any valid negative value apart from -1 for a PartialTensorShape?
bixia1
left a comment
There was a problem hiding this comment.
Temporarily approving this for myself to further look at this within google.
This PR adds tests for dynamic shape mode for TF-TRT ConvertSqueeze.
PR #38118 is required for of this PR, please review that first. Tagging @bixia1 for review.