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
e3767fe4
Unverified
Commit
e3767fe4
authored
Jul 09, 2019
by
mvermeulen
Committed by
GitHub
Jul 09, 2019
Browse files
Merge branch 'develop' into reduce_mean
parents
e61be020
c8c6bf28
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
138 additions
and
3 deletions
+138
-3
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/propagate_constant.cpp
src/propagate_constant.cpp
+3
-3
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/erf_test.onnx
test/onnx/erf_test.onnx
+13
-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 @
e3767fe4
#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 @
e3767fe4
...
...
@@ -24,6 +24,7 @@
#include <migraphx/op/div.hpp>
#include <migraphx/op/dot.hpp>
#include <migraphx/op/elu.hpp>
#include <migraphx/op/erf.hpp>
#include <migraphx/op/exp.hpp>
#include <migraphx/op/flatten.hpp>
#include <migraphx/op/gather.hpp>
...
...
src/onnx/onnx.cpp
View file @
e3767fe4
...
...
@@ -40,6 +40,7 @@ struct onnx_parser
add_generic_op
(
"Sigmoid"
,
op
::
sigmoid
{});
add_generic_op
(
"Abs"
,
op
::
abs
{});
add_generic_op
(
"Exp"
,
op
::
exp
{});
add_generic_op
(
"Erf"
,
op
::
erf
{});
add_generic_op
(
"Log"
,
op
::
log
{});
// disable dropout for inference
add_generic_op
(
"Dropout"
,
op
::
identity
{});
...
...
src/propagate_constant.cpp
View file @
e3767fe4
...
...
@@ -10,8 +10,8 @@ inline namespace MIGRAPHX_INLINE_NS {
bool
skip_propogate
(
instruction_ref
ins
)
{
if
(
ins
->
name
()
==
"
@literal
"
)
return
true
;
if
(
ins
->
name
()
==
"
contiguous
"
)
return
skip_propogate
(
ins
->
inputs
().
front
())
;
auto
&&
s
=
ins
->
get_shape
();
if
(
s
.
broadcasted
()
and
not
s
.
scalar
())
return
true
;
...
...
@@ -33,7 +33,7 @@ void propagate_constant::apply(program& p) const
ins
->
outputs
().
end
());
for
(
auto
child
:
children
)
{
if
(
skip_propogate
(
child
))
if
(
child
->
name
()
==
"@literal"
or
skip_propogate
(
child
))
{
self
(
child
);
continue
;
...
...
src/targets/gpu/CMakeLists.txt
View file @
e3767fe4
...
...
@@ -17,6 +17,7 @@ add_library(migraphx_device
device/max.cpp
device/min.cpp
device/exp.cpp
device/erf.cpp
device/log.cpp
device/sin.cpp
device/cos.cpp
...
...
src/targets/gpu/device/erf.cpp
0 → 100644
View file @
e3767fe4
#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 @
e3767fe4
#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 @
e3767fe4
#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 @
e3767fe4
...
...
@@ -27,6 +27,7 @@
#include <migraphx/gpu/add.hpp>
#include <migraphx/gpu/sub.hpp>
#include <migraphx/gpu/exp.hpp>
#include <migraphx/gpu/erf.hpp>
#include <migraphx/gpu/log.hpp>
#include <migraphx/gpu/sin.hpp>
#include <migraphx/gpu/cos.hpp>
...
...
@@ -87,6 +88,7 @@ struct miopen_apply
add_generic_op
<
hip_add
>
(
"add"
);
add_generic_op
<
hip_sub
>
(
"sub"
);
add_generic_op
<
hip_exp
>
(
"exp"
);
add_generic_op
<
hip_erf
>
(
"erf"
);
add_generic_op
<
hip_log
>
(
"log"
);
add_generic_op
<
hip_sin
>
(
"sin"
);
add_generic_op
<
hip_cos
>
(
"cos"
);
...
...
test/cpu_ops_test.cpp
View file @
e3767fe4
...
...
@@ -527,6 +527,21 @@ TEST_CASE(exp_test)
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
)
{
migraphx
::
program
p
;
...
...
test/gpu/miopen.cpp
View file @
e3767fe4
...
...
@@ -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
>
{
migraphx
::
program
create_program
()
const
...
...
test/onnx/erf_test.onnx
0 → 100644
View file @
e3767fe4
erf-example:A
xy"Erftest_erfZ
x
b
y
B
test/onnx/onnx_test.cpp
View file @
e3767fe4
...
...
@@ -192,6 +192,16 @@ TEST_CASE(exp_test)
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
)
{
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