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
6f96cf7e
Commit
6f96cf7e
authored
Aug 23, 2018
by
Paul
Browse files
Formatting
parent
cff1144d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
27 deletions
+21
-27
src/targets/gpu/device/add_relu.cpp
src/targets/gpu/device/add_relu.cpp
+1
-3
src/targets/gpu/device/include/migraph/gpu/device/binary.hpp
src/targets/gpu/device/include/migraph/gpu/device/binary.hpp
+11
-13
src/targets/gpu/device/include/migraph/gpu/device/unary.hpp
src/targets/gpu/device/include/migraph/gpu/device/unary.hpp
+9
-11
No files found.
src/targets/gpu/device/add_relu.cpp
View file @
6f96cf7e
...
@@ -7,9 +7,7 @@ namespace device {
...
@@ -7,9 +7,7 @@ namespace device {
void
add_relu
(
argument
arg1
,
argument
arg2
,
argument
result
)
void
add_relu
(
argument
arg1
,
argument
arg2
,
argument
result
)
{
{
binary_standard
(
arg1
,
arg2
,
result
,
[](
auto
x
,
auto
y
)
{
binary_standard
(
arg1
,
arg2
,
result
,
[](
auto
x
,
auto
y
)
{
return
max
(
0
,
x
+
y
);
});
return
max
(
0
,
x
+
y
);
});
}
}
}
// namespace device
}
// namespace device
...
...
src/targets/gpu/device/include/migraph/gpu/device/binary.hpp
View file @
6f96cf7e
...
@@ -8,7 +8,7 @@ namespace migraph {
...
@@ -8,7 +8,7 @@ namespace migraph {
namespace
gpu
{
namespace
gpu
{
namespace
device
{
namespace
device
{
template
<
class
F
>
template
<
class
F
>
void
binary
(
argument
x
,
argument
y
,
argument
result
,
F
f
)
void
binary
(
argument
x
,
argument
y
,
argument
result
,
F
f
)
{
{
if
(
x
.
get_shape
().
standard
())
if
(
x
.
get_shape
().
standard
())
...
@@ -17,42 +17,40 @@ void binary(argument x, argument y, argument result, F f)
...
@@ -17,42 +17,40 @@ void binary(argument x, argument y, argument result, F f)
binary_nonstandard
(
x
,
y
,
result
,
f
);
binary_nonstandard
(
x
,
y
,
result
,
f
);
}
}
template
<
class
F
>
template
<
class
F
>
void
binary_nonstandard
(
argument
x
,
argument
y
,
argument
result
,
F
f
)
void
binary_nonstandard
(
argument
x
,
argument
y
,
argument
result
,
F
f
)
{
{
auto
output_shape
=
result
.
get_shape
();
auto
output_shape
=
result
.
get_shape
();
auto
input_shape
=
x
.
get_shape
();
auto
input_shape
=
x
.
get_shape
();
visit_all
(
result
,
x
,
y
)([
&
](
auto
output
,
auto
input1
,
auto
input2
)
{
visit_all
(
result
,
x
,
y
)([
&
](
auto
output
,
auto
input1
,
auto
input2
)
{
visit_tensor_size
(
output_shape
.
lens
().
size
(),
[
&
](
auto
ndim
)
{
visit_tensor_size
(
output_shape
.
lens
().
size
(),
[
&
](
auto
ndim
)
{
hip_tensor_descriptor
<
ndim
>
x_desc
(
x
.
get_shape
().
lens
(),
x
.
get_shape
().
strides
());
hip_tensor_descriptor
<
ndim
>
x_desc
(
x
.
get_shape
().
lens
(),
x
.
get_shape
().
strides
());
hip_tensor_descriptor
<
ndim
>
y_desc
(
y
.
get_shape
().
lens
(),
y
.
get_shape
().
strides
());
hip_tensor_descriptor
<
ndim
>
y_desc
(
y
.
get_shape
().
lens
(),
y
.
get_shape
().
strides
());
hip_tensor_descriptor
<
ndim
>
out_desc
(
output_shape
.
lens
(),
output_shape
.
strides
());
hip_tensor_descriptor
<
ndim
>
out_desc
(
output_shape
.
lens
(),
output_shape
.
strides
());
auto
*
xp
=
input1
.
data
();
auto
*
xp
=
input1
.
data
();
auto
*
yp
=
input2
.
data
();
auto
*
yp
=
input2
.
data
();
auto
*
outp
=
output
.
data
();
auto
*
outp
=
output
.
data
();
gs_launch
(
input_shape
.
elements
())([
=
](
auto
i
)
{
gs_launch
(
input_shape
.
elements
())([
=
](
auto
i
)
{
auto
outidx
=
out_desc
.
multi
(
i
);
auto
outidx
=
out_desc
.
multi
(
i
);
size_t
xidx
=
x_desc
.
linear
(
outidx
);
size_t
xidx
=
x_desc
.
linear
(
outidx
);
size_t
yidx
=
y_desc
.
linear
(
outidx
);
size_t
yidx
=
y_desc
.
linear
(
outidx
);
outp
[
i
]
=
f
(
xp
[
xidx
],
yp
[
yidx
]);
outp
[
i
]
=
f
(
xp
[
xidx
],
yp
[
yidx
]);
});
});
});
});
});
});
}
}
template
<
class
F
>
template
<
class
F
>
void
binary_standard
(
argument
x
,
argument
y
,
argument
result
,
F
f
)
void
binary_standard
(
argument
x
,
argument
y
,
argument
result
,
F
f
)
{
{
assert
(
x
.
get_shape
().
elements
()
==
y
.
get_shape
().
elements
());
assert
(
x
.
get_shape
().
elements
()
==
y
.
get_shape
().
elements
());
auto
output_shape
=
result
.
get_shape
();
auto
output_shape
=
result
.
get_shape
();
auto
input_shape
=
x
.
get_shape
();
auto
input_shape
=
x
.
get_shape
();
visit_all
(
result
,
x
,
y
)([
&
](
auto
output
,
auto
input1
,
auto
input2
)
{
visit_all
(
result
,
x
,
y
)([
&
](
auto
output
,
auto
input1
,
auto
input2
)
{
auto
*
xp
=
input1
.
data
();
auto
*
xp
=
input1
.
data
();
auto
*
yp
=
input2
.
data
();
auto
*
yp
=
input2
.
data
();
auto
*
outp
=
output
.
data
();
auto
*
outp
=
output
.
data
();
gs_launch
(
input_shape
.
elements
())([
=
](
auto
i
)
{
gs_launch
(
input_shape
.
elements
())([
=
](
auto
i
)
{
outp
[
i
]
=
f
(
xp
[
i
],
yp
[
i
]);
});
outp
[
i
]
=
f
(
xp
[
i
],
yp
[
i
]);
});
});
});
}
}
...
...
src/targets/gpu/device/include/migraph/gpu/device/unary.hpp
View file @
6f96cf7e
...
@@ -9,7 +9,7 @@ namespace migraph {
...
@@ -9,7 +9,7 @@ namespace migraph {
namespace
gpu
{
namespace
gpu
{
namespace
device
{
namespace
device
{
template
<
class
F
>
template
<
class
F
>
void
unary
(
argument
x
,
argument
result
,
F
f
)
void
unary
(
argument
x
,
argument
result
,
F
f
)
{
{
if
(
x
.
get_shape
().
standard
())
if
(
x
.
get_shape
().
standard
())
...
@@ -18,36 +18,34 @@ void unary(argument x, argument result, F f)
...
@@ -18,36 +18,34 @@ void unary(argument x, argument result, F f)
unary_nonstandard
(
x
,
result
,
f
);
unary_nonstandard
(
x
,
result
,
f
);
}
}
template
<
class
F
>
template
<
class
F
>
void
unary_nonstandard
(
argument
x
,
argument
result
,
F
f
)
void
unary_nonstandard
(
argument
x
,
argument
result
,
F
f
)
{
{
auto
output_shape
=
result
.
get_shape
();
auto
output_shape
=
result
.
get_shape
();
auto
input_shape
=
x
.
get_shape
();
auto
input_shape
=
x
.
get_shape
();
visit_all
(
result
,
x
)([
&
](
auto
output
,
auto
input
)
{
visit_all
(
result
,
x
)([
&
](
auto
output
,
auto
input
)
{
visit_tensor_size
(
output_shape
.
lens
().
size
(),
[
&
](
auto
ndim
)
{
visit_tensor_size
(
output_shape
.
lens
().
size
(),
[
&
](
auto
ndim
)
{
hip_tensor_descriptor
<
ndim
>
x_desc
(
input_shape
.
lens
(),
input_shape
.
strides
());
hip_tensor_descriptor
<
ndim
>
x_desc
(
input_shape
.
lens
(),
input_shape
.
strides
());
hip_tensor_descriptor
<
ndim
>
out_desc
(
output_shape
.
lens
(),
output_shape
.
strides
());
hip_tensor_descriptor
<
ndim
>
out_desc
(
output_shape
.
lens
(),
output_shape
.
strides
());
auto
*
xp
=
input
.
data
();
auto
*
xp
=
input
.
data
();
auto
*
outp
=
output
.
data
();
auto
*
outp
=
output
.
data
();
gs_launch
(
input_shape
.
elements
())([
=
](
auto
i
)
{
gs_launch
(
input_shape
.
elements
())([
=
](
auto
i
)
{
size_t
xidx
=
x_desc
.
linear
(
out_desc
.
multi
(
i
));
size_t
xidx
=
x_desc
.
linear
(
out_desc
.
multi
(
i
));
outp
[
i
]
=
f
(
xp
[
xidx
]);
outp
[
i
]
=
f
(
xp
[
xidx
]);
});
});
});
});
});
});
}
}
template
<
class
F
>
template
<
class
F
>
void
unary_standard
(
argument
x
,
argument
result
,
F
f
)
void
unary_standard
(
argument
x
,
argument
result
,
F
f
)
{
{
auto
output_shape
=
result
.
get_shape
();
auto
output_shape
=
result
.
get_shape
();
auto
input_shape
=
x
.
get_shape
();
auto
input_shape
=
x
.
get_shape
();
visit_all
(
result
,
x
)([
&
](
auto
output
,
auto
input
)
{
visit_all
(
result
,
x
)([
&
](
auto
output
,
auto
input
)
{
auto
*
xp
=
input
.
data
();
auto
*
xp
=
input
.
data
();
auto
*
outp
=
output
.
data
();
auto
*
outp
=
output
.
data
();
gs_launch
(
input_shape
.
elements
())([
=
](
auto
i
)
{
gs_launch
(
input_shape
.
elements
())([
=
](
auto
i
)
{
outp
[
i
]
=
f
(
xp
[
i
]);
});
outp
[
i
]
=
f
(
xp
[
i
]);
});
});
});
}
}
...
...
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