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] Optimize int(Value) and float(Value) error messages #68328

Merged
merged 3 commits into from
Sep 25, 2024

Conversation

gouzil
Copy link
Member

@gouzil gouzil commented Sep 19, 2024

PR Category

Execute Infrastructure

PR Types

Improvements

Description

新的 float(Value) 报错信息

TypeError: float(Tensor) is not supported in static graph mode. Because it's value is not available during the static mode.
If you haven't call float(Tensor) explicitly, it's usually triggered by the logging implicitly, for example:
    >>> logging.info("The value of x is: {float(x)}")
                                                ^ `x` is Tensor, `float(x)` triggers float(Tensor)

    There are two common workarounds available:
    If you are logging Tensor values, then consider logging only at dynamic graphs, for example:

        Modify the following code
        >>> logging.info("The value of x is: {float(x)}")
        to
        >>> if paddle.in_dynamic_mode():
        ...     logging.info("The value of x is: {float(x)}")

    If you need to convert the Tensor type, for example:
        Modify the following code
        >>> x = float(x)
        to
        >>> x = x.astype("float64")

新的 int(Value) 报错信息

TypeError: int(Tensor) is not supported in static graph mode. Because it's value is not available during the static mode.
If you haven't call int(Tensor) explicitly, it's usually triggered by the logging implicitly, for example:
    >>> logging.info("The value of x is: {int(x)}")
                                              ^ `x` is Tensor, `int(x)` triggers int(Tensor)

    There are two common workarounds available:
    If you are logging Tensor values, then consider logging only at dynamic graphs, for example:

        Modify the following code
        >>> logging.info("The value of x is: {int(x)}")
        to
        >>> if paddle.in_dynamic_mode():
        ...     logging.info("The value of x is: {int(x)}")

    If you need to convert the Tensor type, for example:
        Modify the following code
        >>> x = int(x)
        to
        >>> x = x.astype("int64")

@CLAassistant
Copy link

CLAassistant commented Sep 19, 2024

CLA assistant check
All committers have signed the CLA.

@paddle-bot paddle-bot bot added the contributor External developers label Sep 19, 2024
Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

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

其余倒没啥问题

)
error_msg = """\
int(Tensor) is not supported in static graph mode. Because it's value is not available during the static mode.
If you haven't call int(Tensor) explicitly, it's usually triggered by the logging implicitly, for example:
Copy link
Member

Choose a reason for hiding this comment

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

这行说不是显式的,下面的示例是显式的

这里不用说不是显式的,直接给出示例吧

Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

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

LGTMeow 🐾

@SigureMo SigureMo merged commit 9bd4efc into PaddlePaddle:develop Sep 25, 2024
27 of 28 checks passed
Copy link

paddle-bot bot commented Sep 26, 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.

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.

3 participants