未验证 提交 bbc837ee 编写于 作者: S Shang Zhizhou 提交者: GitHub

add info log for trt input dynamic shape check (#27796)

* add info log for trt input dynamic shape check

* fix error msg error
上级 445634fa
...@@ -164,6 +164,7 @@ class OpConverter { ...@@ -164,6 +164,7 @@ class OpConverter {
const std::unordered_set<std::string>& parameters, const std::unordered_set<std::string>& parameters,
const std::vector<std::string>& outputs, TensorRTEngine* engine) { const std::vector<std::string>& outputs, TensorRTEngine* engine) {
engine->InitNetwork(); engine->InitNetwork();
bool all_dynamic_shape_set = true;
for (auto& input : inputs) { for (auto& input : inputs) {
if (parameters.count(input)) continue; if (parameters.count(input)) continue;
auto* var = block_desc->FindVar(input); auto* var = block_desc->FindVar(input);
...@@ -181,6 +182,13 @@ class OpConverter { ...@@ -181,6 +182,13 @@ class OpConverter {
auto max_input_shape = engine->max_input_shape()[input]; auto max_input_shape = engine->max_input_shape()[input];
auto optim_input_shape = engine->optim_input_shape()[input]; auto optim_input_shape = engine->optim_input_shape()[input];
size_t ranks = min_input_shape.size(); 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; std::vector<int64_t> input_shape;
input_shape.push_back(-1); input_shape.push_back(-1);
for (size_t i = 1; i < ranks; i++) { for (size_t i = 1; i < ranks; i++) {
...@@ -207,6 +215,10 @@ class OpConverter { ...@@ -207,6 +215,10 @@ class OpConverter {
Vec2TRT_Dims(var_shape, input)); 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(); framework::proto::BlockDesc* block_proto = block_desc->Proto();
ConvertBlock(*block_proto, parameters, scope, engine); ConvertBlock(*block_proto, parameters, scope, engine);
for (auto& output : outputs) { for (auto& output : outputs) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册