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
96f81a26
Commit
96f81a26
authored
Feb 05, 2019
by
Shucai Xiao
Browse files
Merge branch 'develop' of
https://github.com/ROCmSoftwarePlatform/AMDMIGraphX
into rnn_operator
parents
2dfb4b0f
15d3cf62
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
192 additions
and
1 deletion
+192
-1
src/targets/gpu/CMakeLists.txt
src/targets/gpu/CMakeLists.txt
+1
-0
src/targets/gpu/device/sub.cpp
src/targets/gpu/device/sub.cpp
+17
-0
src/targets/gpu/include/migraphx/gpu/device/sub.hpp
src/targets/gpu/include/migraphx/gpu/device/sub.hpp
+20
-0
src/targets/gpu/include/migraphx/gpu/sub.hpp
src/targets/gpu/include/migraphx/gpu/sub.hpp
+34
-0
src/targets/gpu/lowering.cpp
src/targets/gpu/lowering.cpp
+2
-0
test/gpu/miopen.cpp
test/gpu/miopen.cpp
+34
-0
test/onnx/implicit_sub_bcast_test.onnx
test/onnx/implicit_sub_bcast_test.onnx
+20
-0
test/onnx/onnx_test.cpp
test/onnx/onnx_test.cpp
+42
-1
test/onnx/sub_bcast_test.onnx
test/onnx/sub_bcast_test.onnx
+22
-0
test/onnx/sub_scalar_test.onnx
test/onnx/sub_scalar_test.onnx
+0
-0
No files found.
src/targets/gpu/CMakeLists.txt
View file @
96f81a26
...
@@ -30,6 +30,7 @@ add_library(migraphx_device
...
@@ -30,6 +30,7 @@ add_library(migraphx_device
device/concat.cpp
device/concat.cpp
device/pad.cpp
device/pad.cpp
device/gather.cpp
device/gather.cpp
device/sub.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/sub.cpp
0 → 100644
View file @
96f81a26
#include <migraphx/gpu/device/sub.hpp>
#include <migraphx/gpu/device/nary.hpp>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
gpu
{
namespace
device
{
void
sub
(
hipStream_t
stream
,
const
argument
&
result
,
const
argument
&
arg1
,
const
argument
&
arg2
)
{
nary
(
stream
,
result
,
arg1
,
arg2
)([](
auto
x
,
auto
y
)
{
return
y
-
x
;
});
}
}
// namespace device
}
// namespace gpu
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
src/targets/gpu/include/migraphx/gpu/device/sub.hpp
0 → 100644
View file @
96f81a26
#ifndef MIGRAPHX_GUARD_RTGLIB_DEVICE_SUB_HPP
#define MIGRAPHX_GUARD_RTGLIB_DEVICE_SUB_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
sub
(
hipStream_t
stream
,
const
argument
&
result
,
const
argument
&
arg1
,
const
argument
&
arg2
);
}
// namespace device
}
// namespace gpu
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
#endif
src/targets/gpu/include/migraphx/gpu/sub.hpp
0 → 100644
View file @
96f81a26
#ifndef MIGRAPHX_GUARD_RTGLIB_SUB_HPP
#define MIGRAPHX_GUARD_RTGLIB_SUB_HPP
#include <migraphx/gpu/lowering.hpp>
#include <migraphx/gpu/oper.hpp>
#include <migraphx/manage_ptr.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/operators.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/shape_for_each.hpp>
#include <migraphx/gpu/miopen.hpp>
#include <migraphx/gpu/hip.hpp>
#include <migraphx/dfor.hpp>
#include <migraphx/gpu/device/contiguous.hpp>
#include <migraphx/gpu/device/sub.hpp>
#include <migraphx/iterator_for.hpp>
#include <migraphx/gpu/rocblas.hpp>
#include <migraphx/gpu/context.hpp>
#include <migraphx/config.hpp>
#include <utility>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
gpu
{
struct
hip_sub
:
binary_device
<
hip_sub
,
device
::
sub
>
{
};
}
// namespace gpu
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
#endif
src/targets/gpu/lowering.cpp
View file @
96f81a26
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
#include <migraphx/gpu/elu.hpp>
#include <migraphx/gpu/elu.hpp>
#include <migraphx/gpu/softmax.hpp>
#include <migraphx/gpu/softmax.hpp>
#include <migraphx/gpu/add.hpp>
#include <migraphx/gpu/add.hpp>
#include <migraphx/gpu/sub.hpp>
#include <migraphx/gpu/exp.hpp>
#include <migraphx/gpu/exp.hpp>
#include <migraphx/gpu/log.hpp>
#include <migraphx/gpu/log.hpp>
#include <migraphx/gpu/sin.hpp>
#include <migraphx/gpu/sin.hpp>
...
@@ -76,6 +77,7 @@ struct miopen_apply
...
@@ -76,6 +77,7 @@ struct miopen_apply
add_miopen_extend_op
<
miopen_elu
,
op
::
elu
>
(
"elu"
,
make_elu
);
add_miopen_extend_op
<
miopen_elu
,
op
::
elu
>
(
"elu"
,
make_elu
);
add_generic_op
<
hip_add
>
(
"add"
);
add_generic_op
<
hip_add
>
(
"add"
);
add_generic_op
<
hip_sub
>
(
"sub"
);
add_generic_op
<
hip_exp
>
(
"exp"
);
add_generic_op
<
hip_exp
>
(
"exp"
);
add_generic_op
<
hip_log
>
(
"log"
);
add_generic_op
<
hip_log
>
(
"log"
);
add_generic_op
<
hip_sin
>
(
"sin"
);
add_generic_op
<
hip_sin
>
(
"sin"
);
...
...
test/gpu/miopen.cpp
View file @
96f81a26
...
@@ -483,6 +483,38 @@ struct test_triadd_broadcast
...
@@ -483,6 +483,38 @@ struct test_triadd_broadcast
}
}
};
};
struct
test_sub
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
}};
auto
x
=
p
.
add_parameter
(
"x"
,
s
);
auto
y
=
p
.
add_parameter
(
"y"
,
s
);
auto
z
=
p
.
add_parameter
(
"z"
,
s
);
auto
diff
=
p
.
add_instruction
(
migraphx
::
op
::
sub
{},
x
,
y
);
p
.
add_instruction
(
migraphx
::
op
::
sub
{},
diff
,
z
);
return
p
;
}
};
struct
test_sub2
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
2
,
3
}};
migraphx
::
shape
b
{
migraphx
::
shape
::
float_type
,
{
3
}};
auto
x
=
p
.
add_parameter
(
"x"
,
s
);
auto
y
=
p
.
add_parameter
(
"y"
,
s
);
auto
z
=
p
.
add_parameter
(
"z"
,
b
);
auto
zb
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
1
,
s
},
z
);
auto
diff
=
p
.
add_instruction
(
migraphx
::
op
::
sub
{},
x
,
y
);
p
.
add_instruction
(
migraphx
::
op
::
sub
{},
diff
,
zb
);
return
p
;
}
};
struct
test_softmax
struct
test_softmax
{
{
migraphx
::
program
create_program
()
const
migraphx
::
program
create_program
()
const
...
@@ -1503,6 +1535,8 @@ int main()
...
@@ -1503,6 +1535,8 @@ int main()
verify_program
<
test_add_broadcast4
>
();
verify_program
<
test_add_broadcast4
>
();
verify_program
<
test_add_broadcast5
>
();
verify_program
<
test_add_broadcast5
>
();
verify_program
<
test_triadd_broadcast
>
();
verify_program
<
test_triadd_broadcast
>
();
verify_program
<
test_sub
>
();
verify_program
<
test_sub2
>
();
verify_program
<
test_softmax
>
();
verify_program
<
test_softmax
>
();
verify_program
<
test_softmax2
>
();
verify_program
<
test_softmax2
>
();
verify_program
<
test_conv
>
();
verify_program
<
test_conv
>
();
...
...
test/onnx/implicit_sub_bcast_test.onnx
0 → 100644
View file @
96f81a26
subtraction2:q
0
1out"Subsubtraction2Z
0
Z
1
b
out
B
\ No newline at end of file
test/onnx/onnx_test.cpp
View file @
96f81a26
...
@@ -346,7 +346,7 @@ TEST_CASE(add_bcast_test)
...
@@ -346,7 +346,7 @@ TEST_CASE(add_bcast_test)
EXPECT
(
p
==
prog
);
EXPECT
(
p
==
prog
);
}
}
TEST_CASE
(
implicit_bcast_test
)
TEST_CASE
(
implicit_
add_
bcast_test
)
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
auto
l0
=
p
.
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
5
}});
auto
l0
=
p
.
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
5
}});
...
@@ -360,6 +360,33 @@ TEST_CASE(implicit_bcast_test)
...
@@ -360,6 +360,33 @@ TEST_CASE(implicit_bcast_test)
EXPECT
(
p
==
prog
);
EXPECT
(
p
==
prog
);
}
}
TEST_CASE
(
sub_bcast_test
)
{
migraphx
::
program
p
;
auto
l0
=
p
.
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
5
}});
auto
l1
=
p
.
add_parameter
(
"1"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
4
}});
auto
l2
=
p
.
add_instruction
(
migraphx
::
op
::
broadcast
{
1
,
l0
->
get_shape
()},
l1
);
p
.
add_instruction
(
migraphx
::
op
::
sub
{},
l0
,
l2
);
auto
prog
=
migraphx
::
parse_onnx
(
"sub_bcast_test.onnx"
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
implicit_sub_bcast_test
)
{
migraphx
::
program
p
;
auto
l0
=
p
.
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
5
}});
auto
l1
=
p
.
add_parameter
(
"1"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
4
}});
auto
l2
=
p
.
add_instruction
(
migraphx
::
op
::
multibroadcast
{{
2
,
3
,
4
,
5
}},
l0
);
auto
l3
=
p
.
add_instruction
(
migraphx
::
op
::
multibroadcast
{{
2
,
3
,
4
,
5
}},
l1
);
p
.
add_instruction
(
migraphx
::
op
::
sub
{},
l2
,
l3
);
auto
prog
=
migraphx
::
parse_onnx
(
"implicit_sub_bcast_test.onnx"
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
unknown_test
)
TEST_CASE
(
unknown_test
)
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
...
@@ -714,6 +741,20 @@ TEST_CASE(add_scalar_test)
...
@@ -714,6 +741,20 @@ TEST_CASE(add_scalar_test)
EXPECT
(
p
==
prog
);
EXPECT
(
p
==
prog
);
}
}
TEST_CASE
(
sub_scalar_test
)
{
migraphx
::
program
p
;
auto
l0
=
p
.
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
5
}});
auto
l1
=
p
.
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
}},
{
1
}});
auto
m0
=
p
.
add_instruction
(
migraphx
::
op
::
multibroadcast
{{
2
,
3
,
4
,
5
}},
l0
);
auto
m1
=
p
.
add_instruction
(
migraphx
::
op
::
multibroadcast
{{
2
,
3
,
4
,
5
}},
l1
);
p
.
add_instruction
(
migraphx
::
op
::
sub
{},
m0
,
m1
);
auto
prog
=
migraphx
::
parse_onnx
(
"sub_scalar_test.onnx"
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
group_conv_test
)
TEST_CASE
(
group_conv_test
)
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
...
...
test/onnx/sub_bcast_test.onnx
0 → 100644
View file @
96f81a26
subtraction2:
/
0
1out"Sub*
axis*
broadcastsubtraction2Z
0
Z
1
b
out
B
\ No newline at end of file
test/onnx/sub_scalar_test.onnx
0 → 100644
View file @
96f81a26
File added
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