diff --git a/paddle/fluid/framework/op_registry.h b/paddle/fluid/framework/op_registry.h index a53a81c270aeec1b6ee4ed30e77526f4ea2e7977..3f14f47f0dddc0f203d03fcdcdb3213291ab6bdb 100644 --- a/paddle/fluid/framework/op_registry.h +++ b/paddle/fluid/framework/op_registry.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include +#include #include #include #include @@ -53,8 +54,9 @@ class Registrar { template struct OperatorRegistrar : public Registrar { explicit OperatorRegistrar(const char* op_type) { - PADDLE_ENFORCE(!OpInfoMap::Instance().Has(op_type), - "'%s' is registered more than once.", op_type); + if (OpInfoMap::Instance().Has(op_type)) { + PADDLE_THROW("'%s' is registered more than once.", op_type); + } static_assert(sizeof...(ARGS) != 0, "OperatorRegistrar should be invoked at least by OpClass"); OpInfo info; @@ -206,7 +208,8 @@ struct OpKernelRegistrarFunctorEx