From 104d3b4e680c020d60ffa1977e7df118371fd53f Mon Sep 17 00:00:00 2001 From: dzhwinter Date: Sat, 9 Feb 2019 14:40:38 +0800 Subject: [PATCH] add details. test=develop --- paddle/fluid/operators/elementwise/elementwise_op.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/paddle/fluid/operators/elementwise/elementwise_op.h b/paddle/fluid/operators/elementwise/elementwise_op.h index 5443132641c..91e44152658 100644 --- a/paddle/fluid/operators/elementwise/elementwise_op.h +++ b/paddle/fluid/operators/elementwise/elementwise_op.h @@ -272,9 +272,12 @@ class ElementwiseGradOpInplace : public framework::InplaceInToOut { std::unordered_map Apply( const framework::OpDesc &op_desc, framework::BlockDesc *block) const override { - return std::unordered_map{ - {framework::GradVarName("Out"), framework::GradVarName("X")}, - }; + std::unordered_map ret; + if (block->HasVar(framework::GradVarName("X")) && + block->HasVar(framework::GradVarName("Out"))) { + ret[framework::GradVarName("Out")] = framework::GradVarName("X"); + } + return ret; } }; -- GitLab