Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
N
ngraph
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ngraph
Commits
504e78f8
Commit
504e78f8
authored
Dec 06, 2018
by
Nick Korovaiko
Committed by
Scott Cyphers
Dec 06, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
an env var to disable individual fusions (#2185)
* an env var to disable individual fusions * fix env var name
parent
a09d5f88
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
1 deletion
+46
-1
graph_rewrite.cpp
src/ngraph/pass/graph_rewrite.cpp
+44
-0
graph_rewrite.hpp
src/ngraph/pass/graph_rewrite.hpp
+2
-1
No files found.
src/ngraph/pass/graph_rewrite.cpp
View file @
504e78f8
...
...
@@ -16,7 +16,9 @@
#include <algorithm>
#include <iostream>
#include <regex>
#include <unordered_set>
#include <vector>
#include "graph_rewrite.hpp"
#include "ngraph/log.hpp"
...
...
@@ -90,6 +92,48 @@ bool ngraph::pass::GraphRewrite::run_on_function(std::shared_ptr<ngraph::Functio
return
(
NUM_TRIES
-
tries
)
>
1
;
//this means a graph was transformed
}
static
const
std
::
vector
<
std
::
regex
>
initialize_fusion_regexes
()
{
const
char
*
cnsf
=
std
::
getenv
(
"NGRAPH_DISABLED_FUSIONS"
);
std
::
vector
<
std
::
regex
>
regexes
;
if
(
cnsf
)
{
const
std
::
string
nsf
=
cnsf
;
const
auto
sregexes
=
ngraph
::
split
(
nsf
,
';'
);
std
::
transform
(
sregexes
.
begin
(),
sregexes
.
end
(),
std
::
back_inserter
(
regexes
),
[](
const
std
::
string
&
c
)
->
std
::
regex
{
return
std
::
regex
(
c
);
});
}
return
regexes
;
}
bool
ngraph
::
pass
::
GraphRewrite
::
is_enabled
(
std
::
shared_ptr
<
pattern
::
Matcher
>
m
)
{
//note, regexes are static to avoid re-initialization
static
const
auto
regexes
=
initialize_fusion_regexes
();
for
(
const
auto
&
regex
:
regexes
)
{
if
(
std
::
regex_match
(
m
->
get_name
(),
regex
))
{
NGRAPH_DEBUG
<<
"Disabling matcher "
<<
m
->
get_name
();
return
false
;
}
}
return
true
;
}
void
ngraph
::
pass
::
GraphRewrite
::
add_matcher
(
std
::
shared_ptr
<
pattern
::
Matcher
>
m
)
{
if
(
is_enabled
(
m
))
{
m_matchers
.
push_back
(
m
);
}
}
bool
ngraph
::
pass
::
RecurrentGraphRewrite
::
run_on_function
(
std
::
shared_ptr
<
ngraph
::
Function
>
f
)
{
bool
changed
=
false
;
...
...
src/ngraph/pass/graph_rewrite.hpp
View file @
504e78f8
...
...
@@ -52,7 +52,8 @@ public:
{
}
void
add_matcher
(
std
::
shared_ptr
<
pattern
::
Matcher
>
m
)
{
m_matchers
.
push_back
(
m
);
}
bool
is_enabled
(
std
::
shared_ptr
<
pattern
::
Matcher
>
m
);
void
add_matcher
(
std
::
shared_ptr
<
pattern
::
Matcher
>
m
);
virtual
bool
run_on_function
(
std
::
shared_ptr
<
ngraph
::
Function
>
f
);
private
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment