Skip to content

Commit

Permalink
fix some op extra error, test=develop (#35667)
Browse files Browse the repository at this point in the history
  • Loading branch information
winter-wang authored Sep 12, 2021
1 parent adaa207 commit 8342403
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions paddle/fluid/framework/operator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ void OperatorBase::CheckAllInputOutputSet() const {
if (info_ == nullptr || info_->proto_ == nullptr) return;

for (auto& in : info_->Proto().inputs()) {
if (!in.dispensable()) {
if (!in.dispensable() && !in.extra()) {
PADDLE_ENFORCE_NE(
inputs_.find(in.name()), inputs_.end(),
platform::errors::NotFound("Operator %s's input (%s) is not set.",
Expand All @@ -450,7 +450,7 @@ void OperatorBase::CheckAllInputOutputSet() const {
}

for (auto& out : info_->Proto().outputs()) {
if (!out.dispensable()) {
if (!out.dispensable() && !out.extra()) {
PADDLE_ENFORCE_NE(
outputs_.find(out.name()), outputs_.end(),
platform::errors::NotFound("Operator %s's output (%s) is not set.",
Expand Down
7 changes: 5 additions & 2 deletions paddle/fluid/operators/conv_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -686,12 +686,15 @@ class Conv2DGradMaker : public framework::SingleGradOpMaker<T> {
op->SetType(this->ForwardOpType() + "_grad");
op->SetInput("Input", this->Input("Input"));
op->SetInput("Filter", this->Input("Filter"));
op->SetInput("Bias", this->Input("Bias"));
op->SetInput(framework::GradVarName("Output"), this->OutputGrad("Output"));

op->SetOutput(framework::GradVarName("Input"), this->InputGrad("Input"));
op->SetOutput(framework::GradVarName("Filter"), this->InputGrad("Filter"));
op->SetOutput(framework::GradVarName("Bias"), this->InputGrad("Bias"));

if (this->HasInput("Bias")) {
op->SetInput("Bias", this->Input("Bias"));
op->SetOutput(framework::GradVarName("Bias"), this->InputGrad("Bias"));
}
op->SetAttrMap(this->Attrs());
}
};
Expand Down
4 changes: 1 addition & 3 deletions paddle/fluid/operators/lstm_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,7 @@ class LSTMOpMaker : public framework::OpProtoAndCheckerMaker {
"(bool, default: False) "
"whether to compute reversed LSTM.")
.SetDefault(false);
AddAttr<bool>("is_test", "True if in test phase.")
.SetDefault(false)
.AsExtra();
AddAttr<bool>("is_test", "True if in test phase.").SetDefault(false);
AddAttr<std::string>(
"gate_activation",
"(string, default: sigmoid)"
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/transpose_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class Transpose2Op : public TransposeOp {

void InferShape(framework::InferShapeContext *ctx) const override {
TransposeOp::InferShape(ctx);
OP_INOUT_CHECK(ctx->HasOutput("XShape"), "Output", "XShape", "Transpose2");
if (!ctx->HasOutput("XShape")) return;
const auto &in_dims = ctx->GetInputDim("X");
std::vector<int64_t> x_shape_dim(in_dims.size() + 1);
x_shape_dim[0] = 0;
Expand Down

0 comments on commit 8342403

Please sign in to comment.