From 511b5af86f5b7e2c0d61404950e65c2af3eb8e62 Mon Sep 17 00:00:00 2001 From: pangyoki Date: Tue, 12 Apr 2022 14:13:16 +0000 Subject: [PATCH 1/7] support no_need_buffer in eager_fluid state --- .../auto_code_generator/eager_generator.cc | 49 ++++++++++++++++--- paddle/fluid/pybind/op_function_generator.h | 5 ++ .../fluid/tests/unittests/test_inplace.py | 14 ++++++ 3 files changed, 62 insertions(+), 6 deletions(-) diff --git a/paddle/fluid/eager/auto_code_generator/eager_generator.cc b/paddle/fluid/eager/auto_code_generator/eager_generator.cc index de44a833f6e73..80094ea867dc2 100644 --- a/paddle/fluid/eager/auto_code_generator/eager_generator.cc +++ b/paddle/fluid/eager/auto_code_generator/eager_generator.cc @@ -150,12 +150,20 @@ class ForwardGenerationInfo { } std::vector* GetMutableOutVars() { return &out_vars_; } + const std::unordered_set& GetNoNeedBufferInputs() const { + return no_need_buffer_ins_; + } + std::unordered_set* GetMutableNoNeedBufferInputs() { + return &no_need_buffer_ins_; + } + private: std::string op_type_; std::unordered_map fwd_inputs_name_pos_map_; std::unordered_map fwd_outputs_name_pos_map_; std::vector in_vars_; std::vector out_vars_; + std::unordered_set no_need_buffer_ins_; }; class GradNodeGenerationInfo { @@ -762,6 +770,21 @@ static void CollectForwardInformationFromOpInfo( for (const proto::OpProto::Var& output : op_proto.outputs()) { fwd_info->GetMutableOutVars()->push_back(output); } + + auto& inferer = op_info.NoNeedBufferVarsInferer(); + if (inferer) { + paddle::imperative::NameVarMap inputs = + {}; + paddle::imperative::NameVarMap + outputs = {}; + paddle::framework::AttributeMap attrs = {}; + *fwd_info->GetMutableNoNeedBufferInputs() = inferer(inputs, outputs, attrs); + } + if (fwd_info->GetNoNeedBufferInputs().empty() && + no_need_buffer_map.count(op_proto.type())) { + *fwd_info->GetMutableNoNeedBufferInputs() = + no_need_buffer_map[op_proto.type()]; + } } static bool CollectGradInformationFromOpInfo( @@ -994,6 +1017,8 @@ static std::string GenerateGradNodeCreationContent( fwd_info.GetFwdOutputsNamePosMap(); const std::vector& in_vars = fwd_info.GetInVars(); const std::vector& out_vars = fwd_info.GetOutVars(); + const std::unordered_set& no_need_buffer_ins = + fwd_info.GetNoNeedBufferInputs(); const auto& op_base_infos = bwd_info.GetOpBaseInfos(); @@ -1133,7 +1158,8 @@ static std::string GenerateGradNodeCreationContent( const std::string& tensor_wrapper_name = kv.second; std::string full_reserved = "false"; if (fwd_outputs_name_pos_map.find(tensor_wrapper_name) == - fwd_outputs_name_pos_map.end()) { + fwd_outputs_name_pos_map.end() && + !no_need_buffer_ins.count(tensor_wrapper_name)) { full_reserved = "true"; } const char* SET_TENSOR_WRAPPER_TEMPLATE = @@ -2456,6 +2482,8 @@ static std::string GenerateGradNodeHeaderContents( const std::string& op_type = fwd_info.GetOpType(); const std::vector& in_vars = fwd_info.GetInVars(); const std::vector& out_vars = fwd_info.GetOutVars(); + const std::unordered_set& no_need_buffer_ins = + fwd_info.GetNoNeedBufferInputs(); const auto& op_base_infos = bwd_info.GetOpBaseInfos(); @@ -2541,6 +2569,10 @@ static std::string GenerateGradNodeHeaderContents( std::string tensor_wrapper_arg_str; std::string tensor_wrapper_body_str; std::string full_reserved_str = "full_reserved"; + std::string no_need_buffer_str = "false"; + if (no_need_buffer_ins.count(tensor_wrapper_name)) { + no_need_buffer_str = "true"; + } if (duplicable_tensors.count(tensor_wrapper_name)) { const char* ATTR_TENSOR_WRAPPER_ARG_TEMPLATE = "const std::vector& %s"; @@ -2554,12 +2586,12 @@ static std::string GenerateGradNodeHeaderContents( const char* SET_TENSOR_WRAPPER_BODY_TEMPLATE = "for(const auto& eager_tensor : %s) {\n" - " %s.emplace_back( egr::TensorWrapper(eager_tensor, true " - "/*full_reserved*/) );\n" + " %s.emplace_back( egr::TensorWrapper(eager_tensor, %s " + "/*full_reserved*/, %s) );\n" " }\n"; tensor_wrapper_body_str = paddle::string::Sprintf( SET_TENSOR_WRAPPER_BODY_TEMPLATE, tensor_wrapper_name, - struct_tensor_wrapper_name); + struct_tensor_wrapper_name, full_reserved_str, no_need_buffer_str); const char* CLEAR_TENSOR_WRAPPER_TEMPLATE = "for (auto tw: %s) {\n" @@ -2580,10 +2612,10 @@ static std::string GenerateGradNodeHeaderContents( TENSOR_WRAPPER_MEMBER_TEMPLATE, struct_tensor_wrapper_name); const char* SET_TENSOR_WRAPPER_BODY_TEMPLATE = - "%s = egr::TensorWrapper(%s, %s /*full_reserved*/);\n"; + "%s = egr::TensorWrapper(%s, %s /*full_reserved*/, %s);\n"; tensor_wrapper_body_str = paddle::string::Sprintf( SET_TENSOR_WRAPPER_BODY_TEMPLATE, struct_tensor_wrapper_name, - tensor_wrapper_name, full_reserved_str); + tensor_wrapper_name, full_reserved_str, no_need_buffer_str); const char* CLEAR_TENSOR_WRAPPER_TEMPLATE = " %s.clear();\n"; clear_tensor_wrappers_str += paddle::string::Sprintf( @@ -2773,6 +2805,11 @@ static void DygraphCodeGeneration(const std::string& output_dir) { VLOG(6) << "-------- CollectInformationFromOpInfo -------"; CollectForwardInformationFromOpInfo(op_info, &fwd_info); + // std::cout << "yoki op_type: " << fwd_info.GetOpType() << "\n"; + // if (!fwd_info.GetNoNeedBufferInputs().empty()) { + // std:: cout << "yoki no_need_buffer: " << + // *fwd_info.GetNoNeedBufferInputs().begin() << "\n"; + // } bool is_available = CollectGradInformationFromOpInfo(op_info, &bwd_info); diff --git a/paddle/fluid/pybind/op_function_generator.h b/paddle/fluid/pybind/op_function_generator.h index f1e9c7e8f491b..e2d8cb507cb7a 100644 --- a/paddle/fluid/pybind/op_function_generator.h +++ b/paddle/fluid/pybind/op_function_generator.h @@ -17,6 +17,7 @@ #include #include #include +#include // NOTE(zhiqiu): Commonly, the inputs in auto-generated OP function are // determined by the OP`s proto automatically, i.e., all the inputs registered @@ -276,3 +277,7 @@ std::set special_inplace_op_set = { "sum", // `sum` op has duplicate input "assign", // output of `assign` op is in `op_passing_outs_map` }; + +std::map> no_need_buffer_map = { + {"slice", {"Input"}}, +}; diff --git a/python/paddle/fluid/tests/unittests/test_inplace.py b/python/paddle/fluid/tests/unittests/test_inplace.py index c54d3f02d43f0..99873eaa98870 100644 --- a/python/paddle/fluid/tests/unittests/test_inplace.py +++ b/python/paddle/fluid/tests/unittests/test_inplace.py @@ -510,5 +510,19 @@ def test_continuously_inplace(self): self.func_test_continuously_inplace() +class TestGetitemBeforeInplace(unittest.TestCase): + def test_getitem_before_inplace(self): + with _test_eager_guard(): + a = paddle.ones(shape=[4, 2, 3], dtype="float32") + a.stop_gradient = False + b = a**2 + b[0] = 3 + # getitem has no_need_buffer input + c = b[0:2] + loss = c.sum() + b[1] = 2 + loss.backward() + + if __name__ == '__main__': unittest.main() From b9bbc45681857d6ffcbe204ce92cf709b04127bf Mon Sep 17 00:00:00 2001 From: pangyoki Date: Wed, 13 Apr 2022 06:41:45 +0000 Subject: [PATCH 2/7] change no_need_buffer info from fwd_info to bwd_info --- .../auto_code_generator/eager_generator.cc | 51 +++++++------------ paddle/fluid/pybind/op_function_generator.h | 5 -- 2 files changed, 19 insertions(+), 37 deletions(-) diff --git a/paddle/fluid/eager/auto_code_generator/eager_generator.cc b/paddle/fluid/eager/auto_code_generator/eager_generator.cc index 80094ea867dc2..5fe7134d9cfe6 100644 --- a/paddle/fluid/eager/auto_code_generator/eager_generator.cc +++ b/paddle/fluid/eager/auto_code_generator/eager_generator.cc @@ -150,20 +150,12 @@ class ForwardGenerationInfo { } std::vector* GetMutableOutVars() { return &out_vars_; } - const std::unordered_set& GetNoNeedBufferInputs() const { - return no_need_buffer_ins_; - } - std::unordered_set* GetMutableNoNeedBufferInputs() { - return &no_need_buffer_ins_; - } - private: std::string op_type_; std::unordered_map fwd_inputs_name_pos_map_; std::unordered_map fwd_outputs_name_pos_map_; std::vector in_vars_; std::vector out_vars_; - std::unordered_set no_need_buffer_ins_; }; class GradNodeGenerationInfo { @@ -225,6 +217,13 @@ class GradNodeGenerationInfo { return &grad_attrs_; } + const std::unordered_set& GetNoNeedBufferInputs() const { + return no_need_buffer_ins_; + } + std::unordered_set* GetMutableNoNeedBufferInputs() { + return &no_need_buffer_ins_; + } + private: std::string op_base_type_; std::map grad_outs_slotname_map_; @@ -237,6 +236,7 @@ class GradNodeGenerationInfo { std::vector>> grad_outs_; paddle::framework::AttributeMap grad_attrs_; + std::unordered_set no_need_buffer_ins_; }; public: @@ -770,21 +770,6 @@ static void CollectForwardInformationFromOpInfo( for (const proto::OpProto::Var& output : op_proto.outputs()) { fwd_info->GetMutableOutVars()->push_back(output); } - - auto& inferer = op_info.NoNeedBufferVarsInferer(); - if (inferer) { - paddle::imperative::NameVarMap inputs = - {}; - paddle::imperative::NameVarMap - outputs = {}; - paddle::framework::AttributeMap attrs = {}; - *fwd_info->GetMutableNoNeedBufferInputs() = inferer(inputs, outputs, attrs); - } - if (fwd_info->GetNoNeedBufferInputs().empty() && - no_need_buffer_map.count(op_proto.type())) { - *fwd_info->GetMutableNoNeedBufferInputs() = - no_need_buffer_map[op_proto.type()]; - } } static bool CollectGradInformationFromOpInfo( @@ -981,6 +966,13 @@ static bool CollectGradInformationFromOpInfo( VLOG(6) << "GradOuts Name: " << it.first; } } + + auto& inferer = op_base.Info().NoNeedBufferVarsInferer(); + // TODO(pangyoki): sequence_conv op will raise error and needs to be fixed + if (op_type != "sequence_conv" && inferer) { + *(*op_base_infos)[index].GetMutableNoNeedBufferInputs() = + inferer(g_ins, g_outs, *op_base_grad_attrs); + } } /* ------ Slot Name Matching ---- */ @@ -1017,8 +1009,6 @@ static std::string GenerateGradNodeCreationContent( fwd_info.GetFwdOutputsNamePosMap(); const std::vector& in_vars = fwd_info.GetInVars(); const std::vector& out_vars = fwd_info.GetOutVars(); - const std::unordered_set& no_need_buffer_ins = - fwd_info.GetNoNeedBufferInputs(); const auto& op_base_infos = bwd_info.GetOpBaseInfos(); @@ -1154,6 +1144,8 @@ static std::string GenerateGradNodeCreationContent( for (const auto& iter : op_base_infos) { const std::map& grad_ins_fwd_slotname_map = iter.GetGradInsFwdSlotnameMap(); + const std::unordered_set& no_need_buffer_ins = + iter.GetNoNeedBufferInputs(); for (auto& kv : grad_ins_fwd_slotname_map) { const std::string& tensor_wrapper_name = kv.second; std::string full_reserved = "false"; @@ -2482,8 +2474,6 @@ static std::string GenerateGradNodeHeaderContents( const std::string& op_type = fwd_info.GetOpType(); const std::vector& in_vars = fwd_info.GetInVars(); const std::vector& out_vars = fwd_info.GetOutVars(); - const std::unordered_set& no_need_buffer_ins = - fwd_info.GetNoNeedBufferInputs(); const auto& op_base_infos = bwd_info.GetOpBaseInfos(); @@ -2561,6 +2551,8 @@ static std::string GenerateGradNodeHeaderContents( for (const auto& iter : op_base_infos) { const std::map& grad_ins_fwd_slotname_map = iter.GetGradInsFwdSlotnameMap(); + const std::unordered_set& no_need_buffer_ins = + iter.GetNoNeedBufferInputs(); for (const auto& kv : grad_ins_fwd_slotname_map) { const std::string& tensor_wrapper_name = kv.second; @@ -2805,11 +2797,6 @@ static void DygraphCodeGeneration(const std::string& output_dir) { VLOG(6) << "-------- CollectInformationFromOpInfo -------"; CollectForwardInformationFromOpInfo(op_info, &fwd_info); - // std::cout << "yoki op_type: " << fwd_info.GetOpType() << "\n"; - // if (!fwd_info.GetNoNeedBufferInputs().empty()) { - // std:: cout << "yoki no_need_buffer: " << - // *fwd_info.GetNoNeedBufferInputs().begin() << "\n"; - // } bool is_available = CollectGradInformationFromOpInfo(op_info, &bwd_info); diff --git a/paddle/fluid/pybind/op_function_generator.h b/paddle/fluid/pybind/op_function_generator.h index e2d8cb507cb7a..f1e9c7e8f491b 100644 --- a/paddle/fluid/pybind/op_function_generator.h +++ b/paddle/fluid/pybind/op_function_generator.h @@ -17,7 +17,6 @@ #include #include #include -#include // NOTE(zhiqiu): Commonly, the inputs in auto-generated OP function are // determined by the OP`s proto automatically, i.e., all the inputs registered @@ -277,7 +276,3 @@ std::set special_inplace_op_set = { "sum", // `sum` op has duplicate input "assign", // output of `assign` op is in `op_passing_outs_map` }; - -std::map> no_need_buffer_map = { - {"slice", {"Input"}}, -}; From 7fa1dc13d332e057dee4e91c1ec4e16107fc63bc Mon Sep 17 00:00:00 2001 From: pangyoki Date: Wed, 13 Apr 2022 17:02:00 +0000 Subject: [PATCH 3/7] fix CI fail, gru_unit donnot use no_need_buffer --- paddle/fluid/eager/auto_code_generator/eager_generator.cc | 2 +- paddle/fluid/pybind/op_function_generator.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/eager/auto_code_generator/eager_generator.cc b/paddle/fluid/eager/auto_code_generator/eager_generator.cc index 5fe7134d9cfe6..1541eb56f9a5c 100644 --- a/paddle/fluid/eager/auto_code_generator/eager_generator.cc +++ b/paddle/fluid/eager/auto_code_generator/eager_generator.cc @@ -969,7 +969,7 @@ static bool CollectGradInformationFromOpInfo( auto& inferer = op_base.Info().NoNeedBufferVarsInferer(); // TODO(pangyoki): sequence_conv op will raise error and needs to be fixed - if (op_type != "sequence_conv" && inferer) { + if (inferer && !special_no_need_buffer_op_set.count(op_type)) { *(*op_base_infos)[index].GetMutableNoNeedBufferInputs() = inferer(g_ins, g_outs, *op_base_grad_attrs); } diff --git a/paddle/fluid/pybind/op_function_generator.h b/paddle/fluid/pybind/op_function_generator.h index f1e9c7e8f491b..5f9199f5cefab 100644 --- a/paddle/fluid/pybind/op_function_generator.h +++ b/paddle/fluid/pybind/op_function_generator.h @@ -276,3 +276,7 @@ std::set special_inplace_op_set = { "sum", // `sum` op has duplicate input "assign", // output of `assign` op is in `op_passing_outs_map` }; + +std::set special_no_need_buffer_op_set = { + "sequence_conv", "gru_unit", +}; From a9a939ed2dfaefba5d97bf6a1c35b55ecf97114b Mon Sep 17 00:00:00 2001 From: pangyoki Date: Thu, 14 Apr 2022 07:41:08 +0000 Subject: [PATCH 4/7] fix conflict between no_need_buffer and dispensable --- .../auto_code_generator/eager_generator.cc | 18 ++++++++++++++++-- paddle/fluid/pybind/op_function_generator.h | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/paddle/fluid/eager/auto_code_generator/eager_generator.cc b/paddle/fluid/eager/auto_code_generator/eager_generator.cc index 1541eb56f9a5c..a22eeb9bea61c 100644 --- a/paddle/fluid/eager/auto_code_generator/eager_generator.cc +++ b/paddle/fluid/eager/auto_code_generator/eager_generator.cc @@ -1141,6 +1141,12 @@ static std::string GenerateGradNodeCreationContent( // [GradOpNode] Set TensorWrappers grad_node_creation_str += " // Set Tensor Wrappers\n"; + std::unordered_set dispensable_input_name_set; + for (const proto::OpProto::Var& input : in_vars) { + if (input.dispensable()) { + dispensable_input_name_set.insert(input.name()); + } + } for (const auto& iter : op_base_infos) { const std::map& grad_ins_fwd_slotname_map = iter.GetGradInsFwdSlotnameMap(); @@ -1151,7 +1157,8 @@ static std::string GenerateGradNodeCreationContent( std::string full_reserved = "false"; if (fwd_outputs_name_pos_map.find(tensor_wrapper_name) == fwd_outputs_name_pos_map.end() && - !no_need_buffer_ins.count(tensor_wrapper_name)) { + !(no_need_buffer_ins.count(tensor_wrapper_name) && + !dispensable_input_name_set.count(tensor_wrapper_name))) { full_reserved = "true"; } const char* SET_TENSOR_WRAPPER_TEMPLATE = @@ -2533,6 +2540,12 @@ static std::string GenerateGradNodeHeaderContents( VLOG(6) << "Generated SetAttr"; // [Generation] Handle TensorWrappers + std::unordered_set dispensable_input_name_set; + for (const proto::OpProto::Var& input : in_vars) { + if (input.dispensable()) { + dispensable_input_name_set.insert(input.name()); + } + } std::unordered_set duplicable_tensors; for (const proto::OpProto::Var& input : in_vars) { if (input.duplicable()) { @@ -2562,7 +2575,8 @@ static std::string GenerateGradNodeHeaderContents( std::string tensor_wrapper_body_str; std::string full_reserved_str = "full_reserved"; std::string no_need_buffer_str = "false"; - if (no_need_buffer_ins.count(tensor_wrapper_name)) { + if (no_need_buffer_ins.count(tensor_wrapper_name) && + !dispensable_input_name_set.count(tensor_wrapper_name)) { no_need_buffer_str = "true"; } if (duplicable_tensors.count(tensor_wrapper_name)) { diff --git a/paddle/fluid/pybind/op_function_generator.h b/paddle/fluid/pybind/op_function_generator.h index 5f9199f5cefab..401cd53472435 100644 --- a/paddle/fluid/pybind/op_function_generator.h +++ b/paddle/fluid/pybind/op_function_generator.h @@ -278,5 +278,5 @@ std::set special_inplace_op_set = { }; std::set special_no_need_buffer_op_set = { - "sequence_conv", "gru_unit", + "sequence_conv", }; From 9e85e94f94d0c58f1273c35515652188cf6496ad Mon Sep 17 00:00:00 2001 From: pangyoki Date: Thu, 14 Apr 2022 08:30:38 +0000 Subject: [PATCH 5/7] use tensor.define in dispensable --- .../auto_code_generator/eager_generator.cc | 23 ++++--------------- paddle/fluid/pybind/op_function_generator.h | 4 ++++ 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/paddle/fluid/eager/auto_code_generator/eager_generator.cc b/paddle/fluid/eager/auto_code_generator/eager_generator.cc index a22eeb9bea61c..496debcaa252e 100644 --- a/paddle/fluid/eager/auto_code_generator/eager_generator.cc +++ b/paddle/fluid/eager/auto_code_generator/eager_generator.cc @@ -968,7 +968,6 @@ static bool CollectGradInformationFromOpInfo( } auto& inferer = op_base.Info().NoNeedBufferVarsInferer(); - // TODO(pangyoki): sequence_conv op will raise error and needs to be fixed if (inferer && !special_no_need_buffer_op_set.count(op_type)) { *(*op_base_infos)[index].GetMutableNoNeedBufferInputs() = inferer(g_ins, g_outs, *op_base_grad_attrs); @@ -1141,12 +1140,6 @@ static std::string GenerateGradNodeCreationContent( // [GradOpNode] Set TensorWrappers grad_node_creation_str += " // Set Tensor Wrappers\n"; - std::unordered_set dispensable_input_name_set; - for (const proto::OpProto::Var& input : in_vars) { - if (input.dispensable()) { - dispensable_input_name_set.insert(input.name()); - } - } for (const auto& iter : op_base_infos) { const std::map& grad_ins_fwd_slotname_map = iter.GetGradInsFwdSlotnameMap(); @@ -1157,8 +1150,7 @@ static std::string GenerateGradNodeCreationContent( std::string full_reserved = "false"; if (fwd_outputs_name_pos_map.find(tensor_wrapper_name) == fwd_outputs_name_pos_map.end() && - !(no_need_buffer_ins.count(tensor_wrapper_name) && - !dispensable_input_name_set.count(tensor_wrapper_name))) { + !no_need_buffer_ins.count(tensor_wrapper_name)) { full_reserved = "true"; } const char* SET_TENSOR_WRAPPER_TEMPLATE = @@ -2090,7 +2082,7 @@ static std::string GenerateSingleOpBase( } else { const char* DISPENSABLE_GRAD_INS_FWD_CONTENT_TEMPLATE = " auto %s = egr::EagerUtils::RecoverTensorWrapper(&this->%s, " - "nullptr);\n if(%s.initialized()) %s[\"%s\"] = " + "nullptr);\n if(%s.defined()) %s[\"%s\"] = " "egr::EagerUtils::TrySyncToVars(%s);\n"; generated_grad_function_body += paddle::string::Sprintf( DISPENSABLE_GRAD_INS_FWD_CONTENT_TEMPLATE, grad_input_name, @@ -2216,7 +2208,7 @@ static std::string GenerateSingleOpBase( grad_output_name, fwd_input_position); } else { const char* DISPENSABLE_GRAD_OUTS_FWD_CONTENT_TEMPLATE = - " if(%s.initialized()) %s[\"%s\"] = " + " if(%s.defined()) %s[\"%s\"] = " "{std::make_shared(egr::Controller::" "Instance().GenerateUniqueName())};\n"; generated_grad_function_body += paddle::string::Sprintf( @@ -2540,12 +2532,6 @@ static std::string GenerateGradNodeHeaderContents( VLOG(6) << "Generated SetAttr"; // [Generation] Handle TensorWrappers - std::unordered_set dispensable_input_name_set; - for (const proto::OpProto::Var& input : in_vars) { - if (input.dispensable()) { - dispensable_input_name_set.insert(input.name()); - } - } std::unordered_set duplicable_tensors; for (const proto::OpProto::Var& input : in_vars) { if (input.duplicable()) { @@ -2575,8 +2561,7 @@ static std::string GenerateGradNodeHeaderContents( std::string tensor_wrapper_body_str; std::string full_reserved_str = "full_reserved"; std::string no_need_buffer_str = "false"; - if (no_need_buffer_ins.count(tensor_wrapper_name) && - !dispensable_input_name_set.count(tensor_wrapper_name)) { + if (no_need_buffer_ins.count(tensor_wrapper_name)) { no_need_buffer_str = "true"; } if (duplicable_tensors.count(tensor_wrapper_name)) { diff --git a/paddle/fluid/pybind/op_function_generator.h b/paddle/fluid/pybind/op_function_generator.h index 401cd53472435..7b128bd3b0e4d 100644 --- a/paddle/fluid/pybind/op_function_generator.h +++ b/paddle/fluid/pybind/op_function_generator.h @@ -277,6 +277,10 @@ std::set special_inplace_op_set = { "assign", // output of `assign` op is in `op_passing_outs_map` }; +// NOTE(pangyoki): Special no_need_buffer ops that are not supported in +// temporary. +// sequence_conv op will raise error to get no_need_buffer info during +// compiling. std::set special_no_need_buffer_op_set = { "sequence_conv", }; From c0852d69ed6b752820f10ff1de3a36768b3a2890 Mon Sep 17 00:00:00 2001 From: pangyoki Date: Thu, 14 Apr 2022 08:44:37 +0000 Subject: [PATCH 6/7] solve conflict --- paddle/fluid/eager/auto_code_generator/eager_generator.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/paddle/fluid/eager/auto_code_generator/eager_generator.cc b/paddle/fluid/eager/auto_code_generator/eager_generator.cc index 307f8fae31597..6755d3f5492b4 100644 --- a/paddle/fluid/eager/auto_code_generator/eager_generator.cc +++ b/paddle/fluid/eager/auto_code_generator/eager_generator.cc @@ -2083,6 +2083,7 @@ static std::string GenerateSingleOpBase( " auto %s = egr::EagerUtils::RecoverTensorWrapper(&this->%s);\n" " if(%s.defined()) %s[\"%s\"] = " " egr::EagerUtils::TrySyncToVars(%s);\n"; + generated_grad_function_body += paddle::string::Sprintf( DISPENSABLE_GRAD_INS_FWD_CONTENT_TEMPLATE, grad_input_name, struct_fwd_input_name, grad_input_name, ins_name, grad_input_name, From 115142e42821ce791f7583f00421ffe8a77b9ba4 Mon Sep 17 00:00:00 2001 From: pangyoki Date: Thu, 14 Apr 2022 08:44:58 +0000 Subject: [PATCH 7/7] solve conflict --- paddle/fluid/eager/auto_code_generator/eager_generator.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/paddle/fluid/eager/auto_code_generator/eager_generator.cc b/paddle/fluid/eager/auto_code_generator/eager_generator.cc index 6755d3f5492b4..307f8fae31597 100644 --- a/paddle/fluid/eager/auto_code_generator/eager_generator.cc +++ b/paddle/fluid/eager/auto_code_generator/eager_generator.cc @@ -2083,7 +2083,6 @@ static std::string GenerateSingleOpBase( " auto %s = egr::EagerUtils::RecoverTensorWrapper(&this->%s);\n" " if(%s.defined()) %s[\"%s\"] = " " egr::EagerUtils::TrySyncToVars(%s);\n"; - generated_grad_function_body += paddle::string::Sprintf( DISPENSABLE_GRAD_INS_FWD_CONTENT_TEMPLATE, grad_input_name, struct_fwd_input_name, grad_input_name, ins_name, grad_input_name,