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
85247d4d
Commit
85247d4d
authored
May 31, 2022
by
Paul
Browse files
Format
parent
d94c54f0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
src/targets/gpu/kernels/include/migraphx/kernels/layernorm.hpp
...argets/gpu/kernels/include/migraphx/kernels/layernorm.hpp
+4
-3
No files found.
src/targets/gpu/kernels/include/migraphx/kernels/layernorm.hpp
View file @
85247d4d
...
...
@@ -8,16 +8,17 @@ namespace migraphx {
template
<
index_int
Axis
,
class
Input
,
class
Output
>
__device__
void
layernorm
(
Input
input
,
Output
output
)
{
constexpr
auto
relements
=
get_shape_c
<
reduce
::
with_axis
<
Input
,
Axis
>>
{}.
elements
()
/
get_shape_c
<
Input
>
{}.
elements
();
constexpr
auto
relements
=
get_shape_c
<
reduce
::
with_axis
<
Input
,
Axis
>>
{}.
elements
()
/
get_shape_c
<
Input
>
{}.
elements
();
reduce
::
block
::
run
<
reduce
::
with_axis
<
Input
,
Axis
>>
([
&
](
auto
,
auto
r
)
{
using
value_type
=
typename
Input
::
type
;
auto
mean
=
[
&
](
auto
f
)
{
auto
mean
=
[
&
](
auto
f
)
{
return
r
.
reduce
(
op
::
sum
{},
0
,
f
)(
input
)
/
value_type
{
relements
};
};
// mean(x)
auto
mean_x
=
mean
(
op
::
id
{});
// mean(m ^ 2)
auto
mean_m2
=
mean
([
&
](
auto
x
)
{
auto
mean_m2
=
mean
([
&
](
auto
x
)
{
auto
m
=
x
-
mean_x
;
return
m
*
m
;
});
...
...
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