diff --git a/paddle/fluid/framework/no_need_buffer_vars_inference.h b/paddle/fluid/framework/no_need_buffer_vars_inference.h index 2c933659840d02e65c3b222144a31e558e8e8ae8..a63575611bced370d04b3847c7eb3500cb37bad8 100644 --- a/paddle/fluid/framework/no_need_buffer_vars_inference.h +++ b/paddle/fluid/framework/no_need_buffer_vars_inference.h @@ -45,15 +45,16 @@ class NoNeedBufferVarsInference { const AttributeMap &attrs_; }; -#define DECLARE_NO_NEED_BUFFER_VARS_INFERENCE(class_type, ...) \ - class class_type : public ::paddle::framework::NoNeedBufferVarsInference { \ - public: \ - using ::paddle::framework::NoNeedBufferVarsInference:: \ - NoNeedBufferVarsInference; \ - \ - std::unordered_set operator()() const override { \ - return {__VA_ARGS__}; \ - } \ +#define DECLARE_NO_NEED_BUFFER_VARS_INFERENCE(class_type, ...) \ + class class_type final \ + : public ::paddle::framework::NoNeedBufferVarsInference { \ + public: \ + using ::paddle::framework::NoNeedBufferVarsInference:: \ + NoNeedBufferVarsInference; \ + \ + std::unordered_set operator()() const final { \ + return {__VA_ARGS__}; \ + } \ } } // namespace framework diff --git a/paddle/fluid/operators/assign_op.cc b/paddle/fluid/operators/assign_op.cc index 871dfe67343dbe58296095e1df8668e0ebd11d45..ff423778c5982c31a5ff5b0a0e264750ad81ed04 100644 --- a/paddle/fluid/operators/assign_op.cc +++ b/paddle/fluid/operators/assign_op.cc @@ -144,12 +144,14 @@ class AssignGradMaker : public framework::SingleGradOpDescMaker { } }; +DECLARE_INPLACE_OP_INFERER(AssignOpInplaceInferer, {"X", "Out"}); + } // namespace operators } // namespace paddle namespace ops = paddle::operators; REGISTER_OPERATOR(assign, ops::AssignOp, ops::AssignGradMaker, - ops::AssignOpProtoMaker); + ops::AssignOpProtoMaker, ops::AssignOpInplaceInferer); REGISTER_OP_CPU_KERNEL_FUNCTOR(assign, float, ops::AssignKernel, double, ops::AssignKernel, int, ops::AssignKernel, int64_t, ops::AssignKernel);