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
9bee6af8
Commit
9bee6af8
authored
Apr 03, 2019
by
Shucai Xiao
Browse files
add the gpu implementation of the fp_conversion operator
parent
efa8d9f4
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
100 additions
and
0 deletions
+100
-0
src/targets/gpu/CMakeLists.txt
src/targets/gpu/CMakeLists.txt
+2
-0
src/targets/gpu/device/fp_conversion.cpp
src/targets/gpu/device/fp_conversion.cpp
+27
-0
src/targets/gpu/fp_conversion.cpp
src/targets/gpu/fp_conversion.cpp
+24
-0
src/targets/gpu/include/migraphx/gpu/device/fp_conversion.hpp
...targets/gpu/include/migraphx/gpu/device/fp_conversion.hpp
+22
-0
src/targets/gpu/include/migraphx/gpu/fp_conversion.hpp
src/targets/gpu/include/migraphx/gpu/fp_conversion.hpp
+25
-0
No files found.
src/targets/gpu/CMakeLists.txt
View file @
9bee6af8
...
...
@@ -27,6 +27,7 @@ add_library(migraphx_device
device/add_relu.cpp
device/contiguous.cpp
device/logsoftmax.cpp
device/fp_conversion.cpp
device/mul.cpp
device/concat.cpp
device/pad.cpp
...
...
@@ -50,6 +51,7 @@ add_library(migraphx_gpu
convolution.cpp
softmax.cpp
logsoftmax.cpp
fp_conversion.cpp
contiguous.cpp
concat.cpp
relu.cpp
...
...
src/targets/gpu/device/fp_conversion.cpp
0 → 100644
View file @
9bee6af8
#include <migraphx/gpu/device/fp_conversion.hpp>
#include <migraphx/gpu/device/nary.hpp>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
gpu
{
namespace
device
{
argument
fp_conversion
(
hipStream_t
stream
,
const
shape
&
output_shape
,
const
std
::
vector
<
argument
>&
args
)
{
args
.
back
().
visit
([
&
](
auto
output
)
{
args
.
front
().
visit
([
&
](
auto
input
)
{
const
auto
*
input_ptr
=
device_cast
(
input
.
data
());
auto
*
output_ptr
=
device_cast
(
output
.
data
());
gs_launch
(
stream
,
output_shape
.
elements
())([
=
](
auto
i
)
{
output_ptr
[
i
]
=
input_ptr
[
i
];
});
});
});
return
args
.
back
();
}
}
// namespace device
}
// namespace gpu
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
src/targets/gpu/fp_conversion.cpp
0 → 100644
View file @
9bee6af8
#include <migraphx/gpu/fp_conversion.hpp>
#include <migraphx/gpu/context.hpp>
#include <migraphx/gpu/device/gather.hpp>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
gpu
{
shape
hip_fp_conversion
::
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
inputs
.
pop_back
();
return
op
.
compute_shape
(
inputs
);
}
argument
hip_fp_conversion
::
compute
(
context
&
ctx
,
const
shape
&
output_shape
,
const
std
::
vector
<
argument
>&
args
)
const
{
return
device
::
fp_conversion
(
ctx
.
get_stream
().
get
(),
output_shape
,
args
);
}
}
// namespace gpu
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
src/targets/gpu/include/migraphx/gpu/device/fp_conversion.hpp
0 → 100644
View file @
9bee6af8
#ifndef MIGRAPHX_GUARD_RTGLIB_DEVICE_FP_CONVERSION_HPP
#define MIGRAPHX_GUARD_RTGLIB_DEVICE_FP_CONVERSION_HPP
#include <migraphx/argument.hpp>
#include <migraphx/config.hpp>
#include <hip/hip_runtime_api.h>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
gpu
{
namespace
device
{
argument
fp_conversion
(
hipStream_t
stream
,
const
shape
&
output_shape
,
const
std
::
vector
<
argument
>&
args
);
}
// namespace device
}
// namespace gpu
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
#endif
src/targets/gpu/include/migraphx/gpu/fp_conversion.hpp
0 → 100644
View file @
9bee6af8
#ifndef MIGRAPHX_GUARD_RTGLIB_FP_CONVERSION_HPP
#define MIGRAPHX_GUARD_RTGLIB_FP_CONVERSION_HPP
#include <migraphx/gpu/oper.hpp>
#include <migraphx/gpu/device/fp_conversion.hpp>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
gpu
{
struct
hip_fp_conversion
{
op
::
fp_conversion
op
;
std
::
string
name
()
const
{
return
"gpu::fp_conversion"
;
}
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
;
argument
compute
(
context
&
ctx
,
const
shape
&
output_shape
,
const
std
::
vector
<
argument
>&
args
)
const
;
int
output_alias
(
const
std
::
vector
<
shape
>&
shapes
)
const
{
return
shapes
.
size
()
-
1
;
}
};
}
// namespace gpu
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
#endif
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