Skip to content

Commit

Permalink
add info log for trt input dynamic shape check (#27796)
Browse files Browse the repository at this point in the history
* add info log for trt input dynamic shape check

* fix error msg error
  • Loading branch information
shangzhizhou authored Oct 13, 2020
1 parent 445634f commit bbc837e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions paddle/fluid/inference/tensorrt/convert/op_converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ class OpConverter {
const std::unordered_set<std::string>& parameters,
const std::vector<std::string>& outputs, TensorRTEngine* engine) {
engine->InitNetwork();
bool all_dynamic_shape_set = true;
for (auto& input : inputs) {
if (parameters.count(input)) continue;
auto* var = block_desc->FindVar(input);
Expand All @@ -181,6 +182,13 @@ class OpConverter {
auto max_input_shape = engine->max_input_shape()[input];
auto optim_input_shape = engine->optim_input_shape()[input];
size_t ranks = min_input_shape.size();
if (ranks == 0) {
all_dynamic_shape_set = false;
LOG(INFO) << "trt input [" << input.c_str()
<< "] dynamic shape info not set, please check and retry.";
// check other input
continue;
}
std::vector<int64_t> input_shape;
input_shape.push_back(-1);
for (size_t i = 1; i < ranks; i++) {
Expand All @@ -207,6 +215,10 @@ class OpConverter {
Vec2TRT_Dims(var_shape, input));
}
}
PADDLE_ENFORCE_EQ(all_dynamic_shape_set, true,
platform::errors::InvalidArgument(
"some trt inputs dynamic shape info not set, "
"check the INFO log above for more details."));
framework::proto::BlockDesc* block_proto = block_desc->Proto();
ConvertBlock(*block_proto, parameters, scope, engine);
for (auto& output : outputs) {
Expand Down

0 comments on commit bbc837e

Please sign in to comment.