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
478a94f9
Commit
478a94f9
authored
Apr 23, 2018
by
Nick Korovaiko
Committed by
Scott Cyphers
Apr 23, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename Any to Skip since that is exactly what it should have been called from the beginning (#891)
* any -> skip * run style check
parent
870200d1
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
32 additions
and
32 deletions
+32
-32
core_fusion.cpp
src/ngraph/pass/core_fusion.cpp
+2
-2
reshape_elimination.cpp
src/ngraph/pass/reshape_elimination.cpp
+1
-1
matcher.cpp
src/ngraph/pattern/matcher.cpp
+7
-7
matcher.hpp
src/ngraph/pattern/matcher.hpp
+4
-4
pattern.hpp
src/ngraph/pattern/op/pattern.hpp
+1
-1
skip.hpp
src/ngraph/pattern/op/skip.hpp
+4
-4
cpu_fusion.cpp
src/ngraph/runtime/cpu/pass/cpu_fusion.cpp
+3
-3
cpu_post_layout_optimizations.cpp
...ngraph/runtime/cpu/pass/cpu_post_layout_optimizations.cpp
+1
-1
core_fusion.cpp
test/core_fusion.cpp
+1
-1
cpu_fusion.cpp
test/cpu_fusion.cpp
+3
-3
includes.cpp
test/includes.cpp
+1
-1
pattern.cpp
test/pattern.cpp
+3
-3
reshape_elimination.cpp
test/reshape_elimination.cpp
+1
-1
No files found.
src/ngraph/pass/core_fusion.cpp
View file @
478a94f9
...
...
@@ -29,8 +29,8 @@
#include "ngraph/pass/graph_rewrite.hpp"
#include "ngraph/pass/manager.hpp"
#include "ngraph/pattern/matcher.hpp"
#include "ngraph/pattern/op/any.hpp"
#include "ngraph/pattern/op/label.hpp"
#include "ngraph/pattern/op/skip.hpp"
using
namespace
ngraph
;
using
namespace
std
;
...
...
@@ -55,7 +55,7 @@ void pass::CoreFusion::construct_relu_pattern()
auto
broadcast_pred
=
[](
std
::
shared_ptr
<
Node
>
n
)
{
return
static_cast
<
bool
>
(
std
::
dynamic_pointer_cast
<
op
::
Broadcast
>
(
n
));
};
auto
skip_broadcast
=
std
::
make_shared
<
pattern
::
op
::
Any
>
(
zero
,
broadcast_pred
);
auto
skip_broadcast
=
std
::
make_shared
<
pattern
::
op
::
Skip
>
(
zero
,
broadcast_pred
);
auto
max
=
make_shared
<
op
::
Maximum
>
(
skip_broadcast
,
val
);
pattern
::
graph_rewrite_callback
callback
=
[
val
,
zero
](
pattern
::
Matcher
&
m
)
{
...
...
src/ngraph/pass/reshape_elimination.cpp
View file @
478a94f9
...
...
@@ -29,8 +29,8 @@
#include "ngraph/op/parameter.hpp"
#include "ngraph/op/reshape.hpp"
#include "ngraph/pattern/matcher.hpp"
#include "ngraph/pattern/op/any.hpp"
#include "ngraph/pattern/op/label.hpp"
#include "ngraph/pattern/op/skip.hpp"
#include "ngraph/util.hpp"
template
<
typename
T
>
...
...
src/ngraph/pattern/matcher.cpp
View file @
478a94f9
...
...
@@ -71,9 +71,9 @@ namespace ngraph
return
is_match
;
}
bool
Matcher
::
match_
any
(
const
std
::
shared_ptr
<
op
::
Any
>&
any
,
const
std
::
shared_ptr
<
Node
>&
graph_node
,
PatternMap
&
pattern_map
)
bool
Matcher
::
match_
skip
(
const
std
::
shared_ptr
<
op
::
Skip
>&
any
,
const
std
::
shared_ptr
<
Node
>&
graph_node
,
PatternMap
&
pattern_map
)
{
auto
predicate
=
any
->
get_predicate
();
...
...
@@ -86,7 +86,7 @@ namespace ngraph
auto
args
=
any
->
get_arguments
();
if
(
args
.
size
()
!=
1
)
{
throw
ngraph_error
(
"
Any
can only take one argument"
);
throw
ngraph_error
(
"
Skip
can only take one argument"
);
}
return
match_node
(
args
.
at
(
0
),
graph_node
,
pattern_map
);
...
...
@@ -111,10 +111,10 @@ namespace ngraph
return
match_pattern
(
label_node
,
graph_node
,
pattern_map
);
}
if
(
auto
any_node
=
std
::
dynamic_pointer_cast
<
op
::
Any
>
(
if
(
auto
any_node
=
std
::
dynamic_pointer_cast
<
op
::
Skip
>
(
pattern_node
))
//matches PatternSkipOp semantics
{
return
match_
any
(
any_node
,
graph_node
,
pattern_map
);
return
match_
skip
(
any_node
,
graph_node
,
pattern_map
);
}
auto
p_pattern_node
=
pattern_node
.
get
();
...
...
@@ -283,7 +283,7 @@ namespace ngraph
//pre-populate the pattern map for the next cell with the bound nodes
//from the current match. Only bound nodes whose labels are in
//correlated_patterns are pre-populated.
Any
other labels are
//correlated_patterns are pre-populated.
Skip
other labels are
//unbounded by default
for
(
auto
cor_pat
:
m_correlated_patterns
)
{
...
...
src/ngraph/pattern/matcher.hpp
View file @
478a94f9
...
...
@@ -20,8 +20,8 @@
#include <memory.h>
#include "ngraph/node.hpp"
#include "ngraph/op/constant.hpp"
#include "ngraph/pattern/op/any.hpp"
#include "ngraph/pattern/op/label.hpp"
#include "ngraph/pattern/op/skip.hpp"
namespace
ngraph
{
...
...
@@ -127,9 +127,9 @@ namespace ngraph
bool
match_pattern
(
const
std
::
shared_ptr
<
op
::
Label
>&
pattern_node
,
const
std
::
shared_ptr
<
Node
>&
graph_node
,
PatternMap
&
pattern_map
);
bool
match_
any
(
const
std
::
shared_ptr
<
op
::
Any
>&
pattern_node
,
const
std
::
shared_ptr
<
Node
>&
graph_node
,
PatternMap
&
pattern_map
);
bool
match_
skip
(
const
std
::
shared_ptr
<
op
::
Skip
>&
pattern_node
,
const
std
::
shared_ptr
<
Node
>&
graph_node
,
PatternMap
&
pattern_map
);
graph_rewrite_callback
m_callback
;
size_t
m_depth
;
...
...
src/ngraph/pattern/op/pattern.hpp
View file @
478a94f9
...
...
@@ -32,7 +32,7 @@ namespace ngraph
class
Pattern
:
public
Node
{
public
:
/// \brief \p a base class for \sa
Any
and \sa Label
/// \brief \p a base class for \sa
Skip
and \sa Label
///
Pattern
(
const
std
::
string
&
type_name
,
const
NodeVector
&
nodes
,
Predicate
pred
)
:
Node
(
type_name
,
nodes
)
...
...
src/ngraph/pattern/op/
any
.hpp
→
src/ngraph/pattern/op/
skip
.hpp
View file @
478a94f9
...
...
@@ -25,14 +25,14 @@ namespace ngraph
{
namespace
op
{
/// \brief \p
Any
allows users to specify unexpected nodes in a pattern
/// \brief \p
Skip
allows users to specify unexpected nodes in a pattern
/// and skip them if a predicate condition is satisfied.
///
class
Any
:
public
Pattern
class
Skip
:
public
Pattern
{
public
:
Any
(
const
std
::
shared_ptr
<
Node
>&
arg
,
Predicate
predicate
=
nullptr
)
:
Pattern
(
"
Any
"
,
NodeVector
{
arg
},
predicate
)
Skip
(
const
std
::
shared_ptr
<
Node
>&
arg
,
Predicate
predicate
=
nullptr
)
:
Pattern
(
"
Skip
"
,
NodeVector
{
arg
},
predicate
)
{
add_output
(
arg
->
get_element_type
(),
arg
->
get_shape
());
}
...
...
src/ngraph/runtime/cpu/pass/cpu_fusion.cpp
View file @
478a94f9
...
...
@@ -42,8 +42,8 @@
#include "ngraph/op/subtract.hpp"
#include "ngraph/op/sum.hpp"
#include "ngraph/pattern/matcher.hpp"
#include "ngraph/pattern/op/any.hpp"
#include "ngraph/pattern/op/label.hpp"
#include "ngraph/pattern/op/skip.hpp"
#include "ngraph/runtime/cpu/op/batch_norm_relu.hpp"
#include "ngraph/runtime/cpu/op/conv_bias.hpp"
#include "ngraph/runtime/cpu/op/conv_relu.hpp"
...
...
@@ -177,8 +177,8 @@ void ngraph::runtime::cpu::pass::CPUFusion::construct_matmul()
return
static_cast
<
bool
>
(
std
::
dynamic_pointer_cast
<
op
::
Reshape
>
(
n
));
};
auto
skip_w
=
std
::
make_shared
<
pattern
::
op
::
Any
>
(
W
,
reshape_pred
);
auto
skip_x
=
std
::
make_shared
<
pattern
::
op
::
Any
>
(
x
,
reshape_pred
);
auto
skip_w
=
std
::
make_shared
<
pattern
::
op
::
Skip
>
(
W
,
reshape_pred
);
auto
skip_x
=
std
::
make_shared
<
pattern
::
op
::
Skip
>
(
x
,
reshape_pred
);
auto
pdot
=
std
::
make_shared
<
op
::
Dot
>
(
skip_w
,
skip_x
);
...
...
src/ngraph/runtime/cpu/pass/cpu_post_layout_optimizations.cpp
View file @
478a94f9
...
...
@@ -27,8 +27,8 @@
#include "ngraph/pass/graph_rewrite.hpp"
#include "ngraph/pass/manager.hpp"
#include "ngraph/pattern/matcher.hpp"
#include "ngraph/pattern/op/any.hpp"
#include "ngraph/pattern/op/label.hpp"
#include "ngraph/pattern/op/skip.hpp"
#include "ngraph/runtime/cpu/cpu_layout_descriptor.hpp"
#include "ngraph/runtime/cpu/op/convert_layout.hpp"
#include "ngraph/runtime/cpu/pass/cpu_post_layout_optimizations.hpp"
...
...
test/core_fusion.cpp
View file @
478a94f9
...
...
@@ -31,8 +31,8 @@
#include "ngraph/pass/graph_rewrite.hpp"
#include "ngraph/pass/manager.hpp"
#include "ngraph/pattern/matcher.hpp"
#include "ngraph/pattern/op/any.hpp"
#include "ngraph/pattern/op/label.hpp"
#include "ngraph/pattern/op/skip.hpp"
#include "ngraph/serializer.hpp"
#include "ngraph/util.hpp"
#include "nlohmann/json.hpp"
...
...
test/cpu_fusion.cpp
View file @
478a94f9
...
...
@@ -36,8 +36,8 @@
#include "ngraph/pass/reshape_elimination.hpp"
#include "ngraph/pass/visualize_tree.hpp"
#include "ngraph/pattern/matcher.hpp"
#include "ngraph/pattern/op/any.hpp"
#include "ngraph/pattern/op/label.hpp"
#include "ngraph/pattern/op/skip.hpp"
#include "ngraph/runtime/cpu/cpu_layout_descriptor.hpp"
#include "ngraph/runtime/cpu/op/batch_norm_relu.hpp"
#include "ngraph/runtime/cpu/op/conv_bias.hpp"
...
...
@@ -83,8 +83,8 @@ TEST(cpu_fusion, gemm_pattern)
return
static_cast
<
bool
>
(
std
::
dynamic_pointer_cast
<
op
::
Reshape
>
(
n
));
};
auto
skip_w
=
std
::
make_shared
<
pattern
::
op
::
Any
>
(
W
,
reshape_pred
);
auto
skip_x
=
std
::
make_shared
<
pattern
::
op
::
Any
>
(
x
,
reshape_pred
);
auto
skip_w
=
std
::
make_shared
<
pattern
::
op
::
Skip
>
(
W
,
reshape_pred
);
auto
skip_x
=
std
::
make_shared
<
pattern
::
op
::
Skip
>
(
x
,
reshape_pred
);
auto
pdot
=
make_shared
<
op
::
Dot
>
(
skip_w
,
skip_x
);
auto
b
=
std
::
make_shared
<
pattern
::
op
::
Label
>
(
C
);
...
...
test/includes.cpp
View file @
478a94f9
...
...
@@ -143,7 +143,7 @@ TEST(DISABLED_include, complete)
"ngraph/pass/visualize_tree.hpp"
,
"ngraph/pattern/core_fusion.hpp"
,
"ngraph/pattern/matcher.hpp"
,
"ngraph/pattern/op/
any
.hpp"
,
"ngraph/pattern/op/
skip
.hpp"
,
"ngraph/pattern/op/label.hpp"
,
"ngraph/pattern/op/pattern.hpp"
,
"ngraph/placement.hpp"
,
...
...
test/pattern.cpp
View file @
478a94f9
...
...
@@ -37,8 +37,8 @@
#include "ngraph/pass/graph_rewrite.hpp"
#include "ngraph/pass/manager.hpp"
#include "ngraph/pattern/matcher.hpp"
#include "ngraph/pattern/op/any.hpp"
#include "ngraph/pattern/op/label.hpp"
#include "ngraph/pattern/op/skip.hpp"
#include "ngraph/runtime/cpu/pass/cpu_fusion.hpp"
#include "ngraph/serializer.hpp"
#include "util/matcher.hpp"
...
...
@@ -402,11 +402,11 @@ TEST(pattern, matcher)
ASSERT_TRUE
(
n
.
match
(
a
,
a
));
auto
abs
=
make_shared
<
op
::
Abs
>
(
a
);
auto
any
=
std
::
make_shared
<
pattern
::
op
::
Any
>
(
a
);
auto
any
=
std
::
make_shared
<
pattern
::
op
::
Skip
>
(
a
);
ASSERT_TRUE
(
n
.
match
(
any
,
abs
));
auto
any_false
=
std
::
make_shared
<
pattern
::
op
::
Any
>
(
a
,
[](
std
::
shared_ptr
<
Node
>
no
)
{
return
false
;
});
std
::
make_shared
<
pattern
::
op
::
Skip
>
(
a
,
[](
std
::
shared_ptr
<
Node
>
no
)
{
return
false
;
});
ASSERT_TRUE
(
n
.
match
(
any_false
,
a
));
auto
pattern
=
std
::
make_shared
<
pattern
::
op
::
Label
>
(
a
);
...
...
test/reshape_elimination.cpp
View file @
478a94f9
...
...
@@ -30,8 +30,8 @@
#include "ngraph/pass/manager.hpp"
#include "ngraph/pass/reshape_elimination.hpp"
#include "ngraph/pattern/matcher.hpp"
#include "ngraph/pattern/op/any.hpp"
#include "ngraph/pattern/op/label.hpp"
#include "ngraph/pattern/op/skip.hpp"
#include "ngraph/serializer.hpp"
#include "ngraph/util.hpp"
#include "nlohmann/json.hpp"
...
...
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