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
d473eda9
Commit
d473eda9
authored
Aug 17, 2018
by
Jaikrishnan Menon
Committed by
Scott Cyphers
Aug 17, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DEX: Enable packetized innermost dim reducers (#1431)
parent
d742c501
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
123 additions
and
0 deletions
+123
-0
reduction.hpp
src/ngraph/runtime/cpu/builder/reduction.hpp
+15
-0
reduce_max.hpp
src/ngraph/runtime/cpu/kernel/reduce_max.hpp
+27
-0
reduce_min.hpp
src/ngraph/runtime/cpu/kernel/reduce_min.hpp
+27
-0
reduce_product.hpp
src/ngraph/runtime/cpu/kernel/reduce_product.hpp
+27
-0
reduce_sum.hpp
src/ngraph/runtime/cpu/kernel/reduce_sum.hpp
+27
-0
No files found.
src/ngraph/runtime/cpu/builder/reduction.hpp
View file @
d473eda9
...
...
@@ -54,6 +54,21 @@
\
if (reduction_axes.size() == 1) \
{ \
if (*reduction_axes.begin() == arg_rank - 1) \
{ \
std::function<decltype(runtime::cpu::kernel::reduce_##K##_innermost_1rd<float, 2>)> \
kernel; \
SELECT_KERNEL_BY_RANK(kernel, \
result_element_type, \
arg_rank, \
runtime::cpu::kernel::reduce_##K##_innermost_1rd); \
auto functor = [&, kernel, arg_shape, result_shape](CPURuntimeContext* ctx) { \
kernel(arg_tensor, out_tensor, arg_shape, result_shape); \
}; \
functors.emplace_back(functor); \
return; \
} \
\
std::function<decltype(runtime::cpu::kernel::reduce_##K##_1rd<float, 2>)> kernel; \
SELECT_KERNEL_BY_RANK( \
kernel, result_element_type, arg_rank, runtime::cpu::kernel::reduce_##K##_1rd); \
...
...
src/ngraph/runtime/cpu/kernel/reduce_max.hpp
View file @
d473eda9
...
...
@@ -52,6 +52,33 @@ namespace ngraph
out
.
device
(
eigen
::
global_thread_pool_device
)
=
in
.
maximum
();
}
template
<
typename
ElementType
,
unsigned
int
Rank
>
void
reduce_max_innermost_1rd
(
void
*
input
,
void
*
output
,
const
Shape
&
input_shape
,
const
Shape
&
output_shape
)
{
Eigen
::
array
<
Eigen
::
Index
,
Rank
>
in_dims
;
Eigen
::
array
<
Eigen
::
Index
,
Rank
-
1
>
out_dims
;
Eigen
::
IndexList
<
Eigen
::
type2index
<
Rank
-
1
>>
reduction_dim
;
for
(
int
i
=
0
;
i
<
Rank
;
i
++
)
{
in_dims
[
i
]
=
input_shape
[
i
];
}
for
(
int
i
=
0
;
i
<
Rank
-
1
;
i
++
)
{
out_dims
[
i
]
=
output_shape
[
i
];
}
Eigen
::
TensorMap
<
Eigen
::
Tensor
<
ElementType
,
Rank
-
1
,
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
.
maximum
(
reduction_dim
);
}
template
<
typename
ElementType
,
unsigned
int
Rank
,
unsigned
int
ReductionDims
>
void
reduce_max
(
void
*
input
,
void
*
output
,
...
...
src/ngraph/runtime/cpu/kernel/reduce_min.hpp
View file @
d473eda9
...
...
@@ -52,6 +52,33 @@ namespace ngraph
out
.
device
(
eigen
::
global_thread_pool_device
)
=
in
.
minimum
();
}
template
<
typename
ElementType
,
unsigned
int
Rank
>
void
reduce_min_innermost_1rd
(
void
*
input
,
void
*
output
,
const
Shape
&
input_shape
,
const
Shape
&
output_shape
)
{
Eigen
::
array
<
Eigen
::
Index
,
Rank
>
in_dims
;
Eigen
::
array
<
Eigen
::
Index
,
Rank
-
1
>
out_dims
;
Eigen
::
IndexList
<
Eigen
::
type2index
<
Rank
-
1
>>
reduction_dim
;
for
(
int
i
=
0
;
i
<
Rank
;
i
++
)
{
in_dims
[
i
]
=
input_shape
[
i
];
}
for
(
int
i
=
0
;
i
<
Rank
-
1
;
i
++
)
{
out_dims
[
i
]
=
output_shape
[
i
];
}
Eigen
::
TensorMap
<
Eigen
::
Tensor
<
ElementType
,
Rank
-
1
,
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
.
minimum
(
reduction_dim
);
}
template
<
typename
ElementType
,
unsigned
int
Rank
,
unsigned
int
ReductionDims
>
void
reduce_min
(
void
*
input
,
void
*
output
,
...
...
src/ngraph/runtime/cpu/kernel/reduce_product.hpp
View file @
d473eda9
...
...
@@ -52,6 +52,33 @@ namespace ngraph
out
.
device
(
eigen
::
global_thread_pool_device
)
=
in
.
prod
();
}
template
<
typename
ElementType
,
unsigned
int
Rank
>
void
reduce_product_innermost_1rd
(
void
*
input
,
void
*
output
,
const
Shape
&
input_shape
,
const
Shape
&
output_shape
)
{
Eigen
::
array
<
Eigen
::
Index
,
Rank
>
in_dims
;
Eigen
::
array
<
Eigen
::
Index
,
Rank
-
1
>
out_dims
;
Eigen
::
IndexList
<
Eigen
::
type2index
<
Rank
-
1
>>
reduction_dim
;
for
(
int
i
=
0
;
i
<
Rank
;
i
++
)
{
in_dims
[
i
]
=
input_shape
[
i
];
}
for
(
int
i
=
0
;
i
<
Rank
-
1
;
i
++
)
{
out_dims
[
i
]
=
output_shape
[
i
];
}
Eigen
::
TensorMap
<
Eigen
::
Tensor
<
ElementType
,
Rank
-
1
,
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
.
prod
(
reduction_dim
);
}
template
<
typename
ElementType
,
unsigned
int
Rank
,
unsigned
int
ReductionDims
>
void
reduce_product
(
void
*
input
,
void
*
output
,
...
...
src/ngraph/runtime/cpu/kernel/reduce_sum.hpp
View file @
d473eda9
...
...
@@ -52,6 +52,33 @@ namespace ngraph
out
.
device
(
eigen
::
global_thread_pool_device
)
=
in
.
sum
();
}
template
<
typename
ElementType
,
unsigned
int
Rank
>
void
reduce_sum_innermost_1rd
(
void
*
input
,
void
*
output
,
const
Shape
&
input_shape
,
const
Shape
&
output_shape
)
{
Eigen
::
array
<
Eigen
::
Index
,
Rank
>
in_dims
;
Eigen
::
array
<
Eigen
::
Index
,
Rank
-
1
>
out_dims
;
Eigen
::
IndexList
<
Eigen
::
type2index
<
Rank
-
1
>>
reduction_dim
;
for
(
int
i
=
0
;
i
<
Rank
;
i
++
)
{
in_dims
[
i
]
=
input_shape
[
i
];
}
for
(
int
i
=
0
;
i
<
Rank
-
1
;
i
++
)
{
out_dims
[
i
]
=
output_shape
[
i
];
}
Eigen
::
TensorMap
<
Eigen
::
Tensor
<
ElementType
,
Rank
-
1
,
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
(
reduction_dim
);
}
template
<
typename
ElementType
,
unsigned
int
Rank
,
unsigned
int
ReductionDims
>
void
reduce_sum
(
void
*
input
,
void
*
output
,
...
...
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