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

[Prim][PIR] Set prim gflag for pure cpp #60505

Merged
merged 15 commits into from
Jan 3, 2024
10 changes: 8 additions & 2 deletions paddle/fluid/prim/utils/utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@
#include "paddle/fluid/prim/utils/static/static_global_utils.h"

PADDLE_DEFINE_EXPORTED_bool(prim_enabled, false, "enable_prim or not");
PADDLE_DEFINE_EXPORTED_bool(prim_all, false, "enable prim_all or not");
PADDLE_DEFINE_EXPORTED_bool(prim_forward, false, "enable prim_forward or not");
PADDLE_DEFINE_EXPORTED_bool(prim_backward, false, "enable prim_backward not");

namespace paddle {
namespace prim {
bool PrimCommonUtils::IsBwdPrimEnabled() {
return StaticCompositeContext::Instance().IsBwdPrimEnabled();
bool res = StaticCompositeContext::Instance().IsBwdPrimEnabled();
return res || FLAGS_prim_all || FLAGS_prim_backward;
}

void PrimCommonUtils::SetBwdPrimEnabled(bool enable_prim) {
Expand All @@ -36,7 +41,8 @@ void PrimCommonUtils::SetEagerPrimEnabled(bool enable_prim) {
}

bool PrimCommonUtils::IsFwdPrimEnabled() {
return StaticCompositeContext::Instance().IsFwdPrimEnabled();
bool res = StaticCompositeContext::Instance().IsFwdPrimEnabled();
return res || FLAGS_prim_all || FLAGS_prim_forward;
}

void PrimCommonUtils::SetFwdPrimEnabled(bool enable_prim) {
Expand Down