Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions paddle/fluid/operators/concat_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above implementation is a bit complicated.
You can try to fix like the following:

auto inputs = ctx.MultiInputVar("X");
for(auto* input : inputs){
  if(input->IsInitialized()){
    ....
  }
}

if (flag == 0) {
PADDLE_THROW("All Inputs of Concat OP are Empty!");
}

#ifdef PADDLE_WITH_MKLDNN
if (platform::CanMKLDNNBeUsed(ctx)) {
Expand Down