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
1af49c6f
Commit
1af49c6f
authored
Jun 04, 2022
by
Paul
Browse files
Format
parent
187a4769
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
src/targets/gpu/kernels/include/migraphx/kernels/layernorm.hpp
...argets/gpu/kernels/include/migraphx/kernels/layernorm.hpp
+4
-2
No files found.
src/targets/gpu/kernels/include/migraphx/kernels/layernorm.hpp
View file @
1af49c6f
...
@@ -10,12 +10,14 @@ template <index_int Axis, class F, class Output, class Input, class... Inputs>
...
@@ -10,12 +10,14 @@ template <index_int Axis, class F, class Output, class Input, class... Inputs>
__device__
void
layernorm
(
F
compute
,
Output
output
,
Input
input
,
Inputs
...
inputs
)
__device__
void
layernorm
(
F
compute
,
Output
output
,
Input
input
,
Inputs
...
inputs
)
{
{
using
reduce_output
=
reduce
::
with_axis
<
Input
,
Axis
>
;
using
reduce_output
=
reduce
::
with_axis
<
Input
,
Axis
>
;
constexpr
auto
relements
=
get_shape_c
<
Input
>
{}.
elements
()
/
get_shape_c
<
reduce_output
>
{}.
elements
();
constexpr
auto
relements
=
get_shape_c
<
Input
>
{}.
elements
()
/
get_shape_c
<
reduce_output
>
{}.
elements
();
MIGRAPHX_ASSERT
(
relements
>
0
);
MIGRAPHX_ASSERT
(
relements
>
0
);
reduce
::
block
::
run
<
reduce_output
>
([
&
](
auto
,
auto
r
)
{
reduce
::
block
::
run
<
reduce_output
>
([
&
](
auto
,
auto
r
)
{
using
value_type
=
typename
Input
::
type
;
using
value_type
=
typename
Input
::
type
;
auto
mean
=
[
&
](
auto
f
)
{
auto
mean
=
[
&
](
auto
f
)
{
return
r
.
reduce
(
op
::
sum
{},
0
,
[
&
](
auto
x
)
{
return
f
(
x
)
/
value_type
{
relements
};
})(
input
);
return
r
.
reduce
(
op
::
sum
{},
0
,
[
&
](
auto
x
)
{
return
f
(
x
)
/
value_type
{
relements
};
})(
input
);
};
};
// mean(x)
// mean(x)
auto
mean_x
=
mean
(
op
::
id
{});
auto
mean_x
=
mean
(
op
::
id
{});
...
...
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