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
22819e78
Commit
22819e78
authored
Feb 21, 2018
by
nikolay.korovaiko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conv+bias fusion
parent
5c0a29ee
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
0 deletions
+38
-0
cpu_fusion.cpp
src/ngraph/runtime/cpu/pass/cpu_fusion.cpp
+36
-0
cpu_fusion.hpp
src/ngraph/runtime/cpu/pass/cpu_fusion.hpp
+2
-0
No files found.
src/ngraph/runtime/cpu/pass/cpu_fusion.cpp
View file @
22819e78
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
#include "ngraph/ops/broadcast.hpp"
#include "ngraph/ops/broadcast.hpp"
#include "ngraph/ops/broadcast.hpp"
#include "ngraph/ops/broadcast.hpp"
#include "ngraph/ops/constant.hpp"
#include "ngraph/ops/constant.hpp"
#include "ngraph/ops/convolution.hpp"
#include "ngraph/ops/divide.hpp"
#include "ngraph/ops/divide.hpp"
#include "ngraph/ops/dot.hpp"
#include "ngraph/ops/dot.hpp"
#include "ngraph/ops/multiply.hpp"
#include "ngraph/ops/multiply.hpp"
...
@@ -38,6 +39,7 @@
...
@@ -38,6 +39,7 @@
#include "ngraph/pattern/matcher.hpp"
#include "ngraph/pattern/matcher.hpp"
#include "ngraph/pattern/op/any.hpp"
#include "ngraph/pattern/op/any.hpp"
#include "ngraph/pattern/op/label.hpp"
#include "ngraph/pattern/op/label.hpp"
#include "ngraph/runtime/cpu/ops/conv_bias.hpp"
#include "ngraph/runtime/cpu/ops/matmul_bias.hpp"
#include "ngraph/runtime/cpu/ops/matmul_bias.hpp"
static
bool
init_cblas_arg
(
std
::
shared_ptr
<
ngraph
::
Node
>
reshape
,
static
bool
init_cblas_arg
(
std
::
shared_ptr
<
ngraph
::
Node
>
reshape
,
...
@@ -270,3 +272,37 @@ void ngraph::runtime::cpu::pass::CPUFusion::construct_fprop_bn()
...
@@ -270,3 +272,37 @@ void ngraph::runtime::cpu::pass::CPUFusion::construct_fprop_bn()
auto
m
=
std
::
make_shared
<
ngraph
::
pattern
::
Matcher
>
(
add_beta
,
callback
);
auto
m
=
std
::
make_shared
<
ngraph
::
pattern
::
Matcher
>
(
add_beta
,
callback
);
this
->
add_matcher
(
m
);
this
->
add_matcher
(
m
);
}
}
void
ngraph
::
runtime
::
cpu
::
pass
::
CPUFusion
::
construct_conv_bias
()
{
Shape
shape
{
2
,
2
,
1
,
1
};
auto
data_batch
=
std
::
make_shared
<
pattern
::
op
::
Label
>
(
element
::
f32
,
shape
);
auto
filters
=
std
::
make_shared
<
pattern
::
op
::
Label
>
(
element
::
f32
,
shape
);
auto
pbias
=
std
::
make_shared
<
pattern
::
op
::
Label
>
(
element
::
f32
,
Shape
{});
auto
pbroadcast
=
std
::
make_shared
<
op
::
Broadcast
>
(
pbias
,
shape
,
AxisSet
{
0
,
1
,
2
,
3
});
auto
pconv1
=
std
::
make_shared
<
op
::
Convolution
>
(
data_batch
,
filters
,
Strides
{
1
,
1
},
Strides
{
1
,
1
},
CoordinateDiff
{
0
,
0
},
CoordinateDiff
{
0
,
0
},
Strides
{
1
,
1
});
auto
p_conv_bias
=
pbroadcast
+
pconv1
;
ngraph
::
pattern
::
gr_callback_fn
callback
=
[](
pattern
::
Matcher
&
m
)
{
NGRAPH_DEBUG
<<
"In callback for construct_conv_bias against node = "
<<
m
.
match_root
()
->
get_name
();
auto
pattern_map
=
m
.
get_pattern_map
();
std
::
shared_ptr
<
Node
>
nn
;
auto
conv
=
std
::
dynamic_pointer_cast
<
op
::
Convolution
>
(
m
.
match_root
()
->
get_input_op
(
0
));
auto
bias
=
m
.
match_root
()
->
get_input_op
(
1
);
auto
conv_bias
=
std
::
shared_ptr
<
Node
>
(
new
op
::
ConvolutionBias
(
conv
,
bias
));
return
conv_bias
;
};
auto
m
=
std
::
make_shared
<
ngraph
::
pattern
::
Matcher
>
(
p_conv_bias
,
callback
);
this
->
add_matcher
(
m
);
}
src/ngraph/runtime/cpu/pass/cpu_fusion.hpp
100644 → 100755
View file @
22819e78
...
@@ -40,9 +40,11 @@ public:
...
@@ -40,9 +40,11 @@ public:
{
{
construct_gemm_pattern
();
construct_gemm_pattern
();
construct_fprop_bn
();
construct_fprop_bn
();
construct_conv_bias
();
}
}
private
:
private
:
void
construct_gemm_pattern
();
void
construct_gemm_pattern
();
void
construct_fprop_bn
();
void
construct_fprop_bn
();
void
construct_conv_bias
();
};
};
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