From dc9e23c4e24df8ce4b04e5751ae3cdbb93de2da4 Mon Sep 17 00:00:00 2001 From: chengduozh Date: Mon, 29 Oct 2018 15:18:50 +0800 Subject: [PATCH] fix sum_op's GetExpectedKernelType test=develop --- paddle/fluid/operators/sum_op.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/paddle/fluid/operators/sum_op.cc b/paddle/fluid/operators/sum_op.cc index 34dbac2ab..cc3d8db3b 100644 --- a/paddle/fluid/operators/sum_op.cc +++ b/paddle/fluid/operators/sum_op.cc @@ -81,15 +81,17 @@ class SumOp : public framework::OperatorWithKernel { if (x_vars[0]->IsType()) { int dtype = -1; - for (auto& x_var : x_vars) { - auto& lod_tensor = x_var->Get(); - if (lod_tensor.numel() == 0) { + auto x_var_names = ctx.Inputs("X"); + for (auto& x_var_n : x_var_names) { + // FIXME(zcd): The input x_var may be SelectedRows or LoDTensor. + auto tensor = ctx.Input(x_var_n); + if (tensor->numel() == 0) { continue; } if (dtype == -1) { - dtype = framework::ToDataType(lod_tensor.type()); + dtype = framework::ToDataType(tensor->type()); } else { - PADDLE_ENFORCE_EQ(dtype, framework::ToDataType(lod_tensor.type())); + PADDLE_ENFORCE_EQ(dtype, framework::ToDataType(tensor->type())); } } PADDLE_ENFORCE_NE(dtype, -1, -- GitLab