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
6ae9fcbd
Commit
6ae9fcbd
authored
Jul 09, 2019
by
Shucai Xiao
Browse files
add the sqrt operator to suppor the bert model
parent
ebfe9735
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
85 additions
and
0 deletions
+85
-0
src/include/migraphx/op/sqrt.hpp
src/include/migraphx/op/sqrt.hpp
+23
-0
src/include/migraphx/operators.hpp
src/include/migraphx/operators.hpp
+1
-0
src/onnx/onnx.cpp
src/onnx/onnx.cpp
+1
-0
src/targets/gpu/CMakeLists.txt
src/targets/gpu/CMakeLists.txt
+1
-0
src/targets/gpu/device/sqrt.cpp
src/targets/gpu/device/sqrt.cpp
+18
-0
src/targets/gpu/include/migraphx/gpu/device/sqrt.hpp
src/targets/gpu/include/migraphx/gpu/device/sqrt.hpp
+20
-0
src/targets/gpu/include/migraphx/gpu/sqrt.hpp
src/targets/gpu/include/migraphx/gpu/sqrt.hpp
+19
-0
src/targets/gpu/lowering.cpp
src/targets/gpu/lowering.cpp
+2
-0
No files found.
src/include/migraphx/op/sqrt.hpp
0 → 100644
View file @
6ae9fcbd
#ifndef MIGRAPHX_GUARD_OPERATORS_SQRT_HPP
#define MIGRAPHX_GUARD_OPERATORS_SQRT_HPP
#include <migraphx/op/unary.hpp>
#include <migraphx/config.hpp>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
struct
sqrt
:
unary
<
sqrt
>
{
auto
apply
()
const
{
return
[](
auto
x
)
{
return
std
::
sqrt
(
x
);
};
}
};
}
// namespace op
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
#endif
src/include/migraphx/operators.hpp
View file @
6ae9fcbd
...
@@ -57,6 +57,7 @@
...
@@ -57,6 +57,7 @@
#include <migraphx/op/sin.hpp>
#include <migraphx/op/sin.hpp>
#include <migraphx/op/slice.hpp>
#include <migraphx/op/slice.hpp>
#include <migraphx/op/softmax.hpp>
#include <migraphx/op/softmax.hpp>
#include <migraphx/op/sqrt.hpp>
#include <migraphx/op/squeeze.hpp>
#include <migraphx/op/squeeze.hpp>
#include <migraphx/op/sub.hpp>
#include <migraphx/op/sub.hpp>
#include <migraphx/op/tanh.hpp>
#include <migraphx/op/tanh.hpp>
...
...
src/onnx/onnx.cpp
View file @
6ae9fcbd
...
@@ -54,6 +54,7 @@ struct onnx_parser
...
@@ -54,6 +54,7 @@ struct onnx_parser
add_generic_op
(
"Asin"
,
op
::
asin
{});
add_generic_op
(
"Asin"
,
op
::
asin
{});
add_generic_op
(
"Acos"
,
op
::
acos
{});
add_generic_op
(
"Acos"
,
op
::
acos
{});
add_generic_op
(
"Atan"
,
op
::
atan
{});
add_generic_op
(
"Atan"
,
op
::
atan
{});
add_generic_op
(
"Sqrt"
,
op
::
sqrt
{});
add_binary_op
(
"Add"
,
op
::
add
{});
add_binary_op
(
"Add"
,
op
::
add
{});
add_binary_op
(
"Div"
,
op
::
div
{});
add_binary_op
(
"Div"
,
op
::
div
{});
...
...
src/targets/gpu/CMakeLists.txt
View file @
6ae9fcbd
...
@@ -39,6 +39,7 @@ add_library(migraphx_device
...
@@ -39,6 +39,7 @@ add_library(migraphx_device
device/sub.cpp
device/sub.cpp
device/clip.cpp
device/clip.cpp
device/reduce_sum.cpp
device/reduce_sum.cpp
device/sqrt.cpp
)
)
set_target_properties
(
migraphx_device PROPERTIES EXPORT_NAME device
)
set_target_properties
(
migraphx_device PROPERTIES EXPORT_NAME device
)
rocm_clang_tidy_check
(
migraphx_device
)
rocm_clang_tidy_check
(
migraphx_device
)
...
...
src/targets/gpu/device/sqrt.cpp
0 → 100644
View file @
6ae9fcbd
#include <migraphx/gpu/device/sqrt.hpp>
#include <migraphx/gpu/device/nary.hpp>
#include <migraphx/gpu/device/types.hpp>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
gpu
{
namespace
device
{
void
sqrt
(
hipStream_t
stream
,
const
argument
&
result
,
const
argument
&
arg
)
{
nary
(
stream
,
result
,
arg
)([](
auto
x
)
{
return
::
sqrt
(
to_hip_type
(
x
));
});
}
}
// namespace device
}
// namespace gpu
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
src/targets/gpu/include/migraphx/gpu/device/sqrt.hpp
0 → 100644
View file @
6ae9fcbd
#ifndef MIGRAPHX_GUARD_RTGLIB_DEVICE_SQRT_HPP
#define MIGRAPHX_GUARD_RTGLIB_DEVICE_SQRT_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
{
void
sqrt
(
hipStream_t
stream
,
const
argument
&
result
,
const
argument
&
arg
);
}
// namespace device
}
// namespace gpu
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
#endif
src/targets/gpu/include/migraphx/gpu/sqrt.hpp
0 → 100644
View file @
6ae9fcbd
#ifndef MIGRAPHX_GUARD_RTGLIB_SQRT_HPP
#define MIGRAPHX_GUARD_RTGLIB_SQRT_HPP
#include <migraphx/gpu/oper.hpp>
#include <migraphx/gpu/device/sqrt.hpp>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
gpu
{
struct
hip_sqrt
:
unary_device
<
hip_sqrt
,
device
::
sqrt
>
{
};
}
// namespace gpu
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
#endif
src/targets/gpu/lowering.cpp
View file @
6ae9fcbd
...
@@ -51,6 +51,7 @@
...
@@ -51,6 +51,7 @@
#include <migraphx/gpu/convert.hpp>
#include <migraphx/gpu/convert.hpp>
#include <migraphx/gpu/clip.hpp>
#include <migraphx/gpu/clip.hpp>
#include <migraphx/gpu/reduce_sum.hpp>
#include <migraphx/gpu/reduce_sum.hpp>
#include <migraphx/gpu/sqrt.hpp>
#include <utility>
#include <utility>
#include <functional>
#include <functional>
#include <algorithm>
#include <algorithm>
...
@@ -97,6 +98,7 @@ struct miopen_apply
...
@@ -97,6 +98,7 @@ struct miopen_apply
add_generic_op
<
hip_asin
>
(
"asin"
);
add_generic_op
<
hip_asin
>
(
"asin"
);
add_generic_op
<
hip_acos
>
(
"acos"
);
add_generic_op
<
hip_acos
>
(
"acos"
);
add_generic_op
<
hip_atan
>
(
"atan"
);
add_generic_op
<
hip_atan
>
(
"atan"
);
add_generic_op
<
hip_sqrt
>
(
"sqrt"
);
add_generic_op
<
hip_mul
>
(
"mul"
);
add_generic_op
<
hip_mul
>
(
"mul"
);
add_generic_op
<
hip_max
>
(
"max"
);
add_generic_op
<
hip_max
>
(
"max"
);
add_generic_op
<
hip_min
>
(
"min"
);
add_generic_op
<
hip_min
>
(
"min"
);
...
...
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