[Prim][CINN] Use API to instead of set prim all cpp flag#3051
Merged
Zeref996 merged 1 commit intoMar 24, 2025
Merged
Conversation
Zeref996
approved these changes
Mar 24, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PaddlePaddle/Paddle#71837 重构了 prim flag 体系,删掉了 C++ flag
FLAGS_prim_all,因此导致了set_flags({"FLAGS_prim_all": with_prim})形式不再被允许(但环境变量FLAGS_prim_all仍然有效,仅仅只是FLAGS_prim_all通过set_flags形式设置有问题而已)本 PR 进行了如下两种转写:
使用 API 代替设置 flag:
将
FLAGS_prim_all转发到FLAGS_prim_forward和FLAGS_prim_backward设置def SetEnvVar(env_var2value): for env_var, value in env_var2value.items(): os.environ[env_var] = str(value) + if env_var2value.get("FLAGS_prim_all") is not None: + prim_all_value = env_var2value.pop("FLAGS_prim_all") + env_var2value["FLAGS_prim_forward"] = prim_all_value + env_var2value["FLAGS_prim_backward"] = prim_all_value paddle.set_flags({ env_var:value for env_var, value in env_var2value.items() if env_var.startswith('FLAGS_') })本 PR 需在 PaddlePaddle/Paddle#71837 前合入