diff --git a/paddle/fluid/inference/tensorrt/op_teller.cc b/paddle/fluid/inference/tensorrt/op_teller.cc index 9c1939a064a6dd37404eaf7841d4f695ceca4aab..ecc089e134a3ff93546c57a57ba84c29c95a515e 100644 --- a/paddle/fluid/inference/tensorrt/op_teller.cc +++ b/paddle/fluid/inference/tensorrt/op_teller.cc @@ -639,8 +639,12 @@ struct SimpleOpTypeSetTeller : public Teller { int axis = desc.HasAttr("axis") ? PADDLE_GET_CONST(int64_t, desc.GetAttr("axis")) : -1; - bool flatten = PADDLE_GET_CONST(bool, desc.GetAttr("flatten")); - int dtype = PADDLE_GET_CONST(int, desc.GetAttr("dtype")); + bool flatten = desc.HasAttr("flatten") + ? PADDLE_GET_CONST(bool, desc.GetAttr("flatten")) + : false; + int dtype = desc.HasAttr("dtype") + ? PADDLE_GET_CONST(int, desc.GetAttr("dtype")) + : 3; if (axis == 0 || flatten || dtype != 2) return false; }