Skip to content

Commit badaaee

Browse files
author
Pei Yang
authored
show shape diff in wrong trt input shape errmsg, test=develop (#21451) (#21470)
1 parent ccb508d commit badaaee

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

paddle/fluid/operators/tensorrt/tensorrt_engine_op.h

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <string>
2121
#include <unordered_map>
2222
#include <unordered_set>
23+
#include <utility>
2324
#include <vector>
2425

2526
#include "paddle/fluid/framework/executor.h"
@@ -212,11 +213,25 @@ class TensorRTEngineOp : public framework::OperatorBase {
212213
i_shape.end());
213214
std::vector<int64_t> runtime_input_shape(t_shape.begin() + 1,
214215
t_shape.end());
215-
PADDLE_ENFORCE_EQ(model_input_shape == runtime_input_shape, true,
216-
"Input shapes are inconsistent with the model. TRT 5 "
217-
"or lower version "
218-
"does not support dynamic input shapes. Please check "
219-
"your input shapes.");
216+
auto comma_fold = [](std::string a, int b) {
217+
return std::move(a) + ", " + std::to_string(b);
218+
};
219+
std::string model_input_shape_str = std::accumulate(
220+
std::next(model_input_shape.begin()), model_input_shape.end(),
221+
std::to_string(model_input_shape[0]), comma_fold);
222+
std::string runtime_input_shape_str = std::accumulate(
223+
std::next(runtime_input_shape.begin()), runtime_input_shape.end(),
224+
std::to_string(runtime_input_shape[0]), comma_fold);
225+
PADDLE_ENFORCE_EQ(
226+
model_input_shape == runtime_input_shape, true,
227+
platform::errors::InvalidArgument(
228+
"Input shapes are inconsistent with the model. Expect [%s] in "
229+
"model description, but got [%s] in runtime. TRT 5 "
230+
"or lower version "
231+
"does not support dynamic input shapes. Please check and "
232+
"modify "
233+
"your input shapes.",
234+
model_input_shape_str, runtime_input_shape_str));
220235
}
221236

222237
runtime_batch = t_shape[0];

0 commit comments

Comments
 (0)