From 40f15952342b1c526754cb65a2f3e8758fa5b6cd Mon Sep 17 00:00:00 2001 From: Jiabin Yang <360788950@qq.com> Date: Wed, 26 Oct 2022 16:21:20 +0800 Subject: [PATCH] fix pylayer name crash (#47323) --- paddle/fluid/eager/pylayer/py_layer_node.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/paddle/fluid/eager/pylayer/py_layer_node.h b/paddle/fluid/eager/pylayer/py_layer_node.h index eb8d1bc9c57..2b37765bc2a 100644 --- a/paddle/fluid/eager/pylayer/py_layer_node.h +++ b/paddle/fluid/eager/pylayer/py_layer_node.h @@ -31,6 +31,7 @@ class GradNodePyLayer : public GradNodeBase { size_t bwd_out_slot_num) : GradNodeBase(bwd_in_slot_num, bwd_out_slot_num) { ctx_ = ctx; + name_ = "GradNodePyLayer_" + std::string(Py_TYPE(ctx_)->tp_name); Py_INCREF(ctx_); } @@ -52,9 +53,7 @@ class GradNodePyLayer : public GradNodeBase { void ClearTensorWrappers() override { VLOG(6) << "Do nothing here now"; } - std::string name() override { - return "GradNodePyLayer_" + std::string(Py_TYPE(ctx_)->tp_name); - } + std::string name() override { return name_; } void SaveForwardOutputsMeta( const std::vector>& @@ -84,6 +83,7 @@ class GradNodePyLayer : public GradNodeBase { private: PyObject* ctx_{nullptr}; + std::string name_{""}; std::vector> forward_outputs_meta_; std::vector> forward_outputs_place_; }; -- GitLab