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
07214d76
Commit
07214d76
authored
Feb 25, 2019
by
Shucai Xiao
Browse files
clang format
parent
d0e2ace6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
10 deletions
+14
-10
src/include/migraphx/operators.hpp
src/include/migraphx/operators.hpp
+3
-2
src/onnx/onnx.cpp
src/onnx/onnx.cpp
+3
-2
src/targets/cpu/lowering.cpp
src/targets/cpu/lowering.cpp
+8
-6
No files found.
src/include/migraphx/operators.hpp
View file @
07214d76
...
@@ -939,9 +939,10 @@ struct logsoftmax
...
@@ -939,9 +939,10 @@ struct logsoftmax
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
{
check_shapes
{
inputs
}.
has
(
1
);
check_shapes
{
inputs
}.
has
(
1
);
if
(
axis
<
0
||
axis
>=
inputs
[
0
].
lens
().
size
())
if
(
axis
<
0
||
axis
>=
inputs
[
0
].
lens
().
size
())
{
{
MIGRAPHX_THROW
(
"LogSoftMax: input axis value "
+
std
::
to_string
(
axis
)
+
" is out of range"
);
MIGRAPHX_THROW
(
"LogSoftMax: input axis value "
+
std
::
to_string
(
axis
)
+
" is out of range"
);
}
}
return
inputs
.
at
(
0
);
return
inputs
.
at
(
0
);
}
}
...
...
src/onnx/onnx.cpp
View file @
07214d76
...
@@ -229,8 +229,9 @@ struct onnx_parser
...
@@ -229,8 +229,9 @@ struct onnx_parser
return
prog
.
add_instruction
(
op
::
reshape
{{
long
(
dims
[
0
]),
long
(
dims
[
1
])}},
s
);
return
prog
.
add_instruction
(
op
::
reshape
{{
long
(
dims
[
0
]),
long
(
dims
[
1
])}},
s
);
}
}
instruction_ref
instruction_ref
parse_logsoftmax
(
const
std
::
string
&
,
parse_logsoftmax
(
const
std
::
string
&
,
const
attribute_map
&
attributes
,
std
::
vector
<
instruction_ref
>
args
)
const
attribute_map
&
attributes
,
std
::
vector
<
instruction_ref
>
args
)
{
{
int
axis
=
1
;
int
axis
=
1
;
if
(
contains
(
attributes
,
"axis"
))
if
(
contains
(
attributes
,
"axis"
))
...
...
src/targets/cpu/lowering.cpp
View file @
07214d76
...
@@ -619,7 +619,7 @@ struct cpu_logsoftmax
...
@@ -619,7 +619,7 @@ struct cpu_logsoftmax
std
::
string
name
()
const
{
return
"cpu::logsoftmax"
;
}
std
::
string
name
()
const
{
return
"cpu::logsoftmax"
;
}
shape
compute_shape
(
const
std
::
vector
<
shape
>&
inputs
)
const
{
return
op
.
compute_shape
(
inputs
);
}
shape
compute_shape
(
const
std
::
vector
<
shape
>&
inputs
)
const
{
return
op
.
compute_shape
(
inputs
);
}
template
<
typename
T
>
template
<
typename
T
>
std
::
size_t
compute_batch_index
(
const
T
&
idx
,
shape
&
batch_shape
,
int
axis
)
const
std
::
size_t
compute_batch_index
(
const
T
&
idx
,
shape
&
batch_shape
,
int
axis
)
const
{
{
std
::
vector
<
std
::
size_t
>
batch_idx
(
idx
.
begin
(),
idx
.
begin
()
+
axis
);
std
::
vector
<
std
::
size_t
>
batch_idx
(
idx
.
begin
(),
idx
.
begin
()
+
axis
);
...
@@ -636,7 +636,8 @@ struct cpu_logsoftmax
...
@@ -636,7 +636,8 @@ struct cpu_logsoftmax
visit_all
(
result
,
args
[
0
])([
&
](
auto
output
,
auto
input
)
{
visit_all
(
result
,
args
[
0
])([
&
](
auto
output
,
auto
input
)
{
using
value_type
=
typename
decltype
(
input
)
::
value_type
;
using
value_type
=
typename
decltype
(
input
)
::
value_type
;
std
::
vector
<
value_type
>
batch_max
(
batch_shape
.
elements
(),
std
::
numeric_limits
<
value_type
>::
lowest
());
std
::
vector
<
value_type
>
batch_max
(
batch_shape
.
elements
(),
std
::
numeric_limits
<
value_type
>::
lowest
());
shape_for_each
(
output_shape
,
[
&
](
auto
idx
)
{
shape_for_each
(
output_shape
,
[
&
](
auto
idx
)
{
auto
index
=
compute_batch_index
(
idx
,
batch_shape
,
op
.
axis
);
auto
index
=
compute_batch_index
(
idx
,
batch_shape
,
op
.
axis
);
batch_max
[
index
]
=
std
::
max
(
batch_max
[
index
],
input
(
idx
.
begin
(),
idx
.
end
()));
batch_max
[
index
]
=
std
::
max
(
batch_max
[
index
],
input
(
idx
.
begin
(),
idx
.
end
()));
...
@@ -653,14 +654,15 @@ struct cpu_logsoftmax
...
@@ -653,14 +654,15 @@ struct cpu_logsoftmax
batch_sum
[
index
]
+=
std
::
exp
(
output
(
idx
.
begin
(),
idx
.
end
()));
batch_sum
[
index
]
+=
std
::
exp
(
output
(
idx
.
begin
(),
idx
.
end
()));
});
});
for
(
std
::
size_t
i
=
0
;
i
<
batch_sum
.
size
();
++
i
)
for
(
std
::
size_t
i
=
0
;
i
<
batch_sum
.
size
();
++
i
)
{
{
batch_sum
[
i
]
=
std
::
log
(
batch_sum
[
i
]);
batch_sum
[
i
]
=
std
::
log
(
batch_sum
[
i
]);
}
}
shape_for_each
(
output_shape
,
[
&
](
auto
idx
)
{
shape_for_each
(
output_shape
,
[
&
](
auto
idx
)
{
auto
index
=
compute_batch_index
(
idx
,
batch_shape
,
op
.
axis
);
auto
index
=
compute_batch_index
(
idx
,
batch_shape
,
op
.
axis
);
output
(
idx
.
begin
(),
idx
.
end
())
=
input
(
idx
.
begin
(),
idx
.
end
())
-
batch_max
[
index
]
-
batch_sum
[
index
];
output
(
idx
.
begin
(),
idx
.
end
())
=
input
(
idx
.
begin
(),
idx
.
end
())
-
batch_max
[
index
]
-
batch_sum
[
index
];
});
});
});
});
...
...
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