diff --git a/paddle/fluid/framework/operator.cc b/paddle/fluid/framework/operator.cc index 17003157b645a2cb7529543ef9016a26526d5ccb..0d5db737441db50cbe21acefaf7d586f881e1808 100644 --- a/paddle/fluid/framework/operator.cc +++ b/paddle/fluid/framework/operator.cc @@ -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.", @@ -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.", diff --git a/paddle/fluid/operators/conv_op.cc b/paddle/fluid/operators/conv_op.cc index a28f32b6abbc337ecca991f9a395d114d1c28a5b..5ce8422c9ad45662e8bc804b62ab1741e252b6d4 100644 --- a/paddle/fluid/operators/conv_op.cc +++ b/paddle/fluid/operators/conv_op.cc @@ -686,12 +686,15 @@ class Conv2DGradMaker : public framework::SingleGradOpMaker { 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()); } }; diff --git a/paddle/fluid/operators/lstm_op.cc b/paddle/fluid/operators/lstm_op.cc index 0405578f5dc1edbebf410b34199fdf106a397a9b..2ec9de3e3bbfc35992f75c0a4f4426ba52b45fd0 100644 --- a/paddle/fluid/operators/lstm_op.cc +++ b/paddle/fluid/operators/lstm_op.cc @@ -186,9 +186,7 @@ class LSTMOpMaker : public framework::OpProtoAndCheckerMaker { "(bool, default: False) " "whether to compute reversed LSTM.") .SetDefault(false); - AddAttr("is_test", "True if in test phase.") - .SetDefault(false) - .AsExtra(); + AddAttr("is_test", "True if in test phase.").SetDefault(false); AddAttr( "gate_activation", "(string, default: sigmoid)" diff --git a/paddle/fluid/operators/transpose_op.cc b/paddle/fluid/operators/transpose_op.cc index aa606693fed9f883d661fc711f40d99ad1b75e44..2b02d76d08e2de7b3a88b7032d6f601b9a6ca003 100644 --- a/paddle/fluid/operators/transpose_op.cc +++ b/paddle/fluid/operators/transpose_op.cc @@ -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 x_shape_dim(in_dims.size() + 1); x_shape_dim[0] = 0;