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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

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

2 participants