From c1aae8b8d2cdd8ad03beb44128518ee964f222c6 Mon Sep 17 00:00:00 2001 From: jerrywgz Date: Thu, 23 May 2019 16:36:36 +0800 Subject: [PATCH] Fix GetExpectedKernelType in Concat op (#17459) * fix concat op vartype check, test=develop --- paddle/fluid/operators/concat_op.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/paddle/fluid/operators/concat_op.cc b/paddle/fluid/operators/concat_op.cc index 029b05bb662..ad7a84009c9 100644 --- a/paddle/fluid/operators/concat_op.cc +++ b/paddle/fluid/operators/concat_op.cc @@ -80,8 +80,19 @@ class ConcatOp : public framework::OperatorWithKernel { protected: framework::OpKernelType GetExpectedKernelType( const framework::ExecutionContext &ctx) const override { - auto input_data_type = - framework::GetDataTypeOfVar(ctx.MultiInputVar("X")[0]); + auto vars = ctx.MultiInputVar("X"); + auto input_data_type = framework::proto::VarType::Type(0); + bool flag = 0; + for (auto *var : vars) { + if (var->IsInitialized()) { + input_data_type = framework::GetDataTypeOfVar(var); + flag = 1; + break; + } + } + if (flag == 0) { + PADDLE_THROW("All Inputs of Concat OP are Empty!"); + } #ifdef PADDLE_WITH_MKLDNN if (platform::CanMKLDNNBeUsed(ctx)) { -- GitLab