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
3a55ce36
Commit
3a55ce36
authored
Oct 02, 2018
by
Adam Procter
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master' into aprocter/partial-shape
parents
3cef466f
18e41513
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
3 deletions
+65
-3
cpu_external_function.cpp
src/ngraph/runtime/cpu/cpu_external_function.cpp
+4
-3
cpu_mat_fusion.cpp
src/ngraph/runtime/cpu/pass/cpu_mat_fusion.cpp
+0
-0
cpu_fusion.cpp
test/cpu_fusion.cpp
+61
-0
No files found.
src/ngraph/runtime/cpu/cpu_external_function.cpp
View file @
3a55ce36
...
...
@@ -1000,11 +1000,12 @@ void runtime::cpu::CPU_ExternalFunction::register_common_passes(ngraph::pass::Ma
pass_manager
.
register_pass
<
ngraph
::
pass
::
NopElimination
>
();
// TODO (pruthvi): Enable all the disabeled RNN fusion graph pass after fixing
// failing mxnet unit tests.
//
pass_manager.register_pass<runtime::cpu::pass::LSTMFusion>();
//
pass_manager.register_pass<runtime::cpu::pass::RNNFusion>();
pass_manager
.
register_pass
<
runtime
::
cpu
::
pass
::
LSTMFusion
>
();
pass_manager
.
register_pass
<
runtime
::
cpu
::
pass
::
RNNFusion
>
();
pass_manager
.
register_pass
<
ngraph
::
pass
::
AlgebraicSimplification
>
();
//
pass_manager.register_pass<runtime::cpu::pass::MultiLayerRNNFusion>();
pass_manager
.
register_pass
<
runtime
::
cpu
::
pass
::
MultiLayerRNNFusion
>
();
// pass_manager.register_pass<runtime::cpu::pass::ConcatInputs>();
pass_manager
.
register_pass
<
runtime
::
cpu
::
pass
::
CPURnnMatFusion
>
();
pass_manager
.
register_pass
<
runtime
::
cpu
::
pass
::
CPUBatchFusion
>
();
pass_manager
.
register_pass
<
ngraph
::
pass
::
CommonSubexpressionElimination
>
();
pass_manager
.
register_pass
<
ngraph
::
pass
::
CoreFusion
>
();
...
...
src/ngraph/runtime/cpu/pass/cpu_mat_fusion.cpp
View file @
3a55ce36
This diff is collapsed.
Click to expand it.
test/cpu_fusion.cpp
View file @
3a55ce36
...
...
@@ -2822,3 +2822,64 @@ TEST(cpu_fusion, dot_batch_forward)
EXPECT_TRUE
(
test
::
all_close
(
cpu_results
.
at
(
i
),
int_results
.
at
(
i
),
1.0e-4
f
,
1.0e-4
f
));
}
}
static
std
::
shared_ptr
<
Function
>
create_rnn_input_linear_transformation_function
(
size_t
num_timesteps
)
{
auto
W
=
std
::
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
Shape
{
400
,
50
});
auto
bias
=
std
::
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
Shape
{
400
});
op
::
ParameterVector
params
{
W
,
bias
};
auto
create_graph
=
[
&
]()
->
std
::
shared_ptr
<
Node
>
{
auto
data_param
=
std
::
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
Shape
{
10
,
1
,
50
});
params
.
push_back
(
data_param
);
auto
data_param_reshape
=
std
::
make_shared
<
op
::
Reshape
>
(
data_param
,
AxisVector
{
0
,
1
,
2
},
Shape
{
10
,
50
});
auto
W_reshape
=
std
::
make_shared
<
op
::
Reshape
>
(
W
,
AxisVector
{
1
,
0
},
Shape
{
50
,
400
});
auto
dot
=
std
::
make_shared
<
op
::
Dot
>
(
data_param_reshape
,
W_reshape
);
auto
bias_broadcast
=
make_shared
<
op
::
Broadcast
>
(
bias
,
dot
->
get_shape
(),
AxisSet
{
0
});
auto
add_bias
=
std
::
make_shared
<
op
::
Add
>
(
dot
,
bias_broadcast
);
return
add_bias
;
};
NodeVector
graph_nodes
;
for
(
size_t
i
=
0
;
i
<
num_timesteps
;
i
++
)
{
graph_nodes
.
push_back
(
create_graph
());
}
auto
concat
=
std
::
make_shared
<
op
::
Concat
>
(
graph_nodes
,
0
);
return
make_shared
<
Function
>
(
NodeVector
{
concat
},
params
);
}
TEST
(
cpu_fusion
,
fuse_rnn_input_across_time_steps
)
{
auto
func
=
create_rnn_input_linear_transformation_function
(
10
);
pass
::
Manager
pass_manager
;
pass_manager
.
register_pass
<
runtime
::
cpu
::
pass
::
CPURnnMatFusion
>
();
pass_manager
.
register_pass
<
runtime
::
cpu
::
pass
::
CPUFusion
>
();
pass_manager
.
run_passes
(
func
);
size_t
ref_matmulbias_count
=
1
;
auto
matmulbias_count
=
count_ops_of_type
<
op
::
MatmulBias
>
(
func
);
EXPECT_EQ
(
ref_matmulbias_count
,
matmulbias_count
);
}
TEST
(
cpu_fusion
,
rnn_input_fusion_inter_vs_cpu
)
{
shared_ptr
<
Function
>
cpu_func
=
create_rnn_input_linear_transformation_function
(
10
);
shared_ptr
<
Function
>
int_func
=
create_rnn_input_linear_transformation_function
(
10
);
test
::
Uniform
<
float
>
rng
(
-
10.0
f
,
10.0
f
);
vector
<
vector
<
float
>>
args
;
for
(
shared_ptr
<
op
::
Parameter
>
param
:
int_func
->
get_parameters
())
{
vector
<
float
>
tensor_val
(
shape_size
(
param
->
get_shape
()));
rng
.
initialize
(
tensor_val
);
args
.
push_back
(
tensor_val
);
}
auto
int_results
=
execute
(
int_func
,
args
,
"INTERPRETER"
);
auto
cpu_results
=
execute
(
cpu_func
,
args
,
"CPU"
);
for
(
size_t
i
=
0
;
i
<
cpu_results
.
size
();
i
++
)
{
EXPECT_TRUE
(
test
::
all_close
(
cpu_results
.
at
(
i
),
int_results
.
at
(
i
),
1.0e-4
f
,
1.0e-4
f
));
}
}
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