You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BuildAndRun is used by the TF-TRT op converter tests to initialize TRT bindings and execute inference. Its role is roughly equivalent to ExecuteTrtEngine. Recently ExecuteTrtEngine was modified to handle inference using dynamic shapes (PRs #36379, #36434, #36435), the same was not done for the opconverter's BuildAndRun. To allow unit testing of op converters in dynamic shape mode, one needs the extend BuildAndRun with similar changes.
This PR refactors ExecuteTRTEngine, so that both BuildAndRun and ExecuteTrtEngie can use a common set of utility functions to run inference. While doing these changes, the logging is streamlined: we return a status with the log message if an error occurs.
For easier comparison, one could do something like:
git show master:tensorflow/compiler/tf2tensorrt/kernels/trt_engine_op.cc | sed -n '619,868p' > ExecuteTrtEngine_master.cc && diff ExecuteTrtEngine_master.cc tensorflow/compiler/tf2tensorrt/utils/trt_engine_utils.cc
This PR does not add new tests, nor does it modify any existing behavior. This PR is a prerequisite of op converter tests in dynamic shape mode.
An alternative solution to this PR would be to copy the relevant code to BuildAndRun, but this would further increase the already existing code duplication between ExecuteTrtEngine and BuildAndRun. Furthermore, the exact way of specifying the input shapes is subject to change (for example currently we do not specify input shape bindings, and it might be required in the future). Therefore it is preferred to reuse code between BuildAndRun and ExecuteTrtEngine.
The merge process is blocked due to the error below, can you please fix this?
tensorflow/compiler/tf2tensorrt/convert/utils.cc:169:3: error: ignoring return value of function declared with 'warn_unused_result' attribute [-Werror,-Wunused-result]
TensorShapeUtils::MakeShape(trt_dims.data(), trt_dims.size(), &shape);
^~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tensorflow/compiler/tf2tensorrt/convert/utils.cc:179:3: error: ignoring return value of function declared with 'warn_unused_result' attribute [-Werror,-Wunused-result]
TensorShapeUtils::MakeShape(trt_dims.d, trt_dims.nbDims, &shape);
^~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.
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
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 refactors ExecuteTrtEngine so that its components can be reused from BuildAndRun.
BuildAndRun is used by the TF-TRT op converter tests to initialize TRT bindings and execute inference. Its role is roughly equivalent to ExecuteTrtEngine. Recently ExecuteTrtEngine was modified to handle inference using dynamic shapes (PRs #36379, #36434, #36435), the same was not done for the opconverter's BuildAndRun. To allow unit testing of op converters in dynamic shape mode, one needs the extend BuildAndRun with similar changes.
This PR refactors ExecuteTRTEngine, so that both BuildAndRun and ExecuteTrtEngie can use a common set of utility functions to run inference. While doing these changes, the logging is streamlined: we return a status with the log message if an error occurs.
For easier comparison, one could do something like:
This PR does not add new tests, nor does it modify any existing behavior. This PR is a prerequisite of op converter tests in dynamic shape mode.
An alternative solution to this PR would be to copy the relevant code to BuildAndRun, but this would further increase the already existing code duplication between ExecuteTrtEngine and BuildAndRun. Furthermore, the exact way of specifying the input shapes is subject to change (for example currently we do not specify input shape bindings, and it might be required in the future). Therefore it is preferred to reuse code between BuildAndRun and ExecuteTrtEngine.
Tagging @DEKHTIARJonathan and @bixia1 for review.