Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Debug][Werror]error: control reaches end of non-void function [-Werror=return-type] #53326

Merged
merged 1 commit into from
Apr 26, 2023

Conversation

engineer1109
Copy link
Contributor

@engineer1109 engineer1109 commented Apr 25, 2023

PR types

Bug fixes

PR changes

Others

Description

Debug模式下编译
Paddle/paddle/fluid/prim/utils/static/composite_grad_desc_maker.h Werror错误

In file included from /media/wjl/D2/github/fork/Paddle/paddle/fluid/framework/details/op_registry.h:35,
                 from /media/wjl/D2/github/fork/Paddle/paddle/fluid/framework/op_registry.h:31,
                 from /media/wjl/D2/github/fork/Paddle/paddle/fluid/operators/concat_op.h:21,
                 from /media/wjl/D2/github/fork/Paddle/paddle/fluid/operators/concat_op.cc:15:
/media/wjl/D2/github/fork/Paddle/paddle/fluid/prim/utils/static/composite_grad_desc_maker.h: In member function ‘std::vector<paddle::framework::VarDesc*> paddle::prim::CompositeGradOpMakerBase::MultiInputGrad(const string&) const’:
/media/wjl/D2/github/fork/Paddle/paddle/fluid/prim/utils/static/composite_grad_desc_maker.h:417:3: error: control reaches end of non-void function [-Werror=return-type]
  417 |   }
      |   ^
  std::vector<framework::VarDesc*> MultiInputGrad(
      const std::string& name) const {
    std::vector<std::string> ret_val;
    std::vector<framework::VarDesc*> input_grads;
    auto var_names = this->MultiForwardInputVarName(name);
    ret_val.reserve(var_names.size());
    std::transform(var_names.begin(),
                   var_names.end(),
                   std::back_inserter(ret_val),
                   [this](const std::string& fwd_var_name) -> std::string {
                     auto g_name = framework::GradVarName(fwd_var_name);
                     if (no_grad_set_.empty() || !no_grad_set_.count(g_name)) {
                       (*this->grad_to_var_)[g_name] = fwd_var_name;
                       return g_name;
                     } else {
                       return framework::kEmptyVarName;
                     }
                   });
    for (const auto& name : ret_val) {
      if (original_block_->HasVar(name)) {
        // Copy Var from original block to active block, or create a new one.
        CopyVarFromOrig(name);
        input_grads.emplace_back(
            StaticCompositeContext::Instance().GetBlock()->FindVar(name));
      } else {
        input_grads.emplace_back(
            StaticCompositeContext::Instance().GetBlock()->Var(name));
      }
    }
    return input_grads;
    PADDLE_ENFORCE_LE(
        var_names.size(),
        1UL,
        platform::errors::Unavailable(
            "BUG from operator developer:"
            " for input argument with a list of variables, "
            " drop_empty_grad is not allowed because it makes"
            " the correspondence bewteen a variable and its gradient"
            " ambiguous."));
  }

原因return下面有多余的语句。
这个是cmake .. -DCMAKE_BUILD_TYPE=Debug 时出现
#53313

@paddle-bot
Copy link

paddle-bot bot commented Apr 25, 2023

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added contributor External developers status: proposed labels Apr 25, 2023
@paddle-bot
Copy link

paddle-bot bot commented Apr 25, 2023

❌ The PR is not created using PR's template. You can refer to this Demo.
Please use PR's template, it helps save our maintainers' time so that more developers get helped.

@engineer1109
Copy link
Contributor Author

#47143

Copy link
Contributor

@zhangbo9674 zhangbo9674 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@luotao1 luotao1 merged commit 23e96bd into PaddlePaddle:develop Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants