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

[PIR] add paddle fatal mechanism. #62571

Merged
merged 2 commits into from
Mar 11, 2024

Conversation

winter-wang
Copy link
Contributor

@winter-wang winter-wang commented Mar 8, 2024

PR types

New features

PR changes

Others

Description

  • 新增paddle fatal 机制。
    • 全局维护唯一的布尔变量:paddle_fatal_skip, 初始化为false。
    • 当 paddle_fatal_skip 变量为true时, PADDLE_FATAL不起任何作用,等价于空语句。
    • 当 paddle_fatal_skip 变量为false时,PADDLE_FATAL会在打印相关信息后,调用std::abort()终止程序。
    • 新增数据结构PaddleFatalGuard, 该数据结构在构造函数中记录当前paddle_fatal_skip的值,并将paddle_fatal_skip设为true, 析构函数中将paddle_fatal_skip恢复为原值。
    • 在common::enforce:::EnforceNotMet和pir::IrNotMetException的异常中增加PaddleFatalGuard成员变量。 目前paddle代码中的PADDLE_ENFORCE_*和IR_ENFORCE中抛出的就是这两者异常,这意味着当程序在某处通过ADDLE_ENFORCE_*或者IR_ENFORCE判定失败,抛出异常,当异常对象沿着调用栈展开时,会跳过析构函数中的PADDLE_FATAL, 保证了上层调用者不用担心异常信息丢失,可以正确捕获到相应的异常。
  • 将PIR库中用到的析构函数中的LOG((FATAL)替换为PADDLE_FATAL。
  • 将PIR库中析构函数之外位置的LOG((FATAL)替换为PADDLE_ENFORCE_*。

Other

Pcard-67164

Copy link

paddle-bot bot commented Mar 8, 2024

你的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.

@winter-wang winter-wang force-pushed the cf_develop branch 5 times, most recently from d1c68f8 to 1a17ae3 Compare March 9, 2024 14:32
@winter-wang winter-wang force-pushed the cf_develop branch 7 times, most recently from 34aa8f0 to 2603c13 Compare March 10, 2024 07:23
@PaddlePaddle PaddlePaddle locked and limited conversation to collaborators Mar 10, 2024
@PaddlePaddle PaddlePaddle unlocked this conversation Mar 10, 2024
@winter-wang winter-wang reopened this Mar 10, 2024
@winter-wang winter-wang merged commit e365fcd into PaddlePaddle:develop Mar 11, 2024
30 checks passed
hitywt pushed a commit to hitywt/Paddle that referenced this pull request Mar 11, 2024
hitywt pushed a commit to hitywt/Paddle that referenced this pull request Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants