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
60557bc6
Commit
60557bc6
authored
Jul 03, 2019
by
Shucai Xiao
Browse files
clang format
parent
795a7083
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
12 deletions
+20
-12
src/include/migraphx/op/reduce_mean.hpp
src/include/migraphx/op/reduce_mean.hpp
+10
-6
src/include/migraphx/op/reduce_sum.hpp
src/include/migraphx/op/reduce_sum.hpp
+10
-6
No files found.
src/include/migraphx/op/reduce_mean.hpp
View file @
60557bc6
...
@@ -34,20 +34,23 @@ struct reduce_mean
...
@@ -34,20 +34,23 @@ struct reduce_mean
return
{
s
.
type
(),
lens
};
return
{
s
.
type
(),
lens
};
}
}
template
<
class
T
>
template
<
class
T
>
void
calc_mean
(
tensor_view
<
T
>&
input
,
shape
&
batch_shape
,
std
::
vector
<
std
::
size_t
>&
out_idx
,
tensor_view
<
T
>&
output
)
const
void
calc_mean
(
tensor_view
<
T
>&
input
,
shape
&
batch_shape
,
std
::
vector
<
std
::
size_t
>&
out_idx
,
tensor_view
<
T
>&
output
)
const
{
{
auto
data_idx
=
out_idx
;
auto
data_idx
=
out_idx
;
T
val
=
T
{
0
};
T
val
=
T
{
0
};
shape_for_each
(
batch_shape
,
[
&
](
auto
b_idx
)
{
shape_for_each
(
batch_shape
,
[
&
](
auto
b_idx
)
{
for
(
auto
axis
:
axes
)
for
(
auto
axis
:
axes
)
{
{
data_idx
[
axis
]
=
b_idx
[
axis
];
data_idx
[
axis
]
=
b_idx
[
axis
];
}
}
val
+=
input
(
data_idx
.
begin
(),
data_idx
.
end
());
val
+=
input
(
data_idx
.
begin
(),
data_idx
.
end
());
});
});
output
(
out_idx
.
begin
(),
out_idx
.
end
())
=
val
/
batch_shape
.
elements
();
output
(
out_idx
.
begin
(),
out_idx
.
end
())
=
val
/
batch_shape
.
elements
();
}
}
argument
compute
(
const
shape
&
output_shape
,
std
::
vector
<
argument
>
args
)
const
argument
compute
(
const
shape
&
output_shape
,
std
::
vector
<
argument
>
args
)
const
...
@@ -55,7 +58,8 @@ struct reduce_mean
...
@@ -55,7 +58,8 @@ struct reduce_mean
argument
result
{
output_shape
};
argument
result
{
output_shape
};
auto
arg_lens
=
args
.
front
().
get_shape
().
lens
();
auto
arg_lens
=
args
.
front
().
get_shape
().
lens
();
std
::
vector
<
std
::
size_t
>
batch_lens
(
output_shape
.
lens
().
size
(),
1
);
std
::
vector
<
std
::
size_t
>
batch_lens
(
output_shape
.
lens
().
size
(),
1
);
for
(
auto
axis
:
axes
)
{
for
(
auto
axis
:
axes
)
{
batch_lens
[
axis
]
=
arg_lens
[
axis
];
batch_lens
[
axis
]
=
arg_lens
[
axis
];
}
}
shape
batch_shape
{
output_shape
.
type
(),
batch_lens
};
shape
batch_shape
{
output_shape
.
type
(),
batch_lens
};
...
...
src/include/migraphx/op/reduce_sum.hpp
View file @
60557bc6
...
@@ -34,20 +34,23 @@ struct reduce_sum
...
@@ -34,20 +34,23 @@ struct reduce_sum
return
{
s
.
type
(),
lens
};
return
{
s
.
type
(),
lens
};
}
}
template
<
class
T
>
template
<
class
T
>
void
calc_sum
(
tensor_view
<
T
>&
input
,
shape
&
batch_shape
,
std
::
vector
<
std
::
size_t
>&
out_idx
,
tensor_view
<
T
>&
output
)
const
void
calc_sum
(
tensor_view
<
T
>&
input
,
shape
&
batch_shape
,
std
::
vector
<
std
::
size_t
>&
out_idx
,
tensor_view
<
T
>&
output
)
const
{
{
auto
data_idx
=
out_idx
;
auto
data_idx
=
out_idx
;
T
val
=
T
{
0
};
T
val
=
T
{
0
};
shape_for_each
(
batch_shape
,
[
&
](
auto
b_idx
)
{
shape_for_each
(
batch_shape
,
[
&
](
auto
b_idx
)
{
for
(
auto
axis
:
axes
)
for
(
auto
axis
:
axes
)
{
{
data_idx
[
axis
]
=
b_idx
[
axis
];
data_idx
[
axis
]
=
b_idx
[
axis
];
}
}
val
+=
input
(
data_idx
.
begin
(),
data_idx
.
end
());
val
+=
input
(
data_idx
.
begin
(),
data_idx
.
end
());
});
});
output
(
out_idx
.
begin
(),
out_idx
.
end
())
=
val
;
output
(
out_idx
.
begin
(),
out_idx
.
end
())
=
val
;
}
}
argument
compute
(
const
shape
&
output_shape
,
std
::
vector
<
argument
>
args
)
const
argument
compute
(
const
shape
&
output_shape
,
std
::
vector
<
argument
>
args
)
const
...
@@ -55,7 +58,8 @@ struct reduce_sum
...
@@ -55,7 +58,8 @@ struct reduce_sum
argument
result
{
output_shape
};
argument
result
{
output_shape
};
auto
arg_lens
=
args
.
front
().
get_shape
().
lens
();
auto
arg_lens
=
args
.
front
().
get_shape
().
lens
();
std
::
vector
<
std
::
size_t
>
batch_lens
(
output_shape
.
lens
().
size
(),
1
);
std
::
vector
<
std
::
size_t
>
batch_lens
(
output_shape
.
lens
().
size
(),
1
);
for
(
auto
axis
:
axes
)
{
for
(
auto
axis
:
axes
)
{
batch_lens
[
axis
]
=
arg_lens
[
axis
];
batch_lens
[
axis
]
=
arg_lens
[
axis
];
}
}
shape
batch_shape
{
output_shape
.
type
(),
batch_lens
};
shape
batch_shape
{
output_shape
.
type
(),
batch_lens
};
...
...
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