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
947ede80
Commit
947ede80
authored
Aug 24, 2018
by
Paul
Browse files
Fix tidy errors
parent
c7888300
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
23 deletions
+30
-23
src/program.cpp
src/program.cpp
+3
-3
src/targets/gpu/device/add_relu.cpp
src/targets/gpu/device/add_relu.cpp
+1
-1
src/targets/gpu/device/contiguous.cpp
src/targets/gpu/device/contiguous.cpp
+1
-1
src/targets/gpu/device/include/migraph/gpu/device/nary.hpp
src/targets/gpu/device/include/migraph/gpu/device/nary.hpp
+25
-18
No files found.
src/program.cpp
View file @
947ede80
...
...
@@ -91,9 +91,9 @@ instruction_ref program::insert_instruction(instruction_ref ins,
assert
(
not
starts_with
(
op
.
name
(),
"@"
));
// TODO: Use move
shape
r
=
compute_shape
(
op
,
args
);
auto
result
=
impl
->
instructions
.
insert
(
ins
,
{
op
,
r
,
args
});
auto
result
=
impl
->
instructions
.
insert
(
ins
,
{
op
,
r
,
std
::
move
(
args
)
});
backreference
(
result
);
assert
(
result
->
arguments
==
args
);
//
assert(result->arguments == args);
assert
(
result
->
valid
(
begin
()));
return
result
;
}
...
...
@@ -108,7 +108,7 @@ instruction_ref program::replace_instruction(instruction_ref ins,
assert
(
not
starts_with
(
op
.
name
(),
"@"
));
shape
r
=
compute_shape
(
op
,
args
);
ins
->
replace
(
op
,
r
,
args
);
ins
->
replace
(
op
,
r
,
std
::
move
(
args
)
)
;
backreference
(
ins
);
assert
(
ins
->
valid
(
begin
()));
return
ins
;
...
...
src/targets/gpu/device/add_relu.cpp
View file @
947ede80
...
...
@@ -7,7 +7,7 @@ namespace device {
void
add_relu
(
argument
result
,
argument
arg1
,
argument
arg2
)
{
nary_standard
(
result
,
arg1
,
arg2
)([](
auto
x
,
auto
y
)
{
return
max
(
0
,
x
+
y
);
});
nary_standard
(
std
::
move
(
result
)
,
std
::
move
(
arg1
)
,
std
::
move
(
arg2
)
)
([](
auto
x
,
auto
y
)
{
return
max
(
0
,
x
+
y
);
});
}
}
// namespace device
...
...
src/targets/gpu/device/contiguous.cpp
View file @
947ede80
...
...
@@ -8,7 +8,7 @@ namespace device {
void
contiguous
(
argument
result
,
argument
arg
)
{
nary_nonstandard
(
result
,
arg
)([](
auto
x
)
{
return
x
;
});
nary_nonstandard
(
std
::
move
(
result
)
,
std
::
move
(
arg
)
)
([](
auto
x
)
{
return
x
;
});
}
}
// namespace device
...
...
src/targets/gpu/device/include/migraph/gpu/device/nary.hpp
View file @
947ede80
...
...
@@ -22,27 +22,34 @@ auto nary(argument result, Arguments... args)
};
}
template
<
class
...
Arguments
>
auto
nary_nonstandard
(
argument
result
,
Arguments
...
args
)
template
<
class
F
,
class
...
Arguments
>
auto
nary_nonstandard
_impl
(
F
f
,
argument
result
,
Arguments
...
args
)
{
return
[
=
](
auto
f
)
{
auto
output_shape
=
result
.
get_shape
();
visit_all
(
result
,
args
...)([
&
](
auto
output
,
auto
...
inputs
)
{
visit_tensor_size
(
output_shape
.
lens
().
size
(),
[
&
](
auto
ndim
)
{
auto
data
=
make_sequence
(
std
::
make_pair
(
hip_tensor_descriptor
<
ndim
>
{
inputs
.
get_shape
().
lens
(),
inputs
.
get_shape
().
strides
()},
inputs
.
data
())...);
hip_tensor_descriptor
<
ndim
>
out_desc
(
output_shape
.
lens
(),
output_shape
.
strides
());
auto
*
outp
=
output
.
data
();
gs_launch
(
output_shape
.
elements
())([
=
](
auto
i
)
{
data
([
&
](
auto
...
ps
)
{
auto
outidx
=
out_desc
.
multi
(
i
);
outp
[
i
]
=
f
(
ps
.
second
[
ps
.
first
.
linear
(
outidx
)]...);
});
const
auto
&
output_shape
=
result
.
get_shape
();
visit_all
(
result
,
args
...)([
&
](
auto
output
,
auto
...
inputs
)
{
visit_tensor_size
(
output_shape
.
lens
().
size
(),
[
&
](
auto
ndim
)
{
auto
data
=
make_sequence
(
std
::
make_pair
(
hip_tensor_descriptor
<
ndim
>
{
inputs
.
get_shape
().
lens
(),
inputs
.
get_shape
().
strides
()},
inputs
.
data
())...);
hip_tensor_descriptor
<
ndim
>
out_desc
(
output_shape
.
lens
(),
output_shape
.
strides
());
auto
*
outp
=
output
.
data
();
gs_launch
(
output_shape
.
elements
())([
=
](
auto
i
)
{
data
([
&
](
auto
...
ps
)
{
auto
outidx
=
out_desc
.
multi
(
i
);
outp
[
i
]
=
f
(
ps
.
second
[
ps
.
first
.
linear
(
outidx
)]...);
});
});
});
});
}
template
<
class
...
Arguments
>
auto
nary_nonstandard
(
argument
result
,
Arguments
...
args
)
{
return
[
=
](
auto
f
)
{
return
nary_nonstandard_impl
(
f
,
result
,
args
...);
};
}
...
...
@@ -51,7 +58,7 @@ auto nary_standard(argument result, Arguments... args)
{
return
[
=
](
auto
f
)
{
// assert(x.get_shape().elements() == y.get_shape().elements());
auto
output_shape
=
result
.
get_shape
();
const
auto
&
output_shape
=
result
.
get_shape
();
visit_all
(
result
,
args
...)([
&
](
auto
output
,
auto
...
inputs
)
{
auto
data
=
make_sequence
(
inputs
.
data
()...);
auto
*
outp
=
output
.
data
();
...
...
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