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
0352e218
Unverified
Commit
0352e218
authored
Feb 22, 2018
by
Fenglei
Committed by
GitHub
Feb 22, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into tfl/gpu_framework_codegen
parents
8986a83e
29014bab
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
15 deletions
+23
-15
reduce_ops.cpp
src/ngraph/builder/reduce_ops.cpp
+18
-9
cpu_emitter.cpp
src/ngraph/runtime/cpu/cpu_emitter.cpp
+5
-6
No files found.
src/ngraph/builder/reduce_ops.cpp
View file @
0352e218
...
...
@@ -15,10 +15,12 @@
*******************************************************************************/
#include "ngraph/builder/reduce_ops.hpp"
#include "ngraph/builder/autobroadcast.hpp"
#include "ngraph/ops/add.hpp"
#include "ngraph/ops/divide.hpp"
#include "ngraph/ops/multiply.hpp"
#include "ngraph/ops/power.hpp"
#include "ngraph/ops/reshape.hpp"
#include "ngraph/ops/subtract.hpp"
#include "ngraph/ops/sum.hpp"
...
...
@@ -80,27 +82,34 @@ namespace ngraph
const
AxisSet
&
reduction_axes
,
const
bool
bessel_correction
)
{
auto
xsum
=
std
::
make_shared
<
op
::
Sum
>
(
node
,
reduction_axes
);
std
::
shared_ptr
<
Node
>
mu
=
mean
(
node
,
reduction_axes
);
auto
x2
=
node
*
node
;
auto
reshape
=
node
->
get_shape
();
for
(
auto
i
:
reduction_axes
)
{
reshape
[
i
]
=
1
;
}
auto
x2sum
=
std
::
make_shared
<
op
::
Sum
>
(
x2
,
reduction_axes
);
ngraph
::
AxisVector
order
(
mu
->
get_shape
().
size
());
std
::
iota
(
order
.
begin
(),
order
.
end
(),
0
);
const
auto
&
et
=
node
->
get_element_type
();
auto
N
=
get_num_elements
(
node
->
get_shape
(),
reduction_axes
);
mu
=
std
::
make_shared
<
op
::
Reshape
>
(
mu
,
order
,
reshape
);
std
::
shared_ptr
<
Node
>
diff
=
make_with_numpy_broadcast
<
op
::
Subtract
>
(
node
,
mu
);
auto
Nconst
=
op
::
Constant
::
create
(
et
,
xsum
->
get_shape
(),
{
N
});
auto
xbar2
=
(
xsum
*
xsum
)
/
Nconst
;
diff
=
std
::
make_shared
<
op
::
Sum
>
(
diff
*
diff
,
reduction_axes
);
auto
diff
=
x2sum
-
xbar2
;
const
auto
&
et
=
node
->
get_element_type
();
auto
N
=
get_num_elements
(
node
->
get_shape
(),
reduction_axes
);
if
(
bessel_correction
)
{
auto
N1const
=
op
::
Constant
::
create
(
et
,
xsum
->
get_shape
(),
{
N
-
1
});
auto
N1const
=
op
::
Constant
::
create
(
et
,
diff
->
get_shape
(),
{
N
-
1
});
return
diff
/
N1const
;
}
else
{
auto
Nconst
=
op
::
Constant
::
create
(
et
,
diff
->
get_shape
(),
{
N
});
return
diff
/
Nconst
;
}
}
...
...
src/ngraph/runtime/cpu/cpu_emitter.cpp
View file @
0352e218
...
...
@@ -2682,14 +2682,13 @@ namespace ngraph
void
CPU_Emitter
::
EMITTER_DECL
(
ngraph
::
op
::
MaxPoolBackprop
)
{
auto
mpb
=
static_cast
<
const
ngraph
::
op
::
MaxPoolBackprop
*>
(
node
);
auto
max_pool_fprop_op
=
mpb
->
get_forward_op
();
auto
delta_shape
=
args
[
1
].
get_shape
();
auto
delta_rank
=
delta_shape
.
size
();
auto
out_shape
=
out
[
0
].
get_shape
();
if
(
delta_rank
==
4
&&
mpb
->
get_window_shape
().
size
()
==
2
&&
args
[
0
].
get_element_type
()
==
element
::
f32
&&
max_pool_fprop_op
!=
nullptr
)
args
[
0
].
get_element_type
()
==
element
::
f32
)
{
const
string
&
et
=
get_mkldnn_data_type
(
args
[
1
].
get_element_type
().
c_type_string
());
...
...
@@ -2725,10 +2724,10 @@ namespace ngraph
"pooling_forward::primitive_desc("
<<
"{prop_kind::forward, algorithm::pooling_max, "
<<
"max_pool_input_desc, max_pool_result_desc, {"
<<
join
(
m
ax_pool_fprop_op
->
get_window_movement_strides
())
<<
"}, {"
<<
join
(
m
ax_pool_fprop_op
->
get_window_shape
())
<<
"}, "
<<
"{"
<<
join
(
m
ax_pool_fprop_op
->
get_padding_below
())
<<
"}, "
<<
"{"
<<
join
(
m
ax_pool_fprop_op
->
get_padding_above
())
<<
"}, "
<<
join
(
m
pb
->
get_window_movement_strides
())
<<
"}, {"
<<
join
(
m
pb
->
get_window_shape
())
<<
"}, "
<<
"{"
<<
join
(
m
pb
->
get_padding_below
())
<<
"}, "
<<
"{"
<<
join
(
m
pb
->
get_padding_above
())
<<
"}, "
<<
"padding_kind::zero}, cpu_engine);
\n
"
;
// query the workspace from the forward primitive desc and allocates memory
...
...
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