Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.

Commit 1cbad22

Browse files
author
Adam Procter
authored
Add environment variable to explicitly enable f->is_dynamic() (#2973)
1 parent 096ad6e commit 1cbad22

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/ngraph/pass/graph_rewrite.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ bool pass::GraphRewrite::run_on_function(shared_ptr<Function> f)
6565
const size_t NUM_TRIES = 10;
6666
size_t tries = NUM_TRIES;
6767
vector<shared_ptr<pattern::Matcher>> original_matchers{m_matchers};
68-
bool is_dynamic_function = f->is_dynamic();
68+
// This check is very expensive and is only needed for experimental features, so we will hide
69+
// it behind an environment variable for now.
70+
static bool s_rerun_dynamic_check =
71+
(std::getenv("NGRAPH_GRAPH_REWRITE_RERUN_DYNAMIC_CHECK") != nullptr);
72+
bool is_dynamic_function = s_rerun_dynamic_check && f->is_dynamic();
6973
do
7074
{
7175
rewritten = false;
@@ -92,7 +96,7 @@ bool pass::GraphRewrite::run_on_function(shared_ptr<Function> f)
9296
if (matcher->process_match())
9397
{
9498
rewritten = true;
95-
is_dynamic_function = f->is_dynamic();
99+
is_dynamic_function = s_rerun_dynamic_check && f->is_dynamic();
96100
break;
97101
}
98102
}
@@ -151,7 +155,11 @@ bool pass::RecurrentGraphRewrite::run_on_function(shared_ptr<Function> f)
151155
{
152156
bool changed = false;
153157
size_t i = 0;
154-
bool is_dynamic_function = f->is_dynamic();
158+
// This check is very expensive and is only needed for experimental features, so we will hide
159+
// it behind an environment variable for now.
160+
static bool s_rerun_dynamic_check =
161+
(std::getenv("NGRAPH_GRAPH_REWRITE_RERUN_DYNAMIC_CHECK") != nullptr);
162+
bool is_dynamic_function = s_rerun_dynamic_check && f->is_dynamic();
155163
do
156164
{
157165
for (auto node : f->get_ops())
@@ -173,7 +181,7 @@ bool pass::RecurrentGraphRewrite::run_on_function(shared_ptr<Function> f)
173181
if (matcher->process_match())
174182
{
175183
changed = true;
176-
is_dynamic_function = f->is_dynamic();
184+
is_dynamic_function = s_rerun_dynamic_check && f->is_dynamic();
177185
goto next_fusion;
178186
}
179187
}

0 commit comments

Comments
 (0)