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
7f7cbbc0
Commit
7f7cbbc0
authored
May 30, 2019
by
Shucai Xiao
Browse files
clang format
parent
88351f31
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
11 deletions
+12
-11
src/targets/gpu/device/softmax.cpp
src/targets/gpu/device/softmax.cpp
+12
-11
No files found.
src/targets/gpu/device/softmax.cpp
View file @
7f7cbbc0
...
@@ -17,9 +17,9 @@ argument softmax(hipStream_t stream,
...
@@ -17,9 +17,9 @@ argument softmax(hipStream_t stream,
std
::
vector
<
migraphx
::
argument
>
args
,
std
::
vector
<
migraphx
::
argument
>
args
,
int
axis
)
int
axis
)
{
{
auto
lens
=
output_shape
.
lens
();
auto
lens
=
output_shape
.
lens
();
auto
batch_lens
=
lens
;
auto
batch_lens
=
lens
;
size_t
n_dims
=
lens
[
axis
];
size_t
n_dims
=
lens
[
axis
];
batch_lens
[
axis
]
=
1
;
batch_lens
[
axis
]
=
1
;
migraphx
::
shape
batch_shape
{
shape
::
int32_type
,
batch_lens
};
migraphx
::
shape
batch_shape
{
shape
::
int32_type
,
batch_lens
};
...
@@ -33,26 +33,27 @@ argument softmax(hipStream_t stream,
...
@@ -33,26 +33,27 @@ argument softmax(hipStream_t stream,
// each thread is for one item in the batch
// each thread is for one item in the batch
gs_launch
(
stream
,
batch_shape
.
elements
())([
=
](
auto
i
)
{
gs_launch
(
stream
,
batch_shape
.
elements
())([
=
](
auto
i
)
{
auto
batch_idx
=
desc_batch
.
multi
(
i
);
auto
batch_idx
=
desc_batch
.
multi
(
i
);
auto
data_idx
=
batch_idx
;
auto
data_idx
=
batch_idx
;
// get max
// get max
auto
batch_max
=
input_ptr
[
desc_data
.
linear
(
batch_idx
)];
auto
batch_max
=
input_ptr
[
desc_data
.
linear
(
batch_idx
)];
for
(
std
::
size_t
j
=
1
;
j
<
n_dims
;
++
j
)
for
(
std
::
size_t
j
=
1
;
j
<
n_dims
;
++
j
)
{
{
data_idx
[
axis
]
=
j
;
data_idx
[
axis
]
=
j
;
batch_max
=
std
::
max
(
to_hip_type
(
batch_max
),
to_hip_type
(
input_ptr
[
desc_data
.
linear
(
data_idx
)]));
batch_max
=
std
::
max
(
to_hip_type
(
batch_max
),
to_hip_type
(
input_ptr
[
desc_data
.
linear
(
data_idx
)]));
}
}
for
(
std
::
size_t
j
=
0
;
j
<
n_dims
;
++
j
)
for
(
std
::
size_t
j
=
0
;
j
<
n_dims
;
++
j
)
{
{
data_idx
[
axis
]
=
j
;
data_idx
[
axis
]
=
j
;
auto
idx
=
desc_data
.
linear
(
data_idx
);
auto
idx
=
desc_data
.
linear
(
data_idx
);
output_ptr
[
idx
]
=
input_ptr
[
idx
]
-
batch_max
;
output_ptr
[
idx
]
=
input_ptr
[
idx
]
-
batch_max
;
}
}
for
(
std
::
size_t
j
=
0
;
j
<
n_dims
;
++
j
)
for
(
std
::
size_t
j
=
0
;
j
<
n_dims
;
++
j
)
{
{
data_idx
[
axis
]
=
j
;
data_idx
[
axis
]
=
j
;
auto
idx
=
desc_data
.
linear
(
data_idx
);
auto
idx
=
desc_data
.
linear
(
data_idx
);
output_ptr
[
idx
]
=
exp
(
to_hip_type
(
output_ptr
[
idx
]));
output_ptr
[
idx
]
=
exp
(
to_hip_type
(
output_ptr
[
idx
]));
}
}
...
@@ -65,8 +66,8 @@ argument softmax(hipStream_t stream,
...
@@ -65,8 +66,8 @@ argument softmax(hipStream_t stream,
for
(
std
::
size_t
j
=
0
;
j
<
n_dims
;
++
j
)
for
(
std
::
size_t
j
=
0
;
j
<
n_dims
;
++
j
)
{
{
data_idx
[
axis
]
=
j
;
data_idx
[
axis
]
=
j
;
auto
idx
=
desc_data
.
linear
(
data_idx
);
auto
idx
=
desc_data
.
linear
(
data_idx
);
output_ptr
[
idx
]
=
output_ptr
[
idx
]
/
batch_sum
;
output_ptr
[
idx
]
=
output_ptr
[
idx
]
/
batch_sum
;
}
}
});
});
...
...
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