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
720eab5c
"src/git@developer.sourcefind.cn:gaoqiong/migraphx.git" did not exist on "8fb6eedbdef6d624e9df12c426e90dcfb2e97ee5"
Commit
720eab5c
authored
Jul 07, 2019
by
Shucai Xiao
Browse files
Merge branch 'erf_operator' into test_bert
parents
b7c6b8ca
27e1dbb1
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
122 additions
and
0 deletions
+122
-0
src/include/migraphx/op/erf.hpp
src/include/migraphx/op/erf.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/erf.cpp
src/targets/gpu/device/erf.cpp
+18
-0
src/targets/gpu/include/migraphx/gpu/device/erf.hpp
src/targets/gpu/include/migraphx/gpu/device/erf.hpp
+20
-0
src/targets/gpu/include/migraphx/gpu/erf.hpp
src/targets/gpu/include/migraphx/gpu/erf.hpp
+19
-0
src/targets/gpu/lowering.cpp
src/targets/gpu/lowering.cpp
+2
-0
test/cpu_ops_test.cpp
test/cpu_ops_test.cpp
+15
-0
test/gpu/miopen.cpp
test/gpu/miopen.cpp
+12
-0
test/onnx/onnx_test.cpp
test/onnx/onnx_test.cpp
+10
-0
No files found.
src/include/migraphx/op/erf.hpp
0 → 100644
View file @
720eab5c
#ifndef MIGRAPHX_GUARD_OPERATORS_ERF_HPP
#define MIGRAPHX_GUARD_OPERATORS_ERF_HPP
#include <migraphx/op/unary.hpp>
#include <migraphx/config.hpp>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
struct
erf
:
unary
<
erf
>
{
auto
apply
()
const
{
return
[](
auto
x
)
{
return
std
::
erf
(
x
);
};
}
};
}
// namespace op
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
#endif
src/include/migraphx/operators.hpp
View file @
720eab5c
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
#include <migraphx/op/div.hpp>
#include <migraphx/op/div.hpp>
#include <migraphx/op/dot.hpp>
#include <migraphx/op/dot.hpp>
#include <migraphx/op/elu.hpp>
#include <migraphx/op/elu.hpp>
#include <migraphx/op/erf.hpp>
#include <migraphx/op/exp.hpp>
#include <migraphx/op/exp.hpp>
#include <migraphx/op/flatten.hpp>
#include <migraphx/op/flatten.hpp>
#include <migraphx/op/gather.hpp>
#include <migraphx/op/gather.hpp>
...
...
src/onnx/onnx.cpp
View file @
720eab5c
...
@@ -40,6 +40,7 @@ struct onnx_parser
...
@@ -40,6 +40,7 @@ struct onnx_parser
add_generic_op
(
"Sigmoid"
,
op
::
sigmoid
{});
add_generic_op
(
"Sigmoid"
,
op
::
sigmoid
{});
add_generic_op
(
"Abs"
,
op
::
abs
{});
add_generic_op
(
"Abs"
,
op
::
abs
{});
add_generic_op
(
"Exp"
,
op
::
exp
{});
add_generic_op
(
"Exp"
,
op
::
exp
{});
add_generic_op
(
"Erf"
,
op
::
erf
{});
add_generic_op
(
"Log"
,
op
::
log
{});
add_generic_op
(
"Log"
,
op
::
log
{});
// disable dropout for inference
// disable dropout for inference
add_generic_op
(
"Dropout"
,
op
::
identity
{});
add_generic_op
(
"Dropout"
,
op
::
identity
{});
...
...
src/targets/gpu/CMakeLists.txt
View file @
720eab5c
...
@@ -17,6 +17,7 @@ add_library(migraphx_device
...
@@ -17,6 +17,7 @@ add_library(migraphx_device
device/max.cpp
device/max.cpp
device/min.cpp
device/min.cpp
device/exp.cpp
device/exp.cpp
device/erf.cpp
device/log.cpp
device/log.cpp
device/sin.cpp
device/sin.cpp
device/cos.cpp
device/cos.cpp
...
...
src/targets/gpu/device/erf.cpp
0 → 100644
View file @
720eab5c
#include <migraphx/gpu/device/erf.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
erf
(
hipStream_t
stream
,
const
argument
&
result
,
const
argument
&
arg
)
{
nary
(
stream
,
result
,
arg
)([](
auto
x
)
{
return
::
erf
(
to_hip_type
(
x
));
});
}
}
// namespace device
}
// namespace gpu
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
src/targets/gpu/include/migraphx/gpu/device/erf.hpp
0 → 100644
View file @
720eab5c
#ifndef MIGRAPHX_GUARD_RTGLIB_DEVICE_ERF_HPP
#define MIGRAPHX_GUARD_RTGLIB_DEVICE_ERF_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
erf
(
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/erf.hpp
0 → 100644
View file @
720eab5c
#ifndef MIGRAPHX_GUARD_RTGLIB_ERF_HPP
#define MIGRAPHX_GUARD_RTGLIB_ERF_HPP
#include <migraphx/gpu/oper.hpp>
#include <migraphx/gpu/device/erf.hpp>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
gpu
{
struct
hip_erf
:
unary_device
<
hip_erf
,
device
::
erf
>
{
};
}
// namespace gpu
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
#endif
src/targets/gpu/lowering.cpp
View file @
720eab5c
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
#include <migraphx/gpu/add.hpp>
#include <migraphx/gpu/add.hpp>
#include <migraphx/gpu/sub.hpp>
#include <migraphx/gpu/sub.hpp>
#include <migraphx/gpu/exp.hpp>
#include <migraphx/gpu/exp.hpp>
#include <migraphx/gpu/erf.hpp>
#include <migraphx/gpu/log.hpp>
#include <migraphx/gpu/log.hpp>
#include <migraphx/gpu/sin.hpp>
#include <migraphx/gpu/sin.hpp>
#include <migraphx/gpu/cos.hpp>
#include <migraphx/gpu/cos.hpp>
...
@@ -88,6 +89,7 @@ struct miopen_apply
...
@@ -88,6 +89,7 @@ struct miopen_apply
add_generic_op
<
hip_add
>
(
"add"
);
add_generic_op
<
hip_add
>
(
"add"
);
add_generic_op
<
hip_sub
>
(
"sub"
);
add_generic_op
<
hip_sub
>
(
"sub"
);
add_generic_op
<
hip_exp
>
(
"exp"
);
add_generic_op
<
hip_exp
>
(
"exp"
);
add_generic_op
<
hip_erf
>
(
"erf"
);
add_generic_op
<
hip_log
>
(
"log"
);
add_generic_op
<
hip_log
>
(
"log"
);
add_generic_op
<
hip_sin
>
(
"sin"
);
add_generic_op
<
hip_sin
>
(
"sin"
);
add_generic_op
<
hip_cos
>
(
"cos"
);
add_generic_op
<
hip_cos
>
(
"cos"
);
...
...
test/cpu_ops_test.cpp
View file @
720eab5c
...
@@ -527,6 +527,21 @@ TEST_CASE(exp_test)
...
@@ -527,6 +527,21 @@ TEST_CASE(exp_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
}
TEST_CASE
(
erf_test
)
{
migraphx
::
program
p
;
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
4
}};
auto
l
=
p
.
add_literal
(
migraphx
::
literal
{
s
,
{
0.73785057
,
1.58165966
,
-
0.43597795
,
-
0.01677432
}});
p
.
add_instruction
(
migraphx
::
op
::
erf
{},
l
);
p
.
compile
(
migraphx
::
cpu
::
target
{});
auto
result
=
p
.
eval
({});
std
::
vector
<
float
>
results_vector
;
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
=
{
0.70327317
,
0.97470088
,
-
0.46247893
,
-
0.01892602
};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
log_test
)
TEST_CASE
(
log_test
)
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
...
...
test/gpu/miopen.cpp
View file @
720eab5c
...
@@ -243,6 +243,18 @@ struct test_exp : verify_program<test_exp>
...
@@ -243,6 +243,18 @@ struct test_exp : verify_program<test_exp>
}
}
};
};
struct
test_erf
:
verify_program
<
test_erf
>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
6
}};
auto
param
=
p
.
add_parameter
(
"x"
,
s
);
p
.
add_instruction
(
migraphx
::
op
::
erf
{},
param
);
return
p
;
}
};
struct
test_log
:
verify_program
<
test_log
>
struct
test_log
:
verify_program
<
test_log
>
{
{
migraphx
::
program
create_program
()
const
migraphx
::
program
create_program
()
const
...
...
test/onnx/onnx_test.cpp
View file @
720eab5c
...
@@ -192,6 +192,16 @@ TEST_CASE(exp_test)
...
@@ -192,6 +192,16 @@ TEST_CASE(exp_test)
EXPECT
(
p
==
prog
);
EXPECT
(
p
==
prog
);
}
}
TEST_CASE
(
erf_test
)
{
migraphx
::
program
p
;
auto
input
=
p
.
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
10
,
15
}});
p
.
add_instruction
(
migraphx
::
op
::
erf
{},
input
);
auto
prog
=
migraphx
::
parse_onnx
(
"erf_test.onnx"
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
log_test
)
TEST_CASE
(
log_test
)
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
...
...
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