diff --git a/paddle/framework/backward.cc b/paddle/framework/backward.cc index 3d81dadfc4a861eb4aad494c6bff7b8a3ed2ca45..01ef385fd853e8bb435f35574b46c775086ec7a2 100644 --- a/paddle/framework/backward.cc +++ b/paddle/framework/backward.cc @@ -39,9 +39,9 @@ static inline std::unique_ptr CreateGradOp( std::transform(grad_descs.begin(), grad_descs.end(), std::back_inserter(grad_ops), [](const std::unique_ptr& grad_desc) { - return OpRegistry::CreateOp(grad_desc.get()); + return OpRegistry::CreateOp(*grad_desc); }); - PADDLE_ENFORCE_GT(grad_ops.size(), 0); + PADDLE_ENFORCE(!grad_ops.empty()); if (grad_ops.size() == 1) { return std::move(grad_ops[0]); } else { diff --git a/paddle/framework/op_registry.cc b/paddle/framework/op_registry.cc index 4dc83ec8fea12d3ad027fca11a736590d9a4da02..e9d2e5587282250d1f9fcd952cb1c0b002d2b5bb 100644 --- a/paddle/framework/op_registry.cc +++ b/paddle/framework/op_registry.cc @@ -54,9 +54,9 @@ std::unique_ptr OpRegistry::CreateOp(const OpDesc& op_desc) { return CreateOp(op_desc.type(), inputs, outputs, attrs); } -std::unique_ptr OpRegistry::CreateOp(OpDescBind* op_desc) { - return CreateOp(op_desc->Type(), op_desc->Inputs(), op_desc->Outputs(), - op_desc->GetAttrMap()); +std::unique_ptr OpRegistry::CreateOp(const OpDescBind& op_desc) { + return CreateOp(op_desc.Type(), op_desc.Inputs(), op_desc.Outputs(), + op_desc.GetAttrMap()); } } // namespace framework diff --git a/paddle/framework/op_registry.h b/paddle/framework/op_registry.h index a4f0144ce845bda2b4792d03b637fd98b5c7ce14..4bf521c48d575e20b751216ef07057ef174f1512 100644 --- a/paddle/framework/op_registry.h +++ b/paddle/framework/op_registry.h @@ -79,7 +79,7 @@ class OpRegistry { static std::unique_ptr CreateOp(const OpDesc& op_desc); - static std::unique_ptr CreateOp(OpDescBind* op_desc); + static std::unique_ptr CreateOp(const OpDescBind& op_desc); }; template