Skip to content
Merged
Changes from 5 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");
const size_t num_input = vars.size();
auto input_data_type = paddle::framework::proto::VarType::Type(0);
for (size_t i = 0; i < num_input; ++i) {
try {
input_data_type = framework::GetDataTypeOfVar(vars[i]);
break;
} catch (platform::EnforceNotMet exception) {
if (i == num_input - 1) {
PADDLE_THROW("All Inputs of Concat OP are Empty!");
}
}
}
Copy link
Copy Markdown
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()){
    ....
  }
}


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