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
c21bbba0
Commit
c21bbba0
authored
Jul 20, 2018
by
Jaikrishnan Menon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CPU Direct Execution: Commit missed kernel changes for Sum reduction
parent
f60dd831
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
11 deletions
+70
-11
reduce_sum.hpp
src/ngraph/runtime/cpu/kernel/reduce_sum.hpp
+70
-11
No files found.
src/ngraph/runtime/cpu/kernel/reduce_sum.hpp
View file @
c21bbba0
...
...
@@ -20,6 +20,7 @@
#include <unsupported/Eigen/CXX11/Tensor>
#include "ngraph/runtime/cpu/kernel/eigen_thread_pool.hpp"
#include "ngraph/runtime/reference/sum.hpp"
#include "ngraph/shape.hpp"
namespace
ngraph
...
...
@@ -31,8 +32,8 @@ namespace ngraph
namespace
kernel
{
template
<
typename
ElementType
,
unsigned
int
Rank
>
void
reduce_sum_all
(
ElementType
*
input
,
ElementType
*
output
,
void
reduce_sum_all
(
void
*
input
,
void
*
output
,
const
Shape
&
input_shape
,
const
Shape
&
output_shape
)
{
...
...
@@ -44,16 +45,16 @@ namespace ngraph
in_dims
[
i
]
=
input_shape
[
i
];
}
Eigen
::
TensorMap
<
Eigen
::
Tensor
<
ElementType
,
0
,
Eigen
::
RowMajor
>>
out
(
output
,
out_dims
);
Eigen
::
TensorMap
<
Eigen
::
Tensor
<
ElementType
,
Rank
,
Eigen
::
RowMajor
>>
in
(
input
,
in_dims
);
Eigen
::
TensorMap
<
Eigen
::
Tensor
<
ElementType
,
0
,
Eigen
::
RowMajor
>>
out
(
static_cast
<
ElementType
*>
(
output
),
out_dims
);
Eigen
::
TensorMap
<
Eigen
::
Tensor
<
ElementType
,
Rank
,
Eigen
::
RowMajor
>>
in
(
static_cast
<
ElementType
*>
(
input
),
in_dims
);
out
.
device
(
eigen
::
global_thread_pool_device
)
=
in
.
sum
();
}
template
<
typename
ElementType
,
unsigned
int
Rank
,
unsigned
int
ReductionDims
>
void
reduce_sum
(
ElementType
*
input
,
ElementType
*
output
,
void
reduce_sum
(
void
*
input
,
void
*
output
,
const
Shape
&
input_shape
,
const
Shape
&
output_shape
,
const
AxisSet
&
reduction_axes
)
...
...
@@ -80,11 +81,69 @@ namespace ngraph
Eigen
::
TensorMap
<
Eigen
::
Tensor
<
ElementType
,
Rank
-
ReductionDims
,
Eigen
::
RowMajor
>>
out
(
output
,
out_dims
);
Eigen
::
TensorMap
<
Eigen
::
Tensor
<
ElementType
,
Rank
,
Eigen
::
RowMajor
>>
in
(
input
,
in_dims
);
out
(
static_cast
<
ElementType
*>
(
output
)
,
out_dims
);
Eigen
::
TensorMap
<
Eigen
::
Tensor
<
ElementType
,
Rank
,
Eigen
::
RowMajor
>>
in
(
static_cast
<
ElementType
*>
(
input
),
in_dims
);
out
.
device
(
eigen
::
global_thread_pool_device
)
=
in
.
sum
(
reduction_dims
);
}
template
<
typename
ElementType
,
unsigned
int
Rank
>
void
reduce_sum_1rd
(
void
*
input
,
void
*
output
,
const
Shape
&
input_shape
,
const
Shape
&
output_shape
,
const
AxisSet
&
reduction_axes
)
{
reduce_sum
<
ElementType
,
Rank
,
1
>
(
input
,
output
,
input_shape
,
output_shape
,
reduction_axes
);
}
template
<
typename
ElementType
>
void
reduce_sum_3d_2rd
(
void
*
input
,
void
*
output
,
const
Shape
&
input_shape
,
const
Shape
&
output_shape
,
const
AxisSet
&
reduction_axes
)
{
reduce_sum
<
ElementType
,
3
,
2
>
(
input
,
output
,
input_shape
,
output_shape
,
reduction_axes
);
}
template
<
typename
ElementType
>
void
reduce_sum_4d_2rd
(
void
*
input
,
void
*
output
,
const
Shape
&
input_shape
,
const
Shape
&
output_shape
,
const
AxisSet
&
reduction_axes
)
{
reduce_sum
<
ElementType
,
4
,
2
>
(
input
,
output
,
input_shape
,
output_shape
,
reduction_axes
);
}
template
<
typename
ElementType
>
void
reduce_sum_5d_2rd
(
void
*
input
,
void
*
output
,
const
Shape
&
input_shape
,
const
Shape
&
output_shape
,
const
AxisSet
&
reduction_axes
)
{
reduce_sum
<
ElementType
,
5
,
2
>
(
input
,
output
,
input_shape
,
output_shape
,
reduction_axes
);
}
template
<
typename
ElementType
>
void
sum
(
void
*
arg
,
void
*
out
,
const
Shape
&
in_shape
,
const
Shape
&
out_shape
,
const
AxisSet
&
reduction_axes
)
{
reference
::
sum
(
static_cast
<
ElementType
*>
(
arg
),
static_cast
<
ElementType
*>
(
out
),
in_shape
,
out_shape
,
reduction_axes
);
}
}
}
}
...
...
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