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
8d059502
"vscode:/vscode.git/clone" did not exist on "e4e4f0bf60984ddbf43deeba75d9f369d462f0b6"
Commit
8d059502
authored
Jul 10, 2019
by
Shucai Xiao
Browse files
merge develop branch
parents
026365a6
80b06ca7
Changes
29
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
350 additions
and
14 deletions
+350
-14
src/targets/gpu/lowering.cpp
src/targets/gpu/lowering.cpp
+6
-0
src/targets/gpu/reduce_mean.cpp
src/targets/gpu/reduce_mean.cpp
+24
-0
test/cpu_ops_test.cpp
test/cpu_ops_test.cpp
+95
-5
test/gpu/miopen.cpp
test/gpu/miopen.cpp
+80
-0
test/onnx/erf_test.onnx
test/onnx/erf_test.onnx
+13
-0
test/onnx/onnx_test.cpp
test/onnx/onnx_test.cpp
+31
-0
test/onnx/reducemean_test1.onnx
test/onnx/reducemean_test1.onnx
+0
-0
test/onnx/reducemean_test2.onnx
test/onnx/reducemean_test2.onnx
+18
-0
test/op_shape_test.cpp
test/op_shape_test.cpp
+83
-9
No files found.
src/targets/gpu/lowering.cpp
View file @
8d059502
...
@@ -26,7 +26,9 @@
...
@@ -26,7 +26,9 @@
#include <migraphx/gpu/logsoftmax.hpp>
#include <migraphx/gpu/logsoftmax.hpp>
#include <migraphx/gpu/add.hpp>
#include <migraphx/gpu/add.hpp>
#include <migraphx/gpu/sub.hpp>
#include <migraphx/gpu/sub.hpp>
#include <migraphx/gpu/div.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>
...
@@ -51,6 +53,7 @@
...
@@ -51,6 +53,7 @@
#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/pow.hpp>
#include <migraphx/gpu/pow.hpp>
#include <migraphx/gpu/reduce_mean.hpp>
#include <utility>
#include <utility>
#include <functional>
#include <functional>
#include <algorithm>
#include <algorithm>
...
@@ -87,6 +90,7 @@ struct miopen_apply
...
@@ -87,6 +90,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"
);
...
@@ -97,6 +101,7 @@ struct miopen_apply
...
@@ -97,6 +101,7 @@ struct miopen_apply
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_mul
>
(
"mul"
);
add_generic_op
<
hip_mul
>
(
"mul"
);
add_generic_op
<
hip_div
>
(
"div"
);
add_generic_op
<
hip_max
>
(
"max"
);
add_generic_op
<
hip_max
>
(
"max"
);
add_generic_op
<
hip_min
>
(
"min"
);
add_generic_op
<
hip_min
>
(
"min"
);
add_generic_op
<
hip_pow
>
(
"pow"
);
add_generic_op
<
hip_pow
>
(
"pow"
);
...
@@ -113,6 +118,7 @@ struct miopen_apply
...
@@ -113,6 +118,7 @@ struct miopen_apply
add_extend_op
<
hip_convert
,
op
::
convert
>
(
"convert"
);
add_extend_op
<
hip_convert
,
op
::
convert
>
(
"convert"
);
add_extend_op
<
hip_clip
,
op
::
clip
>
(
"clip"
);
add_extend_op
<
hip_clip
,
op
::
clip
>
(
"clip"
);
add_extend_op
<
hip_reduce_sum
,
op
::
reduce_sum
>
(
"reduce_sum"
);
add_extend_op
<
hip_reduce_sum
,
op
::
reduce_sum
>
(
"reduce_sum"
);
add_extend_op
<
hip_reduce_mean
,
op
::
reduce_mean
>
(
"reduce_mean"
);
add_lrn_op
();
add_lrn_op
();
add_convolution_op
();
add_convolution_op
();
...
...
src/targets/gpu/reduce_mean.cpp
0 → 100644
View file @
8d059502
#include <migraphx/gpu/reduce_mean.hpp>
#include <migraphx/gpu/context.hpp>
#include <migraphx/gpu/device/reduce_mean.hpp>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
gpu
{
shape
hip_reduce_mean
::
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
inputs
.
pop_back
();
return
op
.
compute_shape
(
inputs
);
}
argument
hip_reduce_mean
::
compute
(
context
&
ctx
,
const
shape
&
,
const
std
::
vector
<
argument
>&
args
)
const
{
device
::
reduce_mean
(
ctx
.
get_stream
().
get
(),
args
.
back
(),
args
.
front
());
return
args
.
back
();
}
}
// namespace gpu
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
test/cpu_ops_test.cpp
View file @
8d059502
...
@@ -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
;
...
@@ -1703,7 +1718,7 @@ TEST_CASE(clip_test)
...
@@ -1703,7 +1718,7 @@ TEST_CASE(clip_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
}
TEST_CASE
(
reduce_sum_
test
0
)
TEST_CASE
(
reduce_sum_
axis
0
)
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
2
,
2
}};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
2
,
2
}};
...
@@ -1718,7 +1733,7 @@ TEST_CASE(reduce_sum_test0)
...
@@ -1718,7 +1733,7 @@ TEST_CASE(reduce_sum_test0)
EXPECT
(
results_vector
==
gold
);
EXPECT
(
results_vector
==
gold
);
}
}
TEST_CASE
(
reduce_sum_
test
1
)
TEST_CASE
(
reduce_sum_
axis
1
)
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
2
,
2
}};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
2
,
2
}};
...
@@ -1733,7 +1748,7 @@ TEST_CASE(reduce_sum_test1)
...
@@ -1733,7 +1748,7 @@ TEST_CASE(reduce_sum_test1)
EXPECT
(
results_vector
==
gold
);
EXPECT
(
results_vector
==
gold
);
}
}
TEST_CASE
(
reduce_sum_
test
2
)
TEST_CASE
(
reduce_sum_
axis
2
)
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
2
,
2
}};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
2
,
2
}};
...
@@ -1748,7 +1763,7 @@ TEST_CASE(reduce_sum_test2)
...
@@ -1748,7 +1763,7 @@ TEST_CASE(reduce_sum_test2)
EXPECT
(
results_vector
==
gold
);
EXPECT
(
results_vector
==
gold
);
}
}
TEST_CASE
(
reduce_sum_
test
02
)
TEST_CASE
(
reduce_sum_
axis
02
)
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
2
,
2
}};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
2
,
2
}};
...
@@ -1763,7 +1778,7 @@ TEST_CASE(reduce_sum_test02)
...
@@ -1763,7 +1778,7 @@ TEST_CASE(reduce_sum_test02)
EXPECT
(
results_vector
==
gold
);
EXPECT
(
results_vector
==
gold
);
}
}
TEST_CASE
(
reduce_sum_
test
12
)
TEST_CASE
(
reduce_sum_
axis
12
)
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
2
,
2
}};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
2
,
2
}};
...
@@ -1778,4 +1793,79 @@ TEST_CASE(reduce_sum_test12)
...
@@ -1778,4 +1793,79 @@ TEST_CASE(reduce_sum_test12)
EXPECT
(
results_vector
==
gold
);
EXPECT
(
results_vector
==
gold
);
}
}
TEST_CASE
(
reduce_mean_axis1
)
{
migraphx
::
program
p
;
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
2
,
2
}};
auto
input
=
migraphx
::
literal
{
s
,
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
}};
auto
l0
=
p
.
add_literal
(
input
);
p
.
add_instruction
(
migraphx
::
op
::
reduce_mean
{{
1
}},
l0
);
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
{
2
,
3
,
6
,
7
,
10
,
11
};
EXPECT
(
results_vector
==
gold
);
}
TEST_CASE
(
reduce_mean_axis2
)
{
migraphx
::
program
p
;
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
2
,
2
}};
auto
input
=
migraphx
::
literal
{
s
,
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
}};
auto
l0
=
p
.
add_literal
(
input
);
p
.
add_instruction
(
migraphx
::
op
::
reduce_mean
{{
2
}},
l0
);
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
{
1.5
f
,
3.5
f
,
5.5
f
,
7.5
f
,
9.5
f
,
11.5
f
};
EXPECT
(
results_vector
==
gold
);
}
TEST_CASE
(
reduce_mean_axis02
)
{
migraphx
::
program
p
;
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
2
,
2
}};
auto
input
=
migraphx
::
literal
{
s
,
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
}};
auto
l0
=
p
.
add_literal
(
input
);
p
.
add_instruction
(
migraphx
::
op
::
reduce_mean
{{
0
,
2
}},
l0
);
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
{
5.5
,
7.5
};
EXPECT
(
results_vector
==
gold
);
}
TEST_CASE
(
reduce_mean_axis12
)
{
migraphx
::
program
p
;
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
2
,
2
}};
auto
input
=
migraphx
::
literal
{
s
,
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
}};
auto
l0
=
p
.
add_literal
(
input
);
p
.
add_instruction
(
migraphx
::
op
::
reduce_mean
{{
1
,
2
}},
l0
);
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
{
2.5
f
,
6.5
f
,
10.5
f
};
EXPECT
(
results_vector
==
gold
);
}
TEST_CASE
(
reduce_mean_int
)
{
migraphx
::
program
p
;
migraphx
::
shape
s
{
migraphx
::
shape
::
int32_type
,
{
3
,
2
,
2
}};
auto
input
=
migraphx
::
literal
{
s
,
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
}};
auto
l0
=
p
.
add_literal
(
input
);
p
.
add_instruction
(
migraphx
::
op
::
reduce_mean
{{
1
,
2
}},
l0
);
p
.
compile
(
migraphx
::
cpu
::
target
{});
auto
result
=
p
.
eval
({});
std
::
vector
<
int
>
results_vector
;
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
int
>
gold
{
2
,
6
,
10
};
EXPECT
(
results_vector
==
gold
);
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
test
::
run
(
argc
,
argv
);
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
test
::
run
(
argc
,
argv
);
}
test/gpu/miopen.cpp
View file @
8d059502
...
@@ -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
...
@@ -583,6 +595,38 @@ struct test_sub2 : verify_program<test_sub2>
...
@@ -583,6 +595,38 @@ struct test_sub2 : verify_program<test_sub2>
}
}
};
};
struct
test_div
:
verify_program
<
test_div
>
{
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
::
div
{},
x
,
y
);
p
.
add_instruction
(
migraphx
::
op
::
div
{},
diff
,
z
);
return
p
;
}
};
struct
test_div2
:
verify_program
<
test_div2
>
{
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
.
lens
()},
z
);
auto
diff
=
p
.
add_instruction
(
migraphx
::
op
::
div
{},
x
,
y
);
p
.
add_instruction
(
migraphx
::
op
::
div
{},
diff
,
zb
);
return
p
;
}
};
struct
test_softmax1
:
verify_program
<
test_softmax1
>
struct
test_softmax1
:
verify_program
<
test_softmax1
>
{
{
migraphx
::
program
create_program
()
const
migraphx
::
program
create_program
()
const
...
@@ -3513,4 +3557,40 @@ struct test_reduce_sum_half : verify_program<test_reduce_sum_half>
...
@@ -3513,4 +3557,40 @@ struct test_reduce_sum_half : verify_program<test_reduce_sum_half>
};
};
};
};
struct
test_reduce_mean
:
verify_program
<
test_reduce_mean
>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
9
,
4
,
3
}};
auto
x
=
p
.
add_parameter
(
"x"
,
s
);
p
.
add_instruction
(
migraphx
::
op
::
reduce_mean
{{
1
}},
x
);
return
p
;
};
};
struct
test_reduce_mean_int
:
verify_program
<
test_reduce_mean_int
>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
migraphx
::
shape
s
{
migraphx
::
shape
::
int32_type
,
{
3
,
1024
,
8
,
8
}};
auto
x
=
p
.
add_parameter
(
"x"
,
s
);
p
.
add_instruction
(
migraphx
::
op
::
reduce_mean
{{
1
}},
x
);
return
p
;
};
};
struct
test_reduce_mean_half
:
verify_program
<
test_reduce_mean_half
>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
migraphx
::
shape
s
{
migraphx
::
shape
::
half_type
,
{
3
,
1024
,
8
,
8
}};
auto
x
=
p
.
add_parameter
(
"x"
,
s
);
p
.
add_instruction
(
migraphx
::
op
::
reduce_mean
{{
2
}},
x
);
return
p
;
};
};
int
main
(
int
argc
,
const
char
*
argv
[])
{
test
::
run
(
argc
,
argv
);
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
test
::
run
(
argc
,
argv
);
}
test/onnx/erf_test.onnx
0 → 100644
View file @
8d059502
erf-example:A
xy"Erftest_erfZ
x
b
y
B
test/onnx/onnx_test.cpp
View file @
8d059502
...
@@ -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
;
...
@@ -848,6 +858,27 @@ TEST_CASE(reducesum_test3)
...
@@ -848,6 +858,27 @@ TEST_CASE(reducesum_test3)
EXPECT
(
p
==
prog
);
EXPECT
(
p
==
prog
);
}
}
TEST_CASE
(
reducemean_test1
)
{
migraphx
::
program
p
;
auto
l0
=
p
.
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
4
,
5
,
6
}});
auto
l1
=
p
.
add_instruction
(
migraphx
::
op
::
reduce_mean
{{
2
,
3
}},
l0
);
p
.
add_instruction
(
migraphx
::
op
::
squeeze
{{
2
,
3
}},
l1
);
auto
prog
=
migraphx
::
parse_onnx
(
"reducemean_test1.onnx"
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
reducemean_test2
)
{
migraphx
::
program
p
;
auto
l0
=
p
.
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
4
,
5
,
6
}});
p
.
add_instruction
(
migraphx
::
op
::
reduce_mean
{{
2
}},
l0
);
auto
prog
=
migraphx
::
parse_onnx
(
"reducemean_test2.onnx"
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
clip_test
)
TEST_CASE
(
clip_test
)
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
...
...
test/onnx/reducemean_test1.onnx
0 → 100644
View file @
8d059502
File added
test/onnx/reducemean_test2.onnx
0 → 100644
View file @
8d059502
reducemean-example:}
0
xy"
ReduceMean*
axes@*
keepdimstest_reducemeanZ
x
b
y
B
test/op_shape_test.cpp
View file @
8d059502
...
@@ -390,37 +390,111 @@ TEST_CASE(softmax) { test_softmax_variations<migraphx::op::softmax>(); }
...
@@ -390,37 +390,111 @@ TEST_CASE(softmax) { test_softmax_variations<migraphx::op::softmax>(); }
TEST_CASE
(
logsoftmax
)
{
test_softmax_variations
<
migraphx
::
op
::
logsoftmax
>
();
}
TEST_CASE
(
logsoftmax
)
{
test_softmax_variations
<
migraphx
::
op
::
logsoftmax
>
();
}
template
<
class
T
>
TEST_CASE
(
test_argmax
)
void
test_argop_var
()
{
{
{
{
migraphx
::
shape
input
{
migraphx
::
shape
::
half_type
,
{
2
,
3
,
4
,
5
}};
migraphx
::
shape
input
{
migraphx
::
shape
::
half_type
,
{
2
,
3
,
4
,
5
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{
1
,
3
,
4
,
5
}},
T
{
0
},
input
);
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{
1
,
3
,
4
,
5
}},
migraphx
::
op
::
argmax
{
0
},
input
);
}
{
migraphx
::
shape
input
{
migraphx
::
shape
::
half_type
,
{
2
,
3
,
4
,
5
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{
2
,
1
,
4
,
5
}},
migraphx
::
op
::
argmax
{
1
},
input
);
}
{
migraphx
::
shape
input
{
migraphx
::
shape
::
half_type
,
{
2
,
3
,
4
,
5
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{
2
,
3
,
1
,
5
}},
migraphx
::
op
::
argmax
{
2
},
input
);
}
{
migraphx
::
shape
input
{
migraphx
::
shape
::
half_type
,
{
2
,
3
,
4
,
5
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{
2
,
3
,
4
,
1
}},
migraphx
::
op
::
argmax
{
3
},
input
);
}
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
5
}};
throws_shape
(
migraphx
::
op
::
argmax
{
4
},
input
);
}
}
}
TEST_CASE
(
test_argmin
)
{
{
{
migraphx
::
shape
input
{
migraphx
::
shape
::
half_type
,
{
2
,
3
,
4
,
5
}};
migraphx
::
shape
input
{
migraphx
::
shape
::
half_type
,
{
2
,
3
,
4
,
5
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{
2
,
1
,
4
,
5
}},
T
{
1
},
input
);
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{
1
,
3
,
4
,
5
}},
migraphx
::
op
::
argmin
{
0
},
input
);
}
}
{
{
migraphx
::
shape
input
{
migraphx
::
shape
::
half_type
,
{
2
,
3
,
4
,
5
}};
migraphx
::
shape
input
{
migraphx
::
shape
::
half_type
,
{
2
,
3
,
4
,
5
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{
2
,
3
,
1
,
5
}},
T
{
2
},
input
);
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{
2
,
1
,
4
,
5
}},
migraphx
::
op
::
argmin
{
1
},
input
);
}
}
{
{
migraphx
::
shape
input
{
migraphx
::
shape
::
half_type
,
{
2
,
3
,
4
,
5
}};
migraphx
::
shape
input
{
migraphx
::
shape
::
half_type
,
{
2
,
3
,
4
,
5
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{
2
,
3
,
4
,
1
}},
T
{
3
},
input
);
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{
2
,
3
,
1
,
5
}},
migraphx
::
op
::
argmin
{
2
},
input
);
}
}
{
migraphx
::
shape
input
{
migraphx
::
shape
::
half_type
,
{
2
,
3
,
4
,
5
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{
2
,
3
,
4
,
1
}},
migraphx
::
op
::
argmin
{
3
},
input
);
}
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
5
}};
throws_shape
(
migraphx
::
op
::
argmin
{
4
},
input
);
}
}
template
<
class
T
>
void
test_reduce_ops
()
{
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
5
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
1
,
1
}},
T
{},
input
);
}
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
5
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
1
,
1
}},
T
{{
0
,
1
,
2
,
3
}},
input
);
}
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
5
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
1
,
1
}},
T
{{
2
,
3
}},
input
);
}
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
5
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
4
,
5
}},
T
{{
0
}},
input
);
}
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
5
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
1
}},
T
{{
-
1
}},
input
);
}
{
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
5
}};
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
5
}};
throws_shape
(
T
{
4
},
input
);
throws_shape
(
T
{
{
4
}
},
input
);
}
}
}
}
TEST_CASE
(
argmax
)
{
test_argop_var
<
migraphx
::
op
::
argmax
>
();
}
TEST_CASE
(
reduce_sum
)
{
test_reduce_ops
<
migraphx
::
op
::
reduce_sum
>
();
}
TEST_CASE
(
argmin
)
{
test_argop_var
<
migraphx
::
op
::
argmi
n
>
();
}
TEST_CASE
(
reduce_mean
)
{
test_reduce_ops
<
migraphx
::
op
::
reduce_mea
n
>
();
}
// 2 inputs arguments
// 2 inputs arguments
TEST_CASE
(
matmul
)
TEST_CASE
(
matmul
)
...
...
Prev
1
2
Next
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