diff --git a/paddle/fluid/operators/tensorrt/tensorrt_engine_op.h b/paddle/fluid/operators/tensorrt/tensorrt_engine_op.h index 22c0c9e9d4af3233e3cc712d26d13eb38b302abf..02e272ec35758de2d504262ded204cebd89ac27f 100644 --- a/paddle/fluid/operators/tensorrt/tensorrt_engine_op.h +++ b/paddle/fluid/operators/tensorrt/tensorrt_engine_op.h @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "paddle/fluid/framework/executor.h" @@ -212,11 +213,25 @@ class TensorRTEngineOp : public framework::OperatorBase { i_shape.end()); std::vector runtime_input_shape(t_shape.begin() + 1, t_shape.end()); - PADDLE_ENFORCE_EQ(model_input_shape == runtime_input_shape, true, - "Input shapes are inconsistent with the model. TRT 5 " - "or lower version " - "does not support dynamic input shapes. Please check " - "your input shapes."); + auto comma_fold = [](std::string a, int b) { + return std::move(a) + ", " + std::to_string(b); + }; + std::string model_input_shape_str = std::accumulate( + std::next(model_input_shape.begin()), model_input_shape.end(), + std::to_string(model_input_shape[0]), comma_fold); + std::string runtime_input_shape_str = std::accumulate( + std::next(runtime_input_shape.begin()), runtime_input_shape.end(), + std::to_string(runtime_input_shape[0]), comma_fold); + PADDLE_ENFORCE_EQ( + model_input_shape == runtime_input_shape, true, + platform::errors::InvalidArgument( + "Input shapes are inconsistent with the model. Expect [%s] in " + "model description, but got [%s] in runtime. TRT 5 " + "or lower version " + "does not support dynamic input shapes. Please check and " + "modify " + "your input shapes.", + model_input_shape_str, runtime_input_shape_str)); } runtime_batch = t_shape[0];