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

请问如何关闭dynamic graph或者pir mode? #70888

Open
Qin-sx opened this issue Jan 19, 2025 · 2 comments
Open

请问如何关闭dynamic graph或者pir mode? #70888

Qin-sx opened this issue Jan 19, 2025 · 2 comments
Assignees
Labels

Comments

@Qin-sx
Copy link
Contributor

Qin-sx commented Jan 19, 2025

请提出你的问题 Please ask your question

根据in_dynamic_or_pir_mode函数内的示例,使用paddle.enable_static()之后结果应该为False,但是在develop分支实际为True。
in_dynamic_or_pir_mode函数:

def in_dynamic_or_pir_mode() -> bool:
    """

    This API checks whether paddle runs in dynamic graph or pir mode.

    Returns:
        bool: Whether paddle runs in static graph mode and use pir api.

    Examples:
        .. code-block:: python

            >>> import paddle

            >>> print(paddle.framework.in_dynamic_or_pir_mode())
            True

            >>> paddle.enable_static()
            >>> print(paddle.framework.in_dynamic_or_pir_mode())
            False

            >>> with paddle.pir_utils.IrGuard():
            ...     print(paddle.framework.in_dynamic_or_pir_mode())
            True

    """
    return global_var._dygraph_tracer_ is not None or global_var._use_pir_api_

测试代码:

import paddle

print(paddle.framework.in_dynamic_or_pir_mode())


paddle.enable_static()
print(paddle.framework.in_dynamic_or_pir_mode())


with paddle.pir_utils.IrGuard():
    print(paddle.framework.in_dynamic_or_pir_mode())

实际结果:

True
True
True
@Qin-sx Qin-sx added status/new-issue 新建 type/question 用户提问 labels Jan 19, 2025
@zhiminzhang0830
Copy link
Contributor

您好,可以通过设置 FLAGS_enable_pir_api=0,关闭PIR

@Qin-sx
Copy link
Contributor Author

Qin-sx commented Jan 20, 2025

您好,可以通过设置 FLAGS_enable_pir_api=0,关闭PIR

收到,谢谢!
设置之后paddle.framework.in_dynamic_or_pir_mode()的结果为False了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants