|
20 | 20 | #include <string>
|
21 | 21 | #include <unordered_map>
|
22 | 22 | #include <unordered_set>
|
| 23 | +#include <utility> |
23 | 24 | #include <vector>
|
24 | 25 |
|
25 | 26 | #include "paddle/fluid/framework/executor.h"
|
@@ -212,11 +213,25 @@ class TensorRTEngineOp : public framework::OperatorBase {
|
212 | 213 | i_shape.end());
|
213 | 214 | std::vector<int64_t> runtime_input_shape(t_shape.begin() + 1,
|
214 | 215 | 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)); |
220 | 235 | }
|
221 | 236 |
|
222 | 237 | runtime_batch = t_shape[0];
|
|
0 commit comments