diff --git a/paddle/fluid/inference/tensorrt/convert/reshape_op.cc b/paddle/fluid/inference/tensorrt/convert/reshape_op.cc index 5ad9bdcae7a069fa2331e9b7660d2ad65f077354..5ad2f9eefc2458d13c4dfaa458d3849ac92e75ff 100644 --- a/paddle/fluid/inference/tensorrt/convert/reshape_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/reshape_op.cc @@ -70,6 +70,16 @@ class ReshapeOpConverter : public OpConverter { layer->setReshapeDimensions(reshape_dim); else layer->setInput(1, *real_shape_tensor); + + PADDLE_ENFORCE_GE( + layer->getOutput(0)->getDimensions().nbDims, + 0, + platform::errors::InvalidArgument( + "Errors occures in Paddle-TRT reshape2 op, try to use C++ Api " + "config.Exp_DisableTensorRtOPs({\"reshape2\"})\n; or Python Api " + "config.exp_disable_tensorrt_ops([\"reshape2\"]) to forbid " + "reshape2 op into " + "Paddle-TRT.")); auto output_name = op_desc.Output("Out")[0]; RreplenishLayerAndOutput(layer, "reshape", {output_name}, test_mode); }