From 4beaa7548b4c7703c41f2a5febf9dc7661c86d34 Mon Sep 17 00:00:00 2001 From: Wei Shengyu Date: Thu, 9 Sep 2021 21:28:10 +0800 Subject: [PATCH] mark extra attr for unsqueeze2 (#35528) * mark extra attr for unsqueeze2 * debug for inference --- paddle/fluid/operators/unsqueeze_op.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/paddle/fluid/operators/unsqueeze_op.cc b/paddle/fluid/operators/unsqueeze_op.cc index 8a645e87158..ed7a4f92f09 100755 --- a/paddle/fluid/operators/unsqueeze_op.cc +++ b/paddle/fluid/operators/unsqueeze_op.cc @@ -253,10 +253,7 @@ class Unsqueeze2Op : public UnsqueezeOp { UnsqueezeOp::InferShape(ctx); const auto &x_dims = ctx->GetInputDim("X"); - PADDLE_ENFORCE_EQ( - ctx->HasOutput("XShape"), true, - platform::errors::InvalidArgument("Output(XShape) of Unsqueeze " - "operator should not be null.")); + if (!ctx->HasOutput("XShape")) return; std::vector xshape_dims(x_dims.size() + 1); xshape_dims[0] = 0; for (int i = 0; i < x_dims.size(); ++i) { @@ -274,7 +271,8 @@ class Unsqueeze2OpMaker : public UnsqueezeOpMaker { AddOutput("XShape", "XShape is just used to store the shape and lod of X, which will " "be used in UnsqueezeGradOp.") - .AsIntermediate(); + .AsIntermediate() + .AsExtra(); } }; -- GitLab