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
fd0f647e
Commit
fd0f647e
authored
May 15, 2019
by
Shucai Xiao
Browse files
fixed a bug in the unary and binary compute implementation
parent
970ac115
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
16 deletions
+21
-16
src/include/migraphx/op/binary.hpp
src/include/migraphx/op/binary.hpp
+10
-8
src/include/migraphx/op/unary.hpp
src/include/migraphx/op/unary.hpp
+11
-8
No files found.
src/include/migraphx/op/binary.hpp
View file @
fd0f647e
...
@@ -33,14 +33,16 @@ struct binary : op_name<Derived>
...
@@ -33,14 +33,16 @@ struct binary : op_name<Derived>
if
(
s1
==
s2
and
s1
.
packed
())
if
(
s1
==
s2
and
s1
.
packed
())
{
{
shape
std_shape
{
s1
.
type
(),
s1
.
lens
()};
shape
std_shape
{
s1
.
type
(),
s1
.
lens
()};
auto
input1
=
make_view
(
std_shape
,
args
[
0
].
data
());
argument
std_result
{
std_shape
,
result
.
data
()};
auto
input2
=
make_view
(
std_shape
,
args
[
1
].
data
());
argument
std_arg0
{
std_shape
,
args
[
0
].
data
()};
auto
output
=
make_view
(
std_shape
,
result
.
data
());
argument
std_arg1
{
std_shape
,
args
[
1
].
data
()};
visit_all
(
std_result
,
std_arg0
,
std_arg1
)([
&
](
auto
output
,
auto
input1
,
auto
input2
)
{
std
::
transform
(
input1
.
begin
(),
std
::
transform
(
input1
.
begin
(),
input1
.
end
(),
input1
.
end
(),
input2
.
begin
(),
input2
.
begin
(),
output
.
begin
(),
output
.
begin
(),
static_cast
<
const
Derived
&>
(
*
this
).
apply
());
static_cast
<
const
Derived
&>
(
*
this
).
apply
());
});
}
}
else
else
{
{
...
...
src/include/migraphx/op/unary.hpp
View file @
fd0f647e
...
@@ -32,12 +32,17 @@ struct unary : op_name<Derived>
...
@@ -32,12 +32,17 @@ struct unary : op_name<Derived>
{
{
shape
std_in_shape
{
in_shape
.
type
(),
in_shape
.
lens
()};
shape
std_in_shape
{
in_shape
.
type
(),
in_shape
.
lens
()};
shape
std_out_shape
{
output_shape
.
type
(),
output_shape
.
lens
()};
shape
std_out_shape
{
output_shape
.
type
(),
output_shape
.
lens
()};
auto
input
=
make_view
(
std_in_shape
,
args
[
0
].
cast
());
argument
arg_in
{
std_in_shape
,
args
[
0
].
data
()};
auto
output
=
make_view
(
std_out_shape
,
result
.
cast
());
argument
arg_out
{
std_out_shape
,
result
.
data
()};
arg_out
.
visit
([
&
](
auto
output
)
{
arg_in
.
visit
([
&
](
auto
input
)
{
std
::
transform
(
input
.
begin
(),
std
::
transform
(
input
.
begin
(),
input
.
end
(),
input
.
end
(),
output
.
begin
(),
output
.
begin
(),
static_cast
<
const
Derived
&>
(
*
this
).
apply
());
static_cast
<
const
Derived
&>
(
*
this
).
apply
());
});
});
}
}
else
else
{
{
...
@@ -47,8 +52,6 @@ struct unary : op_name<Derived>
...
@@ -47,8 +52,6 @@ struct unary : op_name<Derived>
output
(
idx
.
begin
(),
idx
.
end
())
=
static_cast
<
const
Derived
&>
(
*
this
).
apply
()(
output
(
idx
.
begin
(),
idx
.
end
())
=
static_cast
<
const
Derived
&>
(
*
this
).
apply
()(
input
(
idx
.
begin
(),
idx
.
end
()));
input
(
idx
.
begin
(),
idx
.
end
()));
});
});
return
result
;
});
});
});
});
}
}
...
...
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