From 69c2acbdb925e8a37467752512f2a906206611d2 Mon Sep 17 00:00:00 2001 From: chengduozh Date: Mon, 29 Oct 2018 19:57:55 +0800 Subject: [PATCH] fix ci fail test=release/1.1 --- paddle/fluid/framework/operator.cc | 2 +- paddle/fluid/framework/operator.h | 1 + paddle/fluid/operators/sum_op.cc | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/paddle/fluid/framework/operator.cc b/paddle/fluid/framework/operator.cc index 14fcde2fe3b..9259bb740a8 100644 --- a/paddle/fluid/framework/operator.cc +++ b/paddle/fluid/framework/operator.cc @@ -358,7 +358,7 @@ static bool VarIsTensor(const Variable* var) { return var->IsType() || var->IsType(); } -static const Tensor* GetTensorFromVar(Variable* var) { +const Tensor* GetTensorFromVar(Variable* var) { if (var->IsType()) { return var->GetMutable(); } else if (var->IsType()) { diff --git a/paddle/fluid/framework/operator.h b/paddle/fluid/framework/operator.h index 626b50edfd3..a04d2834eb9 100644 --- a/paddle/fluid/framework/operator.h +++ b/paddle/fluid/framework/operator.h @@ -63,6 +63,7 @@ inline std::string GradVarName(const std::string& var_name) { } proto::VarType::Type GetDataTypeOfVar(const Variable* var); +const Tensor* GetTensorFromVar(Variable* var); class OperatorBase; class ExecutionContext; diff --git a/paddle/fluid/operators/sum_op.cc b/paddle/fluid/operators/sum_op.cc index cc3d8db3b5a..6fe30630e96 100644 --- a/paddle/fluid/operators/sum_op.cc +++ b/paddle/fluid/operators/sum_op.cc @@ -81,10 +81,10 @@ class SumOp : public framework::OperatorWithKernel { if (x_vars[0]->IsType()) { int dtype = -1; - auto x_var_names = ctx.Inputs("X"); - for (auto& x_var_n : x_var_names) { + for (auto& x_var : x_vars) { // FIXME(zcd): The input x_var may be SelectedRows or LoDTensor. - auto tensor = ctx.Input(x_var_n); + auto tensor = framework::GetTensorFromVar( + const_cast(x_var)); if (tensor->numel() == 0) { continue; } -- GitLab