Skip to content

Commit

Permalink
Merge pull request #7943 from pkuyym/fix-7939
Browse files Browse the repository at this point in the history
Bug fix for sequence_reshape operator.
  • Loading branch information
pkuyym authored Jan 29, 2018
2 parents 29b6839 + 369e2ba commit fb1a0df
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions paddle/operators/sequence_reshape_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@ class SequenceReshapeOp : public framework::OperatorWithKernel {
auto x_numel = product(x_dims);
PADDLE_ENFORCE_EQ(x_dims.size(), 2U, "Rank of Input(X) should be 2.");
int new_dim = ctx->Attrs().Get<int>("new_dim");
ctx->SetOutputDim("Out",
{x_numel / new_dim, static_cast<int64_t>(new_dim)});
if (ctx->IsRuntime()) {
ctx->SetOutputDim("Out",
{x_numel / new_dim, static_cast<int64_t>(new_dim)});
} else {
// when compiling, the batch size is undetermined, just set to -1
ctx->SetOutputDim("Out", {-1, static_cast<int64_t>(new_dim)});
}
}
};

Expand Down

0 comments on commit fb1a0df

Please sign in to comment.