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
616cbd16
Commit
616cbd16
authored
Jan 26, 2023
by
Paul
Browse files
Merge
parents
d228ca87
4685520e
Changes
29
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
333 additions
and
37 deletions
+333
-37
test/onnx/onnx_test.cpp
test/onnx/onnx_test.cpp
+108
-36
test/onnx/trilu_batch_diff_k_test.onnx
test/onnx/trilu_batch_diff_k_test.onnx
+15
-0
test/onnx/trilu_lower_test.onnx
test/onnx/trilu_lower_test.onnx
+0
-0
test/onnx/trilu_neg_k_test.onnx
test/onnx/trilu_neg_k_test.onnx
+13
-0
test/onnx/trilu_out_k_test.onnx
test/onnx/trilu_out_k_test.onnx
+13
-0
test/onnx/trilu_row_one_test.onnx
test/onnx/trilu_row_one_test.onnx
+13
-0
test/onnx/trilu_test.onnx
test/onnx/trilu_test.onnx
+13
-0
test/onnx/verify_onnx.cpp
test/onnx/verify_onnx.cpp
+157
-0
test/ref_ops_test.cpp
test/ref_ops_test.cpp
+1
-1
No files found.
test/onnx/onnx_test.cpp
View file @
616cbd16
...
...
@@ -2135,64 +2135,64 @@ TEST_CASE(gemm_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
auto l0 = mm->add_parameter("
0
", migraphx::shape{migraphx::shape::float_type, {
5
,
7
}});
auto l1 = mm->add_parameter("
1
", migraphx::shape{migraphx::shape::float_type, {
11
,
5
}});
auto l2 = mm->add_parameter("
2
", migraphx::shape{migraphx::shape::float_type});
auto alpha =
2.
f;
auto beta =
2.0
f;
auto l0 = mm->add_parameter("
A
", migraphx::shape{migraphx::shape::float_type, {
8
,
6
}});
auto l1 = mm->add_parameter("
B
", migraphx::shape{migraphx::shape::float_type, {
8
,
7
}});
auto l2 = mm->add_parameter("
C
", migraphx::shape{migraphx::shape::float_type
, {6, 7}
});
auto alpha =
0.5
f;
auto beta =
0.8
f;
auto a_l = mm->add_literal(alpha);
auto t_a = add_common_op(*mm, migraphx::make_op("mul"), {a_l, l0});
t_a = mm->add_instruction(migraphx::make_op("transpose", {{"permutation", {1, 0}}}), t_a);
auto t1 = mm->add_instruction(migraphx::make_op("transpose", {{"permutation", {1, 0}}}), l1);
auto dot = migraphx::add_apply_alpha_beta(*mm, {t_a, t1}, migraphx::make_op("dot"), 1.0f, 0.0f);
auto dot = migraphx::add_apply_alpha_beta(*mm, {t_a, l1}, migraphx::make_op("dot"), 1.0f, 0.0f);
auto b_l = mm->add_literal(beta);
auto l2_b =
mm->add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", {7, 11}}}), l2);
auto b_b = mm->add_instruction(
migraphx::make_op("multibroadcast", {{"out_lens", l2
_b
->get_shape().lens()}}), b_l);
auto l2_b
b
= mm->add_instruction(migraphx::make_op("mul"), l2
_b
, b_b);
mm->add_instruction(migraphx::make_op("add"), dot, l2_b
b
);
migraphx::make_op("multibroadcast", {{"out_lens", l2->get_shape().lens()}}), b_l);
auto l2_b = mm->add_instruction(migraphx::make_op("mul"), l2, b_b);
mm->add_instruction(migraphx::make_op("add"), dot, l2_b);
auto prog = optimize_onnx("gemm_test.onnx");
EXPECT(p == prog);
}
TEST_CASE(gemm_
ex
_test)
TEST_CASE(gemm_
no_C
_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
auto l0 = mm->add_parameter("
1
", migraphx::shape{migraphx::shape::float_type, {
1, 1, 8
,
6
}});
auto l1 = mm->add_parameter("
2
", migraphx::shape{migraphx::shape::float_type, {1
,
1,
8, 7
}});
auto l2 = mm->add_parameter("
3
", migraphx::shape{migraphx::shape::float_type
, {1, 1, 6, 7}
});
auto alpha =
0.5
f;
auto beta =
0.8
f;
auto l0 = mm->add_parameter("
A
", migraphx::shape{migraphx::shape::float_type, {
5
,
7
}});
auto l1 = mm->add_parameter("
B
", migraphx::shape{migraphx::shape::float_type, {11,
5
}});
auto l2 = mm->add_parameter("
C
", migraphx::shape{migraphx::shape::float_type});
auto alpha =
2.
f;
auto beta =
2.0
f;
auto a_l = mm->add_literal(alpha);
auto t_a = add_common_op(*mm, migraphx::make_op("mul"), {a_l, l0});
t_a = mm->add_instruction(migraphx::make_op("transpose", {{"permutation", {0, 1, 3, 2}}}), t_a);
auto dot = migraphx::add_apply_alpha_beta(*mm, {t_a, l1}, migraphx::make_op("dot"), 1.0f, 0.0f);
t_a = mm->add_instruction(migraphx::make_op("transpose", {{"permutation", {1, 0}}}), t_a);
auto t1 = mm->add_instruction(migraphx::make_op("transpose", {{"permutation", {1, 0}}}), l1);
auto dot = migraphx::add_apply_alpha_beta(*mm, {t_a, t1}, migraphx::make_op("dot"), 1.0f, 0.0f);
auto b_l = mm->add_literal(beta);
auto l2_b =
mm->add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", {7, 11}}}), l2);
auto b_b = mm->add_instruction(
migraphx::make_op("multibroadcast", {{"out_lens", l2->get_shape().lens()}}), b_l);
auto l2_b = mm->add_instruction(migraphx::make_op("mul"), l2, b_b);
mm->add_instruction(migraphx::make_op("add"), dot, l2_b);
migraphx::make_op("multibroadcast", {{"out_lens", l2
_b
->get_shape().lens()}}), b_l);
auto l2_b
b
= mm->add_instruction(migraphx::make_op("mul"), l2
_b
, b_b);
mm->add_instruction(migraphx::make_op("add"), dot, l2_b
b
);
auto prog = optimize_onnx("gemm_
ex
_test.onnx");
auto prog = optimize_onnx("gemm_
no_C
_test.onnx");
EXPECT(p == prog);
}
TEST_CASE(gemm_
ex_
brcst_test)
TEST_CASE(gemm_brcst_
C_
test)
{
migraphx::program p;
auto* mm = p.get_main_module();
auto l0 = mm->add_parameter("
1
", migraphx::shape{migraphx::shape::float_type, {
1, 1,
5, 6}});
auto l1 = mm->add_parameter("
2
", migraphx::shape{migraphx::shape::float_type, {
1, 1,
5, 7}});
auto l2 = mm->add_parameter("
3
", migraphx::shape{migraphx::shape::float_type, {
1, 1,
6, 1}});
std::vector<std::size_t> out_lens{
1, 1,
6, 7};
auto l0 = mm->add_parameter("
A
", migraphx::shape{migraphx::shape::float_type, {5, 6}});
auto l1 = mm->add_parameter("
B
", migraphx::shape{migraphx::shape::float_type, {5, 7}});
auto l2 = mm->add_parameter("
C
", migraphx::shape{migraphx::shape::float_type, {6, 1}});
std::vector<std::size_t> out_lens{6, 7};
auto alpha = 0.5f;
auto beta = 0.8f;
auto a_l = mm->add_literal(alpha);
auto t_a = add_common_op(*mm, migraphx::make_op("mul"), {a_l, l0});
t_a = mm->add_instruction(migraphx::make_op("transpose", {{"permutation", {
0, 1, 3, 2
}}}), t_a);
t_a
= mm->add_instruction(migraphx::make_op("transpose", {{"permutation", {
1, 0
}}}), t_a);
auto dot = migraphx::add_apply_alpha_beta(*mm, {t_a, l1}, migraphx::make_op("dot"), 1.0f, 0.0f);
auto b_l = mm->add_literal(beta);
auto l2_b =
...
...
@@ -2202,7 +2202,7 @@ TEST_CASE(gemm_ex_brcst_test)
auto l2_bb = mm->add_instruction(migraphx::make_op("mul"), l2_b, b_b);
mm->add_instruction(migraphx::make_op("add"), dot, l2_bb);
auto prog = optimize_onnx("gemm_
ex_
brcst_test.onnx");
auto prog = optimize_onnx("gemm_brcst_
C_
test.onnx");
EXPECT(p == prog);
}
...
...
@@ -2210,17 +2210,17 @@ TEST_CASE(gemm_half_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
auto l0 = mm->add_parameter("
1
", migraphx::shape{migraphx::shape::half_type, {
1, 1,
8, 6}});
auto l1 = mm->add_parameter("
2
", migraphx::shape{migraphx::shape::half_type, {
1, 1,
8, 7}});
auto l2 = mm->add_parameter("
3
", migraphx::shape{migraphx::shape::half_type, {
1, 1,
6, 1}});
auto l0 = mm->add_parameter("
A
", migraphx::shape{migraphx::shape::half_type, {8, 6}});
auto l1 = mm->add_parameter("
B
", migraphx::shape{migraphx::shape::half_type, {8, 7}});
auto l2 = mm->add_parameter("
C
", migraphx::shape{migraphx::shape::half_type, {6, 1}});
auto alpha = 0.5f;
auto beta = 0.8f;
auto a_l = mm->add_literal(alpha);
auto t_a = add_common_op(*mm, migraphx::make_op("mul"), {a_l, l0});
t_a = mm->add_instruction(
migraphx::make_op("convert", {{"target_type", migraphx::shape::half_type}}), t_a);
t_a = mm->add_instruction(migraphx::make_op("transpose", {{"permutation", {
0, 1, 3, 2
}}}), t_a);
std::vector<std::size_t> lens = {
1, 1,
6, 7};
t_a = mm->add_instruction(migraphx::make_op("transpose", {{"permutation", {
1, 0
}}}), t_a);
std::vector<std::size_t> lens = {6, 7};
auto dot = migraphx::add_apply_alpha_beta(*mm, {t_a, l1}, migraphx::make_op("dot"), 1.0f, 0.0f);
l2 = mm->add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", lens}}), l2);
l2 = mm->add_instruction(
...
...
@@ -2236,6 +2236,73 @@ TEST_CASE(gemm_half_test)
EXPECT(p == prog);
}
TEST_CASE(gemm_dyn_inner_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
auto l0 = mm->add_parameter(
"A", migraphx::shape{migraphx::shape::float_type, {{1, 10, 8}, {6, 6, 0}}});
auto l1 = mm->add_parameter(
"B", migraphx::shape{migraphx::shape::float_type, {{1, 10, 8}, {7, 7, 0}}});
auto alpha = 0.5f;
auto a_l = mm->add_literal(alpha);
auto t_a = add_common_op(*mm, migraphx::make_op("mul"), {a_l, l0});
t_a = mm->add_instruction(migraphx::make_op("transpose", {{"permutation", {1, 0}}}), t_a);
auto dot = migraphx::add_apply_alpha_beta(*mm, {t_a, l1}, migraphx::make_op("dot"), 1.0f, 0.0f);
mm->add_return({dot});
migraphx::onnx_options options;
options.default_dyn_dim_value = {1, 10, 8};
auto prog = migraphx::parse_onnx("gemm_dyn_inner_test.onnx", options);
EXPECT(p == prog);
}
TEST_CASE(gemm_dyn_outer_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
auto l0 = mm->add_parameter(
"A", migraphx::shape{migraphx::shape::float_type, {{5, 5, 0}, {5, 10, 7}}});
auto l1 = mm->add_parameter("B", migraphx::shape{migraphx::shape::float_type, {11, 5}});
auto alpha = 2.f;
auto a_l = mm->add_literal(alpha);
auto t_a = add_common_op(*mm, migraphx::make_op("mul"), {a_l, l0});
t_a = mm->add_instruction(migraphx::make_op("transpose", {{"permutation", {1, 0}}}), t_a);
auto t1 = mm->add_instruction(migraphx::make_op("transpose", {{"permutation", {1, 0}}}), l1);
auto dot = migraphx::add_apply_alpha_beta(*mm, {t_a, t1}, migraphx::make_op("dot"), 1.0f, 0.0f);
mm->add_return({dot});
migraphx::onnx_options options;
options.default_dyn_dim_value = {5, 10, 7};
auto prog = migraphx::parse_onnx("gemm_dyn_outer_test.onnx", options);
EXPECT(p == prog);
}
TEST_CASE(gemm_dyn_bias_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
auto x0 =
mm->add_parameter("A", migraphx::shape{migraphx::shape::float_type, {{8, 8}, {1, 10}}});
auto x1 = mm->add_parameter("B", migraphx::shape{migraphx::shape::float_type, {8, 7}});
auto x2 = mm->add_parameter("C", migraphx::shape{migraphx::shape::float_type, {1, 7}});
auto x0_t = mm->add_instruction(migraphx::make_op("transpose", {{"permutation", {1, 0}}}), x0);
auto dot = mm->add_instruction(migraphx::make_op("dot"), x0_t, x1);
auto x2_b = mm->add_instruction(migraphx::make_op("multibroadcast"), x2, dot);
auto ret = mm->add_instruction(migraphx::make_op("add"), dot, x2_b);
mm->add_return({ret});
migraphx::onnx_options options;
options.default_dyn_dim_value = {1, 10};
auto prog = parse_onnx("gemm_dyn_bias_test.onnx", options);
EXPECT(p == prog);
}
TEST_CASE(gemm_rank_error)
{
EXPECT(test::throws([&] { migraphx::parse_onnx("gemm_rank_error.onnx"); }));
}
TEST_CASE(globalavgpool_test)
{
migraphx::program p;
...
...
@@ -6485,6 +6552,11 @@ TEST_CASE(transpose_gather_test)
EXPECT(p.sort() == prog.sort());
}
TEST_CASE(trilu_neg_k_test)
{
EXPECT(test::throws([&] { migraphx::parse_onnx("trilu_neg_k_test.onnx"); }));
}
TEST_CASE(undefined_test)
{
migraphx::program p;
...
...
test/onnx/trilu_batch_diff_k_test.onnx
0 → 100644
View file @
616cbd16
trilu_batch_diff_k_test:i
x
ky"Trilutrilu_batch_diff_k_test*
:BkZ
x
b
y
B
\ No newline at end of file
test/onnx/trilu_lower_test.onnx
0 → 100644
View file @
616cbd16
File added
test/onnx/trilu_neg_k_test.onnx
0 → 100644
View file @
616cbd16
trilu_neg_k_test:c
x
ky"Trilutrilu_neg_k_test*:
BkZ
x
b
y
B
\ No newline at end of file
test/onnx/trilu_out_k_test.onnx
0 → 100644
View file @
616cbd16
trilu_out_k_test:Z
x
ky"Trilutrilu_out_k_test*
:BkZ
x
b
y
B
\ No newline at end of file
test/onnx/trilu_row_one_test.onnx
0 → 100644
View file @
616cbd16
trilu_row_one_test:\
x
ky"Trilutrilu_row_one_test*
:BkZ
x
b
y
B
\ No newline at end of file
test/onnx/trilu_test.onnx
0 → 100644
View file @
616cbd16
trilu_test:E
xy"Trilu
trilu_testZ
x
b
y
B
\ No newline at end of file
test/onnx/verify_onnx.cpp
View file @
616cbd16
...
...
@@ -451,6 +451,94 @@ TEST_CASE(gather_elements)
EXPECT
(
migraphx
::
verify_range
(
result_vector
,
gold
));
}
TEST_CASE
(
gemm_test
)
{
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"gemm_brcst_C_test.onnx"
);
p
.
compile
(
migraphx
::
ref
::
target
{});
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
float_type
,
{
5
,
6
}};
std
::
vector
<
float
>
a_data
=
{
0.26472837
,
0.8525864
,
0.41929847
,
0.14151508
,
0.43216065
,
0.67468566
,
0.42488748
,
0.82021785
,
0.9782456
,
0.5794279
,
0.6627283
,
0.4790396
,
0.9237051
,
0.7340607
,
0.67379653
,
0.87168175
,
0.37324256
,
0.33278653
,
0.42736676
,
0.024699844
,
0.75851107
,
0.48719302
,
0.5834426
,
0.6938476
,
0.43747696
,
0.24054702
,
0.26912406
,
0.6760658
,
0.5419149
,
0.89949054
};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
{
5
,
7
}};
std
::
vector
<
float
>
b_data
=
{
0.65727437
,
0.54262096
,
0.14126152
,
0.8994123
,
0.21831702
,
0.81191784
,
0.9371278
,
0.3438551
,
0.7121373
,
0.90316695
,
0.26614252
,
0.80144906
,
0.80301756
,
0.49930334
,
0.0719704
,
0.63484156
,
0.7343097
,
0.32130218
,
0.7094916
,
0.6116475
,
0.74144083
,
0.021210382
,
0.38724765
,
0.44830495
,
0.62347615
,
0.022489505
,
0.23316588
,
0.76540905
,
0.895689
,
0.81540287
,
0.223875
,
0.9275573
,
0.4621397
,
0.70785195
,
0.5658555
};
migraphx
::
shape
c_shape
{
migraphx
::
shape
::
float_type
,
{
6
,
1
}};
std
::
vector
<
float
>
c_data
=
{
0.07358502
,
0.13792239
,
0.8574055
,
0.40553397
,
0.38205826
,
0.62062204
};
migraphx
::
parameter_map
params
;
params
[
"A"
]
=
migraphx
::
argument
(
a_shape
,
a_data
.
data
());
params
[
"B"
]
=
migraphx
::
argument
(
b_shape
,
b_data
.
data
());
params
[
"C"
]
=
migraphx
::
argument
(
c_shape
,
c_data
.
data
());
auto
result
=
p
.
eval
(
params
).
back
();
std
::
vector
<
float
>
result_vector
;
result
.
visit
([
&
](
auto
output
)
{
result_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
=
{
0.45261115
,
0.83629227
,
0.7533463
,
0.7189715
,
0.69160205
,
0.824082
,
0.9187499
,
0.6659525
,
0.96956736
,
0.84293026
,
0.8400868
,
0.84835225
,
1.0982862
,
1.0642393
,
1.1447254
,
1.6184721
,
1.6048342
,
1.4741788
,
1.4334437
,
1.638659
,
1.7428316
,
0.8098607
,
1.2157929
,
1.1010075
,
1.0706307
,
1.0429881
,
1.1771785
,
1.2362702
,
0.8239243
,
1.1112559
,
0.9639262
,
1.0813537
,
0.8825792
,
1.121141
,
1.1885703
,
1.2227502
,
1.4568202
,
1.1388762
,
1.55058
,
1.0958102
,
1.4637487
,
1.5756242
};
EXPECT
(
migraphx
::
verify_range
(
result_vector
,
gold
));
}
TEST_CASE
(
gemm_half_test
)
{
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"gemm_half_test.onnx"
);
p
.
compile
(
migraphx
::
ref
::
target
{});
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
half_type
,
{
8
,
6
}};
std
::
vector
tmp
=
{
0.2646
,
0.8525
,
0.4192
,
0.1415
,
0.4321
,
0.675
,
0.4248
,
0.8203
,
0.978
,
0.5796
,
0.6626
,
0.479
,
0.924
,
0.734
,
0.674
,
0.8716
,
0.3733
,
0.3328
,
0.4272
,
0.0247
,
0.7583
,
0.4873
,
0.5835
,
0.694
,
0.4375
,
0.2406
,
0.269
,
0.6763
,
0.542
,
0.8994
,
0.657
,
0.5425
,
0.1412
,
0.8994
,
0.2183
,
0.812
,
0.937
,
0.3438
,
0.712
,
0.9033
,
0.266
,
0.8013
,
0.803
,
0.4993
,
0.07196
,
0.635
,
0.7344
,
0.3213
};
std
::
vector
<
migraphx
::
half
>
a_data
{
tmp
.
cbegin
(),
tmp
.
cend
()};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
half_type
,
{
8
,
7
}};
tmp
=
{
0.7095
,
0.612
,
0.741
,
0.02121
,
0.3872
,
0.4482
,
0.6235
,
0.02249
,
0.2332
,
0.7656
,
0.8955
,
0.8154
,
0.2239
,
0.9277
,
0.4622
,
0.708
,
0.566
,
0.0736
,
0.138
,
0.8574
,
0.4055
,
0.382
,
0.6206
,
0.424
,
0.3674
,
0.435
,
0.998
,
0.3594
,
0.701
,
0.6216
,
0.01826
,
0.6313
,
0.514
,
0.1095
,
0.3203
,
0.01636
,
0.537
,
0.01952
,
0.4502
,
0.8965
,
0.5415
,
0.7456
,
0.793
,
0.756
,
0.9
,
0.5264
,
0.05368
,
0.4214
,
0.276
,
0.1517
,
0.08453
,
0.83
,
0.417
,
0.1682
,
0.845
,
0.1729
};
std
::
vector
<
migraphx
::
half
>
b_data
{
tmp
.
cbegin
(),
tmp
.
cend
()};
migraphx
::
shape
c_shape
{
migraphx
::
shape
::
half_type
,
{
6
,
1
}};
tmp
=
{
0.10846
,
0.672
,
0.527
,
0.94
,
0.429
,
0.2291
};
std
::
vector
<
migraphx
::
half
>
c_data
{
tmp
.
cbegin
(),
tmp
.
cend
()};
migraphx
::
parameter_map
params
;
params
[
"A"
]
=
migraphx
::
argument
(
a_shape
,
a_data
.
data
());
params
[
"B"
]
=
migraphx
::
argument
(
b_shape
,
b_data
.
data
());
params
[
"C"
]
=
migraphx
::
argument
(
c_shape
,
c_data
.
data
());
auto
result
=
p
.
eval
(
params
).
back
();
std
::
vector
<
migraphx
::
half
>
result_vector
;
result
.
visit
([
&
](
auto
output
)
{
result_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
tmp
=
{
1.071
,
1.378
,
1.465
,
1.093
,
0.968
,
1.542
,
1.145
,
1.287
,
1.533
,
1.75
,
1.338
,
1.449
,
1.592
,
1.668
,
1.265
,
1.531
,
1.656
,
1.348
,
1.2705
,
1.525
,
1.479
,
1.754
,
2.143
,
2.062
,
1.921
,
1.836
,
2.203
,
1.952
,
1.055
,
1.225
,
1.418
,
1.209
,
1.155
,
1.42
,
1.234
,
1.302
,
1.593
,
1.368
,
1.289
,
1.327
,
1.451
,
1.394
};
std
::
vector
<
migraphx
::
half
>
gold
{
tmp
.
cbegin
(),
tmp
.
cend
()};
EXPECT
(
migraphx
::
verify_range
(
result_vector
,
gold
));
}
TEST_CASE
(
greaterorequal_test
)
{
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"greaterorequal_test.onnx"
);
...
...
@@ -1370,4 +1458,73 @@ TEST_CASE(where_test)
EXPECT
(
migraphx
::
verify_range
(
result_vector
,
gold
));
}
std
::
vector
<
float
>
gen_trilu_test
(
const
migraphx
::
shape
&
s
,
const
migraphx
::
program
&
p
)
{
// input data filled with values 1 to nelements
std
::
vector
<
float
>
x_data
(
s
.
elements
());
std
::
iota
(
x_data
.
begin
(),
x_data
.
end
(),
1
);
migraphx
::
parameter_map
pp
;
pp
[
"x"
]
=
migraphx
::
argument
(
s
,
x_data
.
data
());
auto
result
=
p
.
eval
(
pp
).
back
();
std
::
vector
<
float
>
result_vector
;
result
.
visit
([
&
](
auto
output
)
{
result_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
return
result_vector
;
}
TEST_CASE
(
trilu_test
)
{
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"trilu_test.onnx"
);
std
::
vector
<
float
>
result_vector
=
gen_trilu_test
({
migraphx
::
shape
::
float_type
,
{
3
,
4
}},
p
);
std
::
vector
<
float
>
gold
=
{
1
,
2
,
3
,
4
,
0
,
6
,
7
,
8
,
0
,
0
,
11
,
12
};
EXPECT
(
migraphx
::
verify_range
(
result_vector
,
gold
));
}
TEST_CASE
(
trilu_batch_diff_k_test
)
{
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"trilu_batch_diff_k_test.onnx"
);
std
::
vector
<
float
>
result_vector
=
gen_trilu_test
({
migraphx
::
shape
::
float_type
,
{
2
,
2
,
3
}},
p
);
std
::
vector
<
float
>
gold
=
{
0
,
0
,
3
,
0
,
0
,
0
,
0
,
0
,
9
,
0
,
0
,
0
};
EXPECT
(
migraphx
::
verify_range
(
result_vector
,
gold
));
}
TEST_CASE
(
trilu_lower_test
)
{
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"trilu_lower_test.onnx"
);
std
::
vector
<
float
>
result_vector
=
gen_trilu_test
({
migraphx
::
shape
::
float_type
,
{
3
,
4
}},
p
);
std
::
vector
<
float
>
gold
=
{
0
,
0
,
0
,
0
,
5
,
0
,
0
,
0
,
9
,
10
,
0
,
0
};
EXPECT
(
migraphx
::
verify_range
(
result_vector
,
gold
));
}
TEST_CASE
(
trilu_out_k_test
)
{
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"trilu_out_k_test.onnx"
);
std
::
vector
<
float
>
result_vector
=
gen_trilu_test
({
migraphx
::
shape
::
float_type
,
{
3
,
4
}},
p
);
std
::
vector
<
float
>
gold
(
12
,
0
);
EXPECT
(
migraphx
::
verify_range
(
result_vector
,
gold
));
}
TEST_CASE
(
trilu_row_one_test
)
{
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"trilu_row_one_test.onnx"
);
std
::
vector
<
float
>
result_vector
=
gen_trilu_test
({
migraphx
::
shape
::
float_type
,
{
1
,
4
}},
p
);
std
::
vector
<
float
>
gold
=
{
0
,
2
,
3
,
4
};
EXPECT
(
migraphx
::
verify_range
(
result_vector
,
gold
));
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
test
::
run
(
argc
,
argv
);
}
test/ref_ops_test.cpp
View file @
616cbd16
...
...
@@ -1027,7 +1027,7 @@ TEST_CASE(contiguous_dyn_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE
(
conv_dyn
amic
_batch_test
)
TEST_CASE(conv_dyn_batch_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
...
...
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