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
0b769919
Commit
0b769919
authored
Feb 26, 2019
by
Shucai Xiao
Browse files
clang format
parent
6dc749f3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
16 deletions
+16
-16
src/targets/gpu/device/logsoftmax.cpp
src/targets/gpu/device/logsoftmax.cpp
+11
-11
src/targets/gpu/include/migraphx/gpu/device/logsoftmax.hpp
src/targets/gpu/include/migraphx/gpu/device/logsoftmax.hpp
+3
-3
src/targets/gpu/logsoftmax.cpp
src/targets/gpu/logsoftmax.cpp
+2
-2
No files found.
src/targets/gpu/device/logsoftmax.cpp
View file @
0b769919
...
@@ -12,9 +12,9 @@ namespace gpu {
...
@@ -12,9 +12,9 @@ namespace gpu {
namespace
device
{
namespace
device
{
argument
logsoftmax
(
hipStream_t
stream
,
argument
logsoftmax
(
hipStream_t
stream
,
const
migraphx
::
shape
&
output_shape
,
const
migraphx
::
shape
&
output_shape
,
std
::
vector
<
migraphx
::
argument
>
args
,
std
::
vector
<
migraphx
::
argument
>
args
,
int
axis
)
int
axis
)
{
{
auto
lens
=
output_shape
.
lens
();
auto
lens
=
output_shape
.
lens
();
...
@@ -25,28 +25,28 @@ argument logsoftmax(hipStream_t stream,
...
@@ -25,28 +25,28 @@ argument logsoftmax(hipStream_t stream,
migraphx
::
shape
comp_shape
{
output_shape
.
type
(),
{
batch_size
,
n_dims
}};
migraphx
::
shape
comp_shape
{
output_shape
.
type
(),
{
batch_size
,
n_dims
}};
visit_all
(
args
.
back
(),
args
.
front
())([
&
](
auto
output
,
auto
input
)
{
visit_all
(
args
.
back
(),
args
.
front
())([
&
](
auto
output
,
auto
input
)
{
const
auto
*
input_ptr
=
device_cast
(
input
.
data
());
const
auto
*
input_ptr
=
device_cast
(
input
.
data
());
auto
*
output_ptr
=
device_cast
(
output
.
data
());
auto
*
output_ptr
=
device_cast
(
output
.
data
());
// each thread is for one item in the batch
// each thread is for one item in the batch
gs_launch
(
stream
,
batch_size
)([
=
](
auto
i
)
{
gs_launch
(
stream
,
batch_size
)([
=
](
auto
i
)
{
std
::
size_t
row_start
=
i
*
n_dims
;
std
::
size_t
row_start
=
i
*
n_dims
;
// get max
// get max
auto
batch_max
=
input_ptr
[
row_start
];
auto
batch_max
=
input_ptr
[
row_start
];
for
(
std
::
size_t
j
=
1
;
j
<
n_dims
;
++
j
)
for
(
std
::
size_t
j
=
1
;
j
<
n_dims
;
++
j
)
{
{
auto
ind
=
row_start
+
j
;
auto
ind
=
row_start
+
j
;
batch_max
=
std
::
max
(
to_hip_type
(
batch_max
),
to_hip_type
(
input_ptr
[
ind
]));
batch_max
=
std
::
max
(
to_hip_type
(
batch_max
),
to_hip_type
(
input_ptr
[
ind
]));
}
}
for
(
std
::
size_t
j
=
0
;
j
<
n_dims
;
++
j
)
for
(
std
::
size_t
j
=
0
;
j
<
n_dims
;
++
j
)
{
{
auto
ind
=
row_start
+
j
;
auto
ind
=
row_start
+
j
;
output_ptr
[
ind
]
=
input_ptr
[
ind
]
-
batch_max
;
output_ptr
[
ind
]
=
input_ptr
[
ind
]
-
batch_max
;
}
}
auto
batch_sum
=
output_ptr
[
row_start
];
auto
batch_sum
=
output_ptr
[
row_start
];
for
(
std
::
size_t
j
=
1
;
j
<
n_dims
;
++
j
)
for
(
std
::
size_t
j
=
1
;
j
<
n_dims
;
++
j
)
{
{
auto
ind
=
row_start
+
j
;
auto
ind
=
row_start
+
j
;
batch_sum
+=
::
exp
(
to_hip_type
(
output_ptr
[
ind
]));
batch_sum
+=
::
exp
(
to_hip_type
(
output_ptr
[
ind
]));
...
@@ -54,7 +54,7 @@ argument logsoftmax(hipStream_t stream,
...
@@ -54,7 +54,7 @@ argument logsoftmax(hipStream_t stream,
batch_sum
=
::
log
(
to_hip_type
(
batch_sum
));
batch_sum
=
::
log
(
to_hip_type
(
batch_sum
));
for
(
std
::
size_t
j
=
0
;
j
<
n_dims
;
++
j
)
for
(
std
::
size_t
j
=
0
;
j
<
n_dims
;
++
j
)
{
{
auto
ind
=
row_start
+
j
;
auto
ind
=
row_start
+
j
;
output_ptr
[
ind
]
-=
batch_sum
;
output_ptr
[
ind
]
-=
batch_sum
;
...
...
src/targets/gpu/include/migraphx/gpu/device/logsoftmax.hpp
View file @
0b769919
...
@@ -11,9 +11,9 @@ namespace gpu {
...
@@ -11,9 +11,9 @@ namespace gpu {
namespace
device
{
namespace
device
{
argument
logsoftmax
(
hipStream_t
stream
,
argument
logsoftmax
(
hipStream_t
stream
,
const
migraphx
::
shape
&
output_shape
,
const
migraphx
::
shape
&
output_shape
,
std
::
vector
<
migraphx
::
argument
>
args
,
std
::
vector
<
migraphx
::
argument
>
args
,
int
axis
);
int
axis
);
}
// namespace device
}
// namespace device
}
// namespace gpu
}
// namespace gpu
...
...
src/targets/gpu/logsoftmax.cpp
View file @
0b769919
...
@@ -16,8 +16,8 @@ shape hip_logsoftmax::compute_shape(const std::vector<shape>& inputs) const
...
@@ -16,8 +16,8 @@ shape hip_logsoftmax::compute_shape(const std::vector<shape>& inputs) const
}
}
argument
hip_logsoftmax
::
compute
(
context
&
ctx
,
argument
hip_logsoftmax
::
compute
(
context
&
ctx
,
const
shape
&
output_shape
,
const
shape
&
output_shape
,
const
std
::
vector
<
argument
>&
args
)
const
const
std
::
vector
<
argument
>&
args
)
const
{
{
return
device
::
logsoftmax
(
ctx
.
get_stream
().
get
(),
output_shape
,
args
,
op
.
axis
);
return
device
::
logsoftmax
(
ctx
.
get_stream
().
get
(),
output_shape
,
args
,
op
.
axis
);
}
}
...
...
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