Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
d0c53a98
Commit
d0c53a98
authored
Jun 24, 2019
by
Paul
Browse files
Formatting
parent
2ed09f15
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
9 deletions
+9
-9
src/include/migraphx/op/reduce_sum.hpp
src/include/migraphx/op/reduce_sum.hpp
+4
-4
test/cpu_ops_test.cpp
test/cpu_ops_test.cpp
+5
-5
No files found.
src/include/migraphx/op/reduce_sum.hpp
View file @
d0c53a98
...
...
@@ -26,9 +26,9 @@ struct reduce_sum
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
check_shapes
{
inputs
,
*
this
}.
has
(
1
);
auto
s
=
inputs
.
at
(
0
);
auto
s
=
inputs
.
at
(
0
);
auto
lens
=
s
.
lens
();
for
(
auto
axis
:
axes
)
for
(
auto
axis
:
axes
)
lens
[
axis
]
=
1
;
return
{
s
.
type
(),
lens
};
}
...
...
@@ -36,10 +36,10 @@ struct reduce_sum
argument
compute
(
const
shape
&
output_shape
,
std
::
vector
<
argument
>
args
)
const
{
argument
result
{
output_shape
};
visit_all
(
result
,
args
[
0
])([
&
](
auto
output
,
auto
input
){
visit_all
(
result
,
args
[
0
])([
&
](
auto
output
,
auto
input
)
{
shape_for_each
(
input
.
get_shape
(),
[
&
](
auto
&&
in_idx
)
{
auto
out_idx
=
in_idx
;
for
(
auto
axis
:
axes
)
for
(
auto
axis
:
axes
)
out_idx
[
axis
]
=
0
;
output
(
out_idx
.
begin
(),
out_idx
.
end
())
+=
input
(
in_idx
.
begin
(),
in_idx
.
end
());
});
...
...
test/cpu_ops_test.cpp
View file @
d0c53a98
...
...
@@ -1588,7 +1588,7 @@ TEST_CASE(reduce_sum_test0)
migraphx
::
program
p
;
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
2
,
2
}};
auto
input
=
migraphx
::
literal
{
s
,
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
}};
auto
l0
=
p
.
add_literal
(
input
);
auto
l0
=
p
.
add_literal
(
input
);
p
.
add_instruction
(
migraphx
::
op
::
reduce_sum
{{
0
}},
l0
);
p
.
compile
(
migraphx
::
cpu
::
target
{});
auto
result
=
p
.
eval
({});
...
...
@@ -1603,7 +1603,7 @@ TEST_CASE(reduce_sum_test1)
migraphx
::
program
p
;
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
2
,
2
}};
auto
input
=
migraphx
::
literal
{
s
,
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
}};
auto
l0
=
p
.
add_literal
(
input
);
auto
l0
=
p
.
add_literal
(
input
);
p
.
add_instruction
(
migraphx
::
op
::
reduce_sum
{{
1
}},
l0
);
p
.
compile
(
migraphx
::
cpu
::
target
{});
auto
result
=
p
.
eval
({});
...
...
@@ -1618,7 +1618,7 @@ TEST_CASE(reduce_sum_test2)
migraphx
::
program
p
;
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
2
,
2
}};
auto
input
=
migraphx
::
literal
{
s
,
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
}};
auto
l0
=
p
.
add_literal
(
input
);
auto
l0
=
p
.
add_literal
(
input
);
p
.
add_instruction
(
migraphx
::
op
::
reduce_sum
{{
2
}},
l0
);
p
.
compile
(
migraphx
::
cpu
::
target
{});
auto
result
=
p
.
eval
({});
...
...
@@ -1633,7 +1633,7 @@ TEST_CASE(reduce_sum_test02)
migraphx
::
program
p
;
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
2
,
2
}};
auto
input
=
migraphx
::
literal
{
s
,
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
}};
auto
l0
=
p
.
add_literal
(
input
);
auto
l0
=
p
.
add_literal
(
input
);
p
.
add_instruction
(
migraphx
::
op
::
reduce_sum
{{
0
,
2
}},
l0
);
p
.
compile
(
migraphx
::
cpu
::
target
{});
auto
result
=
p
.
eval
({});
...
...
@@ -1648,7 +1648,7 @@ TEST_CASE(reduce_sum_test12)
migraphx
::
program
p
;
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
2
,
2
}};
auto
input
=
migraphx
::
literal
{
s
,
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
}};
auto
l0
=
p
.
add_literal
(
input
);
auto
l0
=
p
.
add_literal
(
input
);
p
.
add_instruction
(
migraphx
::
op
::
reduce_sum
{{
1
,
2
}},
l0
);
p
.
compile
(
migraphx
::
cpu
::
target
{});
auto
result
=
p
.
eval
({});
...
...
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