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
443fc80c
Commit
443fc80c
authored
Jul 09, 2019
by
Shucai Xiao
Browse files
merge sqrt operator to test_bert branch
parents
85b35f92
6ae9fcbd
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
95 additions
and
1 deletion
+95
-1
src/include/migraphx/generate.hpp
src/include/migraphx/generate.hpp
+10
-1
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/generate.hpp
View file @
443fc80c
...
...
@@ -81,7 +81,16 @@ template <class T>
std
::
vector
<
T
>
generate_tensor_data
(
const
migraphx
::
shape
&
s
,
unsigned
long
seed
=
0
)
{
std
::
vector
<
T
>
result
(
s
.
elements
());
shape
::
type_t
type
=
s
.
type
();
if
(
type
==
shape
::
int64_type
or
type
==
shape
::
int32_type
)
{
std
::
generate
(
result
.
begin
(),
result
.
end
(),
[]{
return
1
;
});
}
else
{
std
::
generate
(
result
.
begin
(),
result
.
end
(),
xorshf96_generator
<
T
>
{
seed
});
}
// std::generate(result.begin(), result.end(), [&]{ return seed % 7; });
// std::generate(result.begin(), result.end(), []{ return 1; });
return
result
;
...
...
src/include/migraphx/op/sqrt.hpp
0 → 100644
View file @
443fc80c
#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 @
443fc80c
...
...
@@ -59,6 +59,7 @@
#include <migraphx/op/sin.hpp>
#include <migraphx/op/slice.hpp>
#include <migraphx/op/softmax.hpp>
#include <migraphx/op/sqrt.hpp>
#include <migraphx/op/squeeze.hpp>
#include <migraphx/op/sub.hpp>
#include <migraphx/op/tanh.hpp>
...
...
src/onnx/onnx.cpp
View file @
443fc80c
...
...
@@ -54,6 +54,7 @@ struct onnx_parser
add_generic_op
(
"Asin"
,
op
::
asin
{});
add_generic_op
(
"Acos"
,
op
::
acos
{});
add_generic_op
(
"Atan"
,
op
::
atan
{});
add_generic_op
(
"Sqrt"
,
op
::
sqrt
{});
add_binary_op
(
"Add"
,
op
::
add
{});
add_binary_op
(
"Div"
,
op
::
div
{});
...
...
src/targets/gpu/CMakeLists.txt
View file @
443fc80c
...
...
@@ -41,6 +41,7 @@ add_library(migraphx_device
device/reduce_sum.cpp
device/pow.cpp
device/reduce_mean.cpp
device/sqrt.cpp
)
set_target_properties
(
migraphx_device PROPERTIES EXPORT_NAME device
)
rocm_clang_tidy_check
(
migraphx_device
)
...
...
src/targets/gpu/device/sqrt.cpp
0 → 100644
View file @
443fc80c
#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 @
443fc80c
#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 @
443fc80c
#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 @
443fc80c
...
...
@@ -53,6 +53,7 @@
#include <migraphx/gpu/reduce_sum.hpp>
#include <migraphx/gpu/pow.hpp>
#include <migraphx/gpu/reduce_mean.hpp>
#include <migraphx/gpu/sqrt.hpp>
#include <utility>
#include <functional>
#include <algorithm>
...
...
@@ -99,6 +100,7 @@ struct miopen_apply
add_generic_op
<
hip_asin
>
(
"asin"
);
add_generic_op
<
hip_acos
>
(
"acos"
);
add_generic_op
<
hip_atan
>
(
"atan"
);
add_generic_op
<
hip_sqrt
>
(
"sqrt"
);
add_generic_op
<
hip_mul
>
(
"mul"
);
add_generic_op
<
hip_max
>
(
"max"
);
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