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

[Dy2St] Make translator logger lazy format and add error message for builtin type conversion methods #60836

Conversation

SigureMo
Copy link
Member

@SigureMo SigureMo commented Jan 16, 2024

PR types

Bug fixes

PR changes

Others

Description

logger 里直接 format 的话,如果用户自定义了一个 callable object,而且 __str__ 写了动转静运行不了的代码,则会报错,比如

class CustomLayer(paddle.nn.Layer):
    def __init__(self):
        super().__init__()
        self.expr = paddle.to_tensor(1)

    def __str__(self):
        return f"{float(self.expr)}"

为 Variable、Value 添加 float、bool、int 等 builtin 类型转换方法,均为直接报错,引导替换写法(bool 由于现有框架里有大量错误用法,因此单独提一个 PR,以不阻塞本 PR 推进)

并为 SOT 添加了遗漏的应当 breakgraph 的方法 float

PCard-66972

Copy link

paddle-bot bot commented Jan 16, 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.

@SigureMo SigureMo changed the title [Dy2St] Make translator logger lazy format [Dy2St] Make translator logger lazy format and add error message for builtin type conversion methods Jan 16, 2024
@PaddlePaddle PaddlePaddle locked and limited conversation to collaborators Jan 17, 2024
@PaddlePaddle PaddlePaddle unlocked this conversation Jan 17, 2024
Copy link
Contributor

@2742195759 2742195759 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@xiaoguoguo626807 xiaoguoguo626807 left a comment

Choose a reason for hiding this comment

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

LGTM for backward

@SigureMo SigureMo merged commit 548ac86 into PaddlePaddle:develop Jan 19, 2024
29 checks passed
@SigureMo SigureMo deleted the dy2st/make-translator-logger-lazy-format branch January 19, 2024 02:01
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.

None yet

3 participants