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
b263cfa0
Commit
b263cfa0
authored
Nov 30, 2018
by
Khalique
Browse files
replace for loop with accumulate
parent
cdbe643c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
27 deletions
+3
-27
src/onnx/onnx.cpp
src/onnx/onnx.cpp
+3
-27
No files found.
src/onnx/onnx.cpp
View file @
b263cfa0
...
@@ -185,43 +185,19 @@ struct onnx_parser
...
@@ -185,43 +185,19 @@ struct onnx_parser
instruction_ref
instruction_ref
parse_sum
(
const
std
::
string
&
,
const
attribute_map
&
,
std
::
vector
<
instruction_ref
>
args
)
parse_sum
(
const
std
::
string
&
,
const
attribute_map
&
,
std
::
vector
<
instruction_ref
>
args
)
{
{
auto
curr_sum
=
args
.
front
();
return
std
::
accumulate
(
std
::
next
(
args
.
begin
()),
args
.
end
(),
args
.
front
(),
[
this
](
instruction_ref
a
,
instruction_ref
b
){
return
add_broadcastable_binary_op
(
a
,
b
,
op
::
add
{});});
if
(
args
.
size
()
>
1
)
{
for
(
auto
it
=
std
::
next
(
args
.
begin
());
it
!=
args
.
end
();
++
it
)
{
curr_sum
=
add_broadcastable_binary_op
(
curr_sum
,
*
it
,
op
::
add
{});
}
}
return
curr_sum
;
}
}
instruction_ref
instruction_ref
parse_max
(
const
std
::
string
&
,
const
attribute_map
&
,
std
::
vector
<
instruction_ref
>
args
)
parse_max
(
const
std
::
string
&
,
const
attribute_map
&
,
std
::
vector
<
instruction_ref
>
args
)
{
{
auto
curr_max
=
args
.
front
();
return
std
::
accumulate
(
std
::
next
(
args
.
begin
()),
args
.
end
(),
args
.
front
(),
[
this
](
instruction_ref
a
,
instruction_ref
b
){
return
add_broadcastable_binary_op
(
a
,
b
,
op
::
max
{});});
if
(
args
.
size
()
>
1
)
{
for
(
auto
it
=
std
::
next
(
args
.
begin
());
it
!=
args
.
end
();
++
it
)
{
curr_max
=
add_broadcastable_binary_op
(
curr_max
,
*
it
,
op
::
max
{});
}
}
return
curr_max
;
}
}
instruction_ref
instruction_ref
parse_min
(
const
std
::
string
&
,
const
attribute_map
&
,
std
::
vector
<
instruction_ref
>
args
)
parse_min
(
const
std
::
string
&
,
const
attribute_map
&
,
std
::
vector
<
instruction_ref
>
args
)
{
{
auto
curr_min
=
args
.
front
();
return
std
::
accumulate
(
std
::
next
(
args
.
begin
()),
args
.
end
(),
args
.
front
(),
[
this
](
instruction_ref
a
,
instruction_ref
b
){
return
add_broadcastable_binary_op
(
a
,
b
,
op
::
min
{});});
if
(
args
.
size
()
>
1
)
{
for
(
auto
it
=
std
::
next
(
args
.
begin
());
it
!=
args
.
end
();
++
it
)
{
curr_min
=
add_broadcastable_binary_op
(
curr_min
,
*
it
,
op
::
min
{});
}
}
return
curr_min
;
}
}
instruction_ref
instruction_ref
...
...
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