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
e2eb6036
Commit
e2eb6036
authored
Apr 13, 2022
by
Paul
Browse files
Merge
parents
298c93d5
1e0bbd78
Changes
267
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
872 additions
and
65 deletions
+872
-65
test/onnx/gen_onnx.pyc
test/onnx/gen_onnx.pyc
+0
-0
test/onnx/isnan_float_test.onnx
test/onnx/isnan_float_test.onnx
+11
-0
test/onnx/isnan_half_test.onnx
test/onnx/isnan_half_test.onnx
+13
-0
test/onnx/lpnormalization_axis_error_test.onnx
test/onnx/lpnormalization_axis_error_test.onnx
+12
-0
test/onnx/lpnormalization_default_test.onnx
test/onnx/lpnormalization_default_test.onnx
+0
-0
test/onnx/lpnormalization_l1_test.onnx
test/onnx/lpnormalization_l1_test.onnx
+12
-0
test/onnx/lpnormalization_l2_test.onnx
test/onnx/lpnormalization_l2_test.onnx
+12
-0
test/onnx/lpnormalization_p_error_test.onnx
test/onnx/lpnormalization_p_error_test.onnx
+12
-0
test/onnx/onnx_test.cpp
test/onnx/onnx_test.cpp
+408
-43
test/onnx/scatternd_add_test.onnx
test/onnx/scatternd_add_test.onnx
+26
-0
test/onnx/scatternd_mul_test.onnx
test/onnx/scatternd_mul_test.onnx
+26
-0
test/onnx/scatternd_test.onnx
test/onnx/scatternd_test.onnx
+25
-0
test/onnx/size_float_test.onnx
test/onnx/size_float_test.onnx
+12
-0
test/onnx/size_half_test.onnx
test/onnx/size_half_test.onnx
+12
-0
test/onnx/size_int_test.onnx
test/onnx/size_int_test.onnx
+12
-0
test/onnx/size_verify_test.onnx
test/onnx/size_verify_test.onnx
+12
-0
test/onnx/verify_onnx.cpp
test/onnx/verify_onnx.cpp
+145
-0
test/op_shape_test.cpp
test/op_shape_test.cpp
+113
-15
test/print_graph_test.cpp
test/print_graph_test.cpp
+6
-6
test/py/CMakeLists.txt
test/py/CMakeLists.txt
+3
-1
No files found.
test/onnx/gen_onnx.pyc
deleted
100644 → 0
View file @
298c93d5
File deleted
test/onnx/isnan_float_test.onnx
0 → 100644
View file @
e2eb6036
isnan_float_test:O
t1t2"IsNaNisnan_float_testZ
t1
b
t2
B
\ No newline at end of file
test/onnx/isnan_half_test.onnx
0 → 100644
View file @
e2eb6036
isnan_half_test:N
t1t2"IsNaNisnan_half_testZ
t1
b
t2
B
\ No newline at end of file
test/onnx/lpnormalization_axis_error_test.onnx
0 → 100644
View file @
e2eb6036
lpnormalization_axis_error_test:q
$
xy"LpNormalization*
axis lpnormalization_axis_error_testZ
x
b
y
B
\ No newline at end of file
test/onnx/lpnormalization_default_test.onnx
0 → 100644
View file @
e2eb6036
File added
test/onnx/lpnormalization_l1_test.onnx
0 → 100644
View file @
e2eb6036
lpnormalization_l1_test:f
!
xy"LpNormalization*
plpnormalization_l1_testZ
x
b
y
B
\ No newline at end of file
test/onnx/lpnormalization_l2_test.onnx
0 → 100644
View file @
e2eb6036
lpnormalization_l2_test:f
!
xy"LpNormalization*
plpnormalization_l2_testZ
x
b
y
B
\ No newline at end of file
test/onnx/lpnormalization_p_error_test.onnx
0 → 100644
View file @
e2eb6036
lpnormalization_p_error_test:k
!
xy"LpNormalization*
plpnormalization_p_error_testZ
x
b
y
B
\ No newline at end of file
test/onnx/onnx_test.cpp
View file @
e2eb6036
...
...
@@ -46,6 +46,40 @@ migraphx::program optimize_onnx(const std::string& name, bool run_passes = false
return
prog
;
}
void
add_celu_instruction
(
migraphx
::
module
*
mm
,
const
migraphx
::
shape
&
s
,
float
alpha
)
{
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
const
auto
&
input_lens
=
s
.
lens
();
const
auto
&
input_type
=
s
.
type
();
auto
zero_lit
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
input_lens
}}),
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
input_type
},
{
0.
}}));
auto
one_lit
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
input_lens
}}),
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
input_type
},
{
1.
}}));
auto
alpha_lit
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
input_lens
}}),
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
input_type
},
{
alpha
}}));
auto
linear_part
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"max"
),
zero_lit
,
x
);
auto
divi
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"div"
),
x
,
alpha_lit
);
auto
expo
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"exp"
),
divi
);
auto
sub
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"sub"
),
expo
,
one_lit
);
auto
mul
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
alpha_lit
,
sub
);
auto
exp_part
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"min"
),
zero_lit
,
mul
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
linear_part
,
exp_part
);
}
static
std
::
vector
<
double
>
make_r_eyelike
(
size_t
num_rows
,
size_t
num_cols
,
size_t
k
)
{
std
::
vector
<
double
>
eyelike_mat
(
num_rows
*
num_cols
,
0
);
for
(
size_t
i
=
0
;
i
<
num_rows
;
++
i
)
{
if
(
i
+
k
<
num_cols
)
eyelike_mat
[(
num_cols
+
1
)
*
i
+
k
]
=
1.
;
}
return
eyelike_mat
;
}
TEST_CASE
(
acos_test
)
{
migraphx
::
program
p
;
...
...
@@ -191,11 +225,12 @@ TEST_CASE(averagepool_1d_test)
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"0"
,
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
5
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
"average"
},
{
"padding"
,
{
0
,
0
}},
{
"stride"
,
{
1
}},
{
"lengths"
,
{
3
}}}),
l0
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
average
},
{
"padding"
,
{
0
,
0
}},
{
"stride"
,
{
1
}},
{
"lengths"
,
{
3
}}}),
l0
);
auto
prog
=
optimize_onnx
(
"averagepool_1d_test.onnx"
);
EXPECT
(
p
==
prog
);
...
...
@@ -207,7 +242,7 @@ TEST_CASE(averagepool_3d_test)
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"0"
,
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
5
,
5
,
5
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
"
average
"
},
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
average
},
{
"padding"
,
{
0
,
0
,
0
,
0
,
0
,
0
}},
{
"stride"
,
{
1
,
1
,
1
}},
{
"lengths"
,
{
3
,
3
,
3
}}}),
...
...
@@ -223,7 +258,7 @@ TEST_CASE(averagepool_notset_test)
auto
*
mm
=
p
.
get_main_module
();
auto
input
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
5
,
5
}});
auto
ins
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
"
average
"
},
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
average
},
{
"padding"
,
{
2
,
2
,
2
,
2
}},
{
"stride"
,
{
2
,
2
}},
{
"lengths"
,
{
6
,
6
}}}),
...
...
@@ -244,7 +279,7 @@ TEST_CASE(averagepool_nt_cip_test)
std
::
vector
<
int64_t
>
pads
=
{
0
,
0
,
0
,
0
,
0
,
0
,
1
,
1
};
auto
ins_pad
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"pad"
,
{{
"pads"
,
pads
}}),
input
);
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
"
average
"
},
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
average
},
{
"padding"
,
{
0
,
0
,
0
,
0
}},
{
"stride"
,
{
2
,
2
}},
{
"lengths"
,
{
6
,
6
}}}),
...
...
@@ -261,7 +296,7 @@ TEST_CASE(averagepool_same_lower_test)
auto
*
mm
=
p
.
get_main_module
();
auto
input
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
5
,
5
}});
auto
ins
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
"
average
"
},
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
average
},
{
"padding"
,
{
1
,
1
,
1
,
1
}},
{
"stride"
,
{
1
,
1
}},
{
"lengths"
,
{
2
,
2
}}}),
...
...
@@ -282,7 +317,7 @@ TEST_CASE(averagepool_sl_cip_test)
std
::
vector
<
int64_t
>
pads
=
{
0
,
0
,
1
,
1
,
0
,
0
,
0
,
0
};
auto
ins_pad
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"pad"
,
{{
"pads"
,
pads
}}),
input
);
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
"
average
"
},
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
average
},
{
"padding"
,
{
0
,
0
,
0
,
0
}},
{
"stride"
,
{
1
,
1
}},
{
"lengths"
,
{
2
,
2
}}}),
...
...
@@ -299,7 +334,7 @@ TEST_CASE(averagepool_same_upper_test)
auto
*
mm
=
p
.
get_main_module
();
auto
input
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
5
,
5
}});
auto
ins
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
"
average
"
},
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
average
},
{
"padding"
,
{
1
,
1
,
1
,
1
}},
{
"stride"
,
{
1
,
1
}},
{
"lengths"
,
{
2
,
2
}}}),
...
...
@@ -368,6 +403,42 @@ TEST_CASE(ceil_test)
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
celu_alpha_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
std
::
vector
<
std
::
size_t
>
input_lens
=
{
3
};
auto
input_type
=
migraphx
::
shape
::
float_type
;
migraphx
::
shape
s
{
input_type
,
input_lens
};
float
alpha
=
0.8
;
add_celu_instruction
(
mm
,
s
,
alpha
);
auto
prog
=
optimize_onnx
(
"celu_alpha_test.onnx"
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
celu_default_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
std
::
vector
<
std
::
size_t
>
input_lens
=
{
2
,
3
};
auto
input_type
=
migraphx
::
shape
::
float_type
;
migraphx
::
shape
s
{
input_type
,
input_lens
};
float
alpha
=
1.0
;
add_celu_instruction
(
mm
,
s
,
alpha
);
auto
prog
=
optimize_onnx
(
"celu_default_test.onnx"
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
celu_wrong_type_test
)
{
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"celu_wrong_type_test.onnx"
);
}));
}
TEST_CASE
(
celu_zero_alpha_test
)
{
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"celu_zero_alpha_test.onnx"
);
}));
}
TEST_CASE
(
clip_test
)
{
migraphx
::
program
p
;
...
...
@@ -458,6 +529,28 @@ TEST_CASE(clip_test_op11_no_args1)
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
clip_test_args_type_mismatch
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
min_val
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
3
}},
{
1.5
,
2.5
,
3.5
}});
auto
max_val
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{
3
,
1
}},
{
2
,
3
,
4
}});
auto
l0
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
3
}});
min_val
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
3
,
3
}}}),
min_val
);
max_val
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
3
,
3
}}}),
max_val
);
max_val
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
shape
::
float_type
}}),
max_val
);
auto
r
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"clip"
),
l0
,
min_val
,
max_val
);
mm
->
add_return
({
r
});
auto
prog
=
migraphx
::
parse_onnx
(
"clip_test_args_type_mismatch.onnx"
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
concat_test
)
{
migraphx
::
program
p
;
...
...
@@ -669,11 +762,12 @@ TEST_CASE(conv_bn_relu_maxpool_test)
auto
l6
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"batch_norm_inference"
,
{{
"epsilon"
,
1.0e-5
f
}}),
l5
,
p3
,
p4
,
p5
,
p6
);
auto
l7
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"relu"
),
l6
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
"max"
},
{
"padding"
,
{
0
,
0
,
0
,
0
}},
{
"stride"
,
{
2
,
2
}},
{
"lengths"
,
{
2
,
2
}}}),
l7
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
max
},
{
"padding"
,
{
0
,
0
,
0
,
0
}},
{
"stride"
,
{
2
,
2
}},
{
"lengths"
,
{
2
,
2
}}}),
l7
);
auto
prog
=
optimize_onnx
(
"conv_bn_relu_maxpool_test.onnx"
);
EXPECT
(
p
==
prog
);
...
...
@@ -693,11 +787,12 @@ TEST_CASE(conv_relu_maxpool_test)
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
axis
},
{
"out_lens"
,
l3
->
get_shape
().
lens
()}}),
l2
);
auto
l5
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
l3
,
l4
);
auto
l6
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"relu"
),
l5
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
"max"
},
{
"padding"
,
{
0
,
0
,
0
,
0
}},
{
"stride"
,
{
2
,
2
}},
{
"lengths"
,
{
2
,
2
}}}),
l6
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
max
},
{
"padding"
,
{
0
,
0
,
0
,
0
}},
{
"stride"
,
{
2
,
2
}},
{
"lengths"
,
{
2
,
2
}}}),
l6
);
auto
prog
=
optimize_onnx
(
"conv_relu_maxpool_test.onnx"
);
EXPECT
(
p
==
prog
);
...
...
@@ -717,11 +812,12 @@ TEST_CASE(conv_relu_maxpool_x2_test)
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
axis
},
{
"out_lens"
,
l3
->
get_shape
().
lens
()}}),
l2
);
auto
l5
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
l3
,
l4
);
auto
l6
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"relu"
),
l5
);
auto
l7
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
"max"
},
{
"padding"
,
{
0
,
0
,
0
,
0
}},
{
"stride"
,
{
2
,
2
}},
{
"lengths"
,
{
2
,
2
}}}),
l6
);
auto
l7
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
max
},
{
"padding"
,
{
0
,
0
,
0
,
0
}},
{
"stride"
,
{
2
,
2
}},
{
"lengths"
,
{
2
,
2
}}}),
l6
);
auto
l8
=
mm
->
add_parameter
(
"3"
,
{
migraphx
::
shape
::
float_type
,
{
1
,
5
,
5
,
5
}});
auto
l9
=
mm
->
add_parameter
(
"4"
,
{
migraphx
::
shape
::
float_type
,
{
1
}});
...
...
@@ -732,11 +828,12 @@ TEST_CASE(conv_relu_maxpool_x2_test)
l9
);
auto
l12
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
l10
,
l11
);
auto
l13
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"relu"
),
l12
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
"max"
},
{
"padding"
,
{
0
,
0
,
0
,
0
}},
{
"stride"
,
{
2
,
2
}},
{
"lengths"
,
{
2
,
2
}}}),
l13
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
max
},
{
"padding"
,
{
0
,
0
,
0
,
0
}},
{
"stride"
,
{
2
,
2
}},
{
"lengths"
,
{
2
,
2
}}}),
l13
);
auto
prog
=
optimize_onnx
(
"conv_relu_maxpool_x2_test.onnx"
);
...
...
@@ -1259,6 +1356,121 @@ TEST_CASE(external_data_diff_path_test)
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
eyelike_default_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
std
::
vector
<
std
::
size_t
>
input_lens
{
3
,
4
};
const
size_t
k
=
0
;
auto
num_rows
=
input_lens
.
front
();
auto
num_cols
=
input_lens
.
back
();
auto
input_type
=
migraphx
::
shape
::
float_type
;
auto
output_type
=
migraphx
::
shape
::
float_type
;
migraphx
::
shape
s
{
input_type
,
input_lens
};
mm
->
add_parameter
(
"T1"
,
s
);
auto
eyelike_mat
=
make_r_eyelike
(
num_rows
,
num_cols
,
k
);
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
output_type
,
input_lens
},
eyelike_mat
});
auto
prog
=
optimize_onnx
(
"eyelike_default_test.onnx"
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
eyelike_double_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
std
::
vector
<
std
::
size_t
>
input_lens
{
6
,
15
};
const
size_t
k
=
0
;
auto
num_rows
=
input_lens
.
front
();
auto
num_cols
=
input_lens
.
back
();
auto
input_type
=
migraphx
::
shape
::
double_type
;
auto
output_type
=
migraphx
::
shape
::
double_type
;
migraphx
::
shape
s
{
input_type
,
input_lens
};
mm
->
add_parameter
(
"T1"
,
s
);
auto
eyelike_mat
=
make_r_eyelike
(
num_rows
,
num_cols
,
k
);
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
output_type
,
input_lens
},
eyelike_mat
});
auto
prog
=
optimize_onnx
(
"eyelike_double_test.onnx"
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
eyelike_half_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
std
::
vector
<
std
::
size_t
>
input_lens
{
8
,
8
};
const
size_t
k
=
0
;
auto
num_rows
=
input_lens
.
front
();
auto
num_cols
=
input_lens
.
back
();
auto
input_type
=
migraphx
::
shape
::
half_type
;
auto
output_type
=
migraphx
::
shape
::
half_type
;
migraphx
::
shape
s
{
input_type
,
input_lens
};
mm
->
add_parameter
(
"T1"
,
s
);
auto
eyelike_mat
=
make_r_eyelike
(
num_rows
,
num_cols
,
k
);
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
output_type
,
input_lens
},
eyelike_mat
});
auto
prog
=
optimize_onnx
(
"eyelike_half_test.onnx"
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
eyelike_k_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
std
::
vector
<
std
::
size_t
>
input_lens
{
3
,
4
};
const
size_t
k
=
1
;
auto
num_rows
=
input_lens
.
front
();
auto
num_cols
=
input_lens
.
back
();
auto
input_type
=
migraphx
::
shape
::
float_type
;
auto
output_type
=
migraphx
::
shape
::
float_type
;
migraphx
::
shape
s
{
input_type
,
input_lens
};
mm
->
add_parameter
(
"T1"
,
s
);
auto
eyelike_mat
=
make_r_eyelike
(
num_rows
,
num_cols
,
k
);
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
output_type
,
input_lens
},
eyelike_mat
});
auto
prog
=
optimize_onnx
(
"eyelike_k_test.onnx"
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
eyelike_k_outofbounds_neg_test
)
{
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"eyelike_k_outofbounds_neg_test.onnx"
);
}));
}
TEST_CASE
(
eyelike_k_outofbounds_pos_test
)
{
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"eyelike_k_outofbounds_pos_test.onnx"
);
}));
}
TEST_CASE
(
eyelike_not_rank2_test
)
{
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"eyelike_not_rank2_test.onnx"
);
}));
}
TEST_CASE
(
eyelike_set_dtype_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
std
::
vector
<
std
::
size_t
>
input_lens
{
3
,
4
};
const
size_t
k
=
0
;
auto
num_rows
=
input_lens
.
front
();
auto
num_cols
=
input_lens
.
back
();
auto
input_type
=
migraphx
::
shape
::
float_type
;
auto
output_type
=
migraphx
::
shape
::
double_type
;
migraphx
::
shape
s
{
input_type
,
input_lens
};
mm
->
add_parameter
(
"T1"
,
s
);
auto
eyelike_mat
=
make_r_eyelike
(
num_rows
,
num_cols
,
k
);
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
output_type
,
input_lens
},
eyelike_mat
});
auto
prog
=
optimize_onnx
(
"eyelike_set_dtype_test.onnx"
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
flatten_test
)
{
migraphx
::
program
p
;
...
...
@@ -1481,7 +1693,7 @@ TEST_CASE(globalavgpool_test)
auto
*
mm
=
p
.
get_main_module
();
auto
input
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
16
,
16
}});
auto
op
=
migraphx
::
op
::
pooling
{
"
average
"
};
auto
op
=
migraphx
::
op
::
pooling
{
migraphx
::
op
::
pooling_mode
::
average
};
auto
lens
=
input
->
get_shape
().
lens
();
op
.
lengths
=
{
lens
[
2
],
lens
[
3
]};
op
.
padding
=
{
0
,
0
,
0
,
0
};
...
...
@@ -1498,7 +1710,7 @@ TEST_CASE(globalmaxpool_test)
auto
*
mm
=
p
.
get_main_module
();
auto
input
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
16
,
16
}});
auto
op
=
migraphx
::
op
::
pooling
{
"max"
};
auto
op
=
migraphx
::
op
::
pooling
{
migraphx
::
op
::
pooling_mode
::
max
};
auto
lens
=
input
->
get_shape
().
lens
();
op
.
lengths
=
{
lens
[
2
],
lens
[
3
]};
op
.
padding
=
{
0
,
0
,
0
,
0
};
...
...
@@ -1929,6 +2141,32 @@ TEST_CASE(if_tuple_test)
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
isnan_float_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
2
,
3
}};
auto
t1
=
mm
->
add_parameter
(
"t1"
,
s
);
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"isnan"
),
t1
);
mm
->
add_return
({
ret
});
auto
prog
=
migraphx
::
parse_onnx
(
"isnan_float_test.onnx"
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
isnan_half_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
half_type
,
{
2
,
3
}};
auto
t1
=
mm
->
add_parameter
(
"t1"
,
s
);
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"isnan"
),
t1
);
mm
->
add_return
({
ret
});
auto
prog
=
migraphx
::
parse_onnx
(
"isnan_half_test.onnx"
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
imagescaler_test
)
{
migraphx
::
program
p
;
...
...
@@ -2318,6 +2556,46 @@ TEST_CASE(loop_test)
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
lpnormalization_default_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
std
::
vector
<
std
::
size_t
>
input_lens
{
3
,
4
};
auto
input_type
=
migraphx
::
shape
::
float_type
;
migraphx
::
shape
s
{
input_type
,
input_lens
};
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
std
::
ptrdiff_t
axis
=
0
;
auto
p_val
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
x
,
x
);
auto
norms
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reduce_sum"
,
{{
"axes"
,
{
axis
}}}),
p_val
);
norms
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"sqrt"
),
norms
);
norms
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
input_lens
}}),
norms
);
auto
zero_mb
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
input_lens
}}),
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
input_type
},
{
0.
}}));
auto
one_mb
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
input_lens
}}),
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
input_type
},
{
1.
}}));
auto
is_zero
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"equal"
),
norms
,
zero_mb
);
auto
norms_zeros_to_one
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"where"
),
is_zero
,
one_mb
,
norms
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"div"
),
x
,
norms_zeros_to_one
);
auto
prog
=
optimize_onnx
(
"lpnormalization_default_test.onnx"
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
lpnormalization_axis_error_test
)
{
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"lpnormalization_axis_error_test.onnx"
);
}));
}
TEST_CASE
(
lpnormalization_p_error_test
)
{
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"lpnormalization_p_error_test.onnx"
);
}));
}
TEST_CASE
(
lrn_test
)
{
migraphx
::
program
p
;
...
...
@@ -2465,11 +2743,12 @@ TEST_CASE(maxpool_notset_test)
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
input
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
5
,
5
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
"max"
},
{
"padding"
,
{
0
,
0
,
1
,
1
}},
{
"stride"
,
{
2
,
2
}},
{
"lengths"
,
{
6
,
6
}}}),
input
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
max
},
{
"padding"
,
{
0
,
0
,
1
,
1
}},
{
"stride"
,
{
2
,
2
}},
{
"lengths"
,
{
6
,
6
}}}),
input
);
auto
prog
=
optimize_onnx
(
"maxpool_notset_test.onnx"
);
...
...
@@ -2481,11 +2760,12 @@ TEST_CASE(maxpool_same_upper_test)
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
input
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
5
,
5
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
"max"
},
{
"padding"
,
{
0
,
0
,
1
,
1
}},
{
"stride"
,
{
1
,
1
}},
{
"lengths"
,
{
2
,
2
}}}),
input
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
max
},
{
"padding"
,
{
0
,
0
,
1
,
1
}},
{
"stride"
,
{
1
,
1
}},
{
"lengths"
,
{
2
,
2
}}}),
input
);
auto
prog
=
optimize_onnx
(
"maxpool_same_upper_test.onnx"
);
...
...
@@ -3970,6 +4250,57 @@ TEST_CASE(scatter_test)
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
scatternd_test
)
{
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"data"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
2
,
2
}});
auto
l1
=
mm
->
add_parameter
(
"indices"
,
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{
2
,
1
,
2
}});
auto
l2
=
mm
->
add_parameter
(
"updates"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
1
,
2
}});
auto
r
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"scatternd_none"
),
l0
,
l1
,
l2
);
mm
->
add_return
({
r
});
auto
prog
=
migraphx
::
parse_onnx
(
"scatternd_test.onnx"
);
EXPECT
(
p
==
prog
);
}
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"data"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
2
,
2
}});
auto
l1
=
mm
->
add_parameter
(
"indices"
,
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{
2
,
1
,
2
}});
auto
l2
=
mm
->
add_parameter
(
"updates"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
1
,
2
}});
auto
r
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"scatternd_add"
),
l0
,
l1
,
l2
);
mm
->
add_return
({
r
});
auto
prog
=
migraphx
::
parse_onnx
(
"scatternd_add_test.onnx"
);
EXPECT
(
p
==
prog
);
}
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"data"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
2
,
2
}});
auto
l1
=
mm
->
add_parameter
(
"indices"
,
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{
2
,
1
,
2
}});
auto
l2
=
mm
->
add_parameter
(
"updates"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
1
,
2
}});
auto
r
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"scatternd_mul"
),
l0
,
l1
,
l2
);
mm
->
add_return
({
r
});
auto
prog
=
migraphx
::
parse_onnx
(
"scatternd_mul_test.onnx"
);
EXPECT
(
p
==
prog
);
}
}
TEST_CASE
(
selu_test
)
{
migraphx
::
program
p
;
...
...
@@ -4066,6 +4397,40 @@ TEST_CASE(sinh_test)
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
size_float_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
s
=
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
}};
mm
->
add_parameter
(
"x"
,
s
);
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
int64_type
,
{
s
.
elements
()}});
auto
prog
=
optimize_onnx
(
"size_float_test.onnx"
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
size_half_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
s
=
migraphx
::
shape
{
migraphx
::
shape
::
half_type
,
{
3
,
1
}};
mm
->
add_parameter
(
"x"
,
s
);
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
int64_type
,
{
s
.
elements
()}});
auto
prog
=
optimize_onnx
(
"size_half_test.onnx"
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
size_int_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
s
=
migraphx
::
shape
{
migraphx
::
shape
::
int32_type
,
{
8
,
2
,
3
}};
mm
->
add_parameter
(
"x"
,
s
);
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
int64_type
,
{
s
.
elements
()}});
auto
prog
=
optimize_onnx
(
"size_int_test.onnx"
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
slice_test
)
{
migraphx
::
program
p
;
...
...
test/onnx/scatternd_add_test.onnx
0 → 100644
View file @
e2eb6036
scatternd_add_test:Î
@
data
indices
updatesoutput" ScatterND*
reduction"add scatternd_add_testZ
data
Z
indices
Z
updates
b
output
B
\ No newline at end of file
test/onnx/scatternd_mul_test.onnx
0 → 100644
View file @
e2eb6036
scatternd_mul_test:
@
data
indices
updatesoutput" ScatterND*
reduction"mulscatternd_mul_testZ
data
Z
indices
Z
updates
b
output
B
\ No newline at end of file
test/onnx/scatternd_test.onnx
0 → 100644
View file @
e2eb6036
scatternd_test:
+
data
indices
updatesoutput" ScatterNDscatternd_testZ
data
Z
indices
Z
updates
b
output
B
\ No newline at end of file
test/onnx/size_float_test.onnx
0 → 100644
View file @
e2eb6036
size_float_test:I
xy"Sizesize_float_testZ
x
b
y
B
\ No newline at end of file
test/onnx/size_half_test.onnx
0 → 100644
View file @
e2eb6036
size_half_test:D
xy"Sizesize_half_testZ
x
b
y
B
\ No newline at end of file
test/onnx/size_int_test.onnx
0 → 100644
View file @
e2eb6036
size_int_test:G
xy"Size size_int_testZ
x
b
y
B
\ No newline at end of file
test/onnx/size_verify_test.onnx
0 → 100644
View file @
e2eb6036
size_verify_test:J
xy"Sizesize_verify_testZ
x
b
y
B
\ No newline at end of file
test/onnx/verify_onnx.cpp
View file @
e2eb6036
...
...
@@ -45,6 +45,44 @@ TEST_CASE(averagepool_nt_cip_test)
EXPECT
(
migraphx
::
verify_range
(
result_vector
,
gold
));
}
TEST_CASE
(
celu_verify_test
)
{
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"celu_verify_test.onnx"
);
p
.
compile
(
migraphx
::
ref
::
target
{});
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
2
,
3
}};
std
::
vector
<
float
>
data
=
{
-
5.5
,
2.0
,
100.
,
7.0
,
0.
,
-
1.
};
migraphx
::
parameter_map
pp
;
pp
[
"x"
]
=
migraphx
::
argument
(
s
,
data
.
data
());
auto
result
=
p
.
eval
(
pp
).
back
();
std
::
vector
<
float
>
result_vector
;
result
.
visit
([
&
](
auto
output
)
{
result_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
correct
(
6
);
float
alpha
=
0.5
;
std
::
transform
(
data
.
begin
(),
data
.
end
(),
correct
.
begin
(),
[
&
](
auto
x
)
{
return
std
::
max
(
0.0
f
,
x
)
+
std
::
min
(
0.0
f
,
alpha
*
std
::
expm1
(
x
/
alpha
));
});
EXPECT
(
migraphx
::
verify_range
(
result_vector
,
correct
));
}
TEST_CASE
(
clip_args_type_mismatch
)
{
auto
p
=
migraphx
::
parse_onnx
(
"clip_test_args_type_mismatch.onnx"
);
p
.
compile
(
migraphx
::
ref
::
target
{});
migraphx
::
shape
s_0
{
migraphx
::
shape
::
float_type
,
{
3
,
3
}};
migraphx
::
parameter_map
pp
;
std
::
vector
<
float
>
data_0
=
{
0.9
,
1.2
,
1.7
,
1.9
,
2.2
,
2.7
,
2.9
,
3.2
,
3.7
};
pp
[
"0"
]
=
migraphx
::
argument
(
s_0
,
data_0
.
data
());
auto
result
=
p
.
eval
(
pp
).
back
();
std
::
vector
<
float
>
result_vector
;
result
.
visit
([
&
](
auto
output
)
{
result_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
=
{
1.5
,
2
,
2
,
1.9
,
2.5
,
3
,
2.9
,
3.2
,
3.7
};
EXPECT
(
migraphx
::
verify_range
(
result_vector
,
gold
));
}
TEST_CASE
(
depthtospace_simple_test
)
{
auto
p
=
migraphx
::
parse_onnx
(
"depthtospace_simple_test.onnx"
);
...
...
@@ -103,6 +141,42 @@ TEST_CASE(spacetodepth_depthtospace_test)
EXPECT
(
migraphx
::
verify_range
(
result_vector2
,
data_in
));
}
TEST_CASE
(
eyelike_verify_test
)
{
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"eyelike_verify_test.onnx"
);
p
.
compile
(
migraphx
::
ref
::
target
{});
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
4
}};
std
::
vector
<
float
>
data
{
12
,
0
};
migraphx
::
parameter_map
pp
;
pp
[
"T1"
]
=
migraphx
::
argument
(
s
,
data
.
data
());
auto
result
=
p
.
eval
(
pp
).
back
();
std
::
vector
<
float
>
result_vector
;
result
.
visit
([
&
](
auto
output
)
{
result_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
eyelike_mat
=
{
0.
,
1.
,
0.
,
0.
,
0.
,
0.
,
1.
,
0.
,
0.
,
0.
,
0.
,
1.
};
EXPECT
(
migraphx
::
verify_range
(
result_vector
,
eyelike_mat
));
}
TEST_CASE
(
eyelike_verify_negk_test
)
{
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"eyelike_verify_negk_test.onnx"
);
p
.
compile
(
migraphx
::
ref
::
target
{});
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
4
}};
std
::
vector
<
float
>
data
{
12
,
0
};
migraphx
::
parameter_map
pp
;
pp
[
"T1"
]
=
migraphx
::
argument
(
s
,
data
.
data
());
auto
result
=
p
.
eval
(
pp
).
back
();
std
::
vector
<
float
>
result_vector
;
result
.
visit
([
&
](
auto
output
)
{
result_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
eyelike_mat
=
{
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
1.
,
0.
,
0.
,
0.
};
EXPECT
(
migraphx
::
verify_range
(
result_vector
,
eyelike_mat
));
}
TEST_CASE
(
gather_elements
)
{
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"gather_elements_axis0_test.onnx"
);
...
...
@@ -393,6 +467,62 @@ TEST_CASE(lessorequal_test)
EXPECT
(
migraphx
::
verify_range
(
result_vector
,
gold
));
}
TEST_CASE
(
lpnormalization_1norm
)
{
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"lpnormalization_l1_test.onnx"
);
p
.
compile
(
migraphx
::
ref
::
target
{});
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
4
}};
std
::
vector
<
float
>
data
{
0.
f
,
2.
f
,
-
2.
f
,
1.
f
,
1.
f
,
-
5.
f
,
3.
f
,
-
1.
f
,
-
4.
f
,
3.
f
,
0.
f
,
0.
f
};
migraphx
::
parameter_map
pp
;
pp
[
"x"
]
=
migraphx
::
argument
(
s
,
data
.
data
());
auto
result
=
p
.
eval
(
pp
).
back
();
std
::
vector
<
float
>
result_vector
;
result
.
visit
([
&
](
auto
output
)
{
result_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
{
0.
f
,
2.
f
/
5.
f
,
-
2.
f
/
5.
f
,
1.
f
/
5.
f
,
1.
f
/
10.
f
,
-
5.
f
/
10.
f
,
3.
f
/
10.
f
,
-
1.
f
/
10.
f
,
-
4.
f
/
7.
f
,
3.
f
/
7.
f
,
0.
f
,
0.
f
};
EXPECT
(
migraphx
::
verify_range
(
result_vector
,
gold
));
}
TEST_CASE
(
lpnormalization_2norm
)
{
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"lpnormalization_l2_test.onnx"
);
p
.
compile
(
migraphx
::
ref
::
target
{});
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
4
}};
std
::
vector
<
float
>
data
{
0.
f
,
2.
f
,
-
2.
f
,
1.
f
,
1.
f
,
-
5.
f
,
3.
f
,
-
1.
f
,
-
4.
f
,
3.
f
,
0.
f
,
0.
f
};
migraphx
::
parameter_map
pp
;
pp
[
"x"
]
=
migraphx
::
argument
(
s
,
data
.
data
());
auto
result
=
p
.
eval
(
pp
).
back
();
std
::
vector
<
float
>
result_vector
;
result
.
visit
([
&
](
auto
output
)
{
result_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
correct
{
0.
f
,
2.
f
/
3.
f
,
-
2.
f
/
3.
f
,
1.
f
/
3.
f
,
1.
f
/
6.
f
,
-
5.
f
/
6.
f
,
3.
f
/
6.
f
,
-
1.
f
/
6.
f
,
-
4.
f
/
5.
f
,
3.
f
/
5.
f
,
0.
f
,
0.
f
};
EXPECT
(
migraphx
::
verify_range
(
result_vector
,
correct
));
}
TEST_CASE
(
mean_broadcast_test
)
{
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"mean_broadcast_test.onnx"
);
...
...
@@ -588,6 +718,21 @@ TEST_CASE(selu_test)
EXPECT
(
migraphx
::
verify_range
(
result_vector
,
gold
));
}
TEST_CASE
(
size_verify_test
)
{
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"size_verify_test.onnx"
);
p
.
compile
(
migraphx
::
ref
::
target
{});
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
2
,
5
,
3
}};
std
::
vector
<
float
>
data
(
30
,
1.
);
migraphx
::
parameter_map
pp
;
pp
[
"x"
]
=
migraphx
::
argument
(
s
,
data
.
data
());
auto
result
=
p
.
eval
(
pp
).
back
();
auto
size_result
=
result
.
at
<
int64_t
>
();
EXPECT
(
size_result
==
int64_t
{
30
});
}
TEST_CASE
(
slice_test
)
{
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"slice_test.onnx"
);
...
...
test/op_shape_test.cpp
View file @
e2eb6036
...
...
@@ -570,10 +570,12 @@ TEST_CASE(inconsistent_attr_shape)
{{
"padding"
,
{
1
,
1
}},
{
"stride"
,
{
2
}},
{
"dilation"
,
{
3
,
3
,
3
}}}),
input
,
weights
);
throws_shape
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
"max"
},
{
"padding"
,
{
1
}},
{
"stride"
,
{
0
}},
{
"lengths"
,
{
1
,
1
}}}),
input
);
throws_shape
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
max
},
{
"padding"
,
{
1
}},
{
"stride"
,
{
0
}},
{
"lengths"
,
{
1
,
1
}}}),
input
);
}
template
<
class
T
>
...
...
@@ -983,21 +985,24 @@ TEST_CASE(pooling_shape)
{
migraphx
::
shape
output
{
migraphx
::
shape
::
float_type
,
{
4
,
3
,
1
,
1
}};
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{
4
,
3
,
3
,
3
}};
throws_shape
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
"max"
},
{
"padding"
,
{
1
}},
{
"stride"
,
{
0
}},
{
"lengths"
,
{
1
}}}),
input
);
expect_shape
(
output
,
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
"max"
},
{
"padding"
,
{
0
,
0
}},
{
"stride"
,
{
3
,
3
}},
{
"lengths"
,
{
1
,
1
}}}),
input
);
throws_shape
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
max
},
{
"padding"
,
{
1
}},
{
"stride"
,
{
0
}},
{
"lengths"
,
{
1
}}}),
input
);
expect_shape
(
output
,
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
max
},
{
"padding"
,
{
0
,
0
}},
{
"stride"
,
{
3
,
3
}},
{
"lengths"
,
{
1
,
1
}}}),
input
);
migraphx
::
shape
output1
{
migraphx
::
shape
::
float_type
,
{
4
,
3
,
2
,
2
}};
expect_shape
(
output1
,
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
"max"
},
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
max
},
{
"padding"
,
{
0
,
0
}},
{
"stride"
,
{
3
,
3
}},
{
"lengths"
,
{
1
,
1
}},
...
...
@@ -1432,6 +1437,29 @@ TEST_CASE(test_scalar_nelemnts)
throws_shape
(
migraphx
::
make_op
(
"scalar"
,
{{
"scalar_bcst_dims"
,
{
2
,
3
,
4
,
5
}}}),
input
);
}
TEST_CASE
(
test_scatternd
)
{
{
// k > r
auto
dtype
=
migraphx
::
shape
::
float_type
;
auto
itype
=
migraphx
::
shape
::
int64_type
;
migraphx
::
shape
ds
{
dtype
,
{
8
}};
migraphx
::
shape
is
{
itype
,
{
4
,
2
}};
migraphx
::
shape
us
{
dtype
,
{
4
}};
throws_shape
(
migraphx
::
make_op
(
"scatternd_none"
),
ds
,
is
,
us
);
}
{
// update.lens != indices.lens[0:q-1] ++ data.lens[k:r-1]
auto
dtype
=
migraphx
::
shape
::
float_type
;
auto
itype
=
migraphx
::
shape
::
int64_type
;
migraphx
::
shape
ds
{
dtype
,
{
8
}};
migraphx
::
shape
is
{
itype
,
{
4
,
1
}};
migraphx
::
shape
us
{
dtype
,
{
2
,
2
}};
throws_shape
(
migraphx
::
make_op
(
"scatternd_none"
),
ds
,
is
,
us
);
}
}
TEST_CASE
(
test_squeeze
)
{
migraphx
::
shape
s1
{
migraphx
::
shape
::
float_type
,
{
4
,
1
,
3
,
1
,
3
}};
...
...
@@ -1446,6 +1474,27 @@ TEST_CASE(test_squeeze_all)
expect_shape
(
s2
,
migraphx
::
make_op
(
"squeeze"
,
{{
"axes"
,
{
0
}}}),
s1
);
}
TEST_CASE
(
test_squeeze_transpose
)
{
migraphx
::
shape
s1
{
migraphx
::
shape
::
float_type
,
{
4
,
4
,
1
},
{
4
,
1
,
4
}};
migraphx
::
shape
s2
{
migraphx
::
shape
::
float_type
,
{
4
,
4
},
{
4
,
1
}};
expect_shape
(
s2
,
migraphx
::
make_op
(
"squeeze"
,
{{
"axes"
,
{
2
}}}),
s1
);
}
TEST_CASE
(
test_squeeze_multibroadcast
)
{
migraphx
::
shape
s1
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
1
,
4
},
{
0
,
1
,
1
,
0
}};
migraphx
::
shape
s2
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
},
{
0
,
1
,
0
}};
expect_shape
(
s2
,
migraphx
::
make_op
(
"squeeze"
,
{{
"axes"
,
{
2
}}}),
s1
);
}
TEST_CASE
(
test_squeeze_slice
)
{
migraphx
::
shape
s1
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
1
,
4
},
{
108
,
36
,
6
,
1
}};
migraphx
::
shape
s2
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
},
{
108
,
36
,
1
}};
expect_shape
(
s2
,
migraphx
::
make_op
(
"squeeze"
,
{{
"axes"
,
{
2
}}}),
s1
);
}
TEST_CASE
(
test_squeeze_negative_axis
)
{
migraphx
::
shape
s1
{
migraphx
::
shape
::
float_type
,
{
4
,
1
,
3
,
1
,
3
}};
...
...
@@ -1492,6 +1541,55 @@ TEST_CASE(test_unsqueeze_scalar_tensor2)
throws_shape
(
migraphx
::
make_op
(
"unsqueeze"
,
{{
"axes"
,
{
-
2
}}}),
s
);
}
TEST_CASE
(
test_unsqueeze_transpose
)
{
migraphx
::
shape
s1
{
migraphx
::
shape
::
float_type
,
{
4
,
4
,
3
},
{
12
,
1
,
4
}};
migraphx
::
shape
s2
{
migraphx
::
shape
::
float_type
,
{
4
,
4
,
1
,
3
},
{
12
,
1
,
1
,
4
}};
expect_shape
(
s2
,
migraphx
::
make_op
(
"unsqueeze"
,
{{
"axes"
,
{
2
}}}),
s1
);
}
TEST_CASE
(
test_unsqueeze_multibroadcast
)
{
migraphx
::
shape
s1
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
},
{
0
,
1
,
0
}};
migraphx
::
shape
s2
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
1
,
4
},
{
0
,
1
,
1
,
0
}};
expect_shape
(
s2
,
migraphx
::
make_op
(
"unsqueeze"
,
{{
"axes"
,
{
2
}}}),
s1
);
}
TEST_CASE
(
test_unsqueeze_slice
)
{
migraphx
::
shape
s1
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
},
{
108
,
36
,
1
}};
migraphx
::
shape
s2
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
1
,
4
},
{
108
,
36
,
36
,
1
}};
expect_shape
(
s2
,
migraphx
::
make_op
(
"unsqueeze"
,
{{
"axes"
,
{
2
}}}),
s1
);
}
TEST_CASE
(
test_unsqueeze_axis_zero
)
{
migraphx
::
shape
s1
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
}};
migraphx
::
shape
s2
{
migraphx
::
shape
::
float_type
,
{
1
,
2
,
3
,
4
}};
expect_shape
(
s2
,
migraphx
::
make_op
(
"unsqueeze"
,
{{
"axes"
,
{
0
}}}),
s1
);
}
TEST_CASE
(
test_unsqueeze_axis_last
)
{
migraphx
::
shape
s1
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
}};
migraphx
::
shape
s2
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
1
}};
expect_shape
(
s2
,
migraphx
::
make_op
(
"unsqueeze"
,
{{
"axes"
,
{
-
1
}}}),
s1
);
}
TEST_CASE
(
test_unsqueeze_multiple_axes_1
)
{
migraphx
::
shape
s1
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
}};
migraphx
::
shape
s2
{
migraphx
::
shape
::
float_type
,
{
1
,
2
,
3
,
4
,
1
}};
expect_shape
(
s2
,
migraphx
::
make_op
(
"unsqueeze"
,
{{
"axes"
,
{
0
,
-
1
}}}),
s1
);
}
TEST_CASE
(
test_unsqueeze_multiple_axes_2
)
{
migraphx
::
shape
s1
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
}};
migraphx
::
shape
s2
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
2
,
3
,
4
}};
expect_shape
(
s2
,
migraphx
::
make_op
(
"unsqueeze"
,
{{
"axes"
,
{
0
,
1
}}}),
s1
);
}
TEST_CASE
(
transpose_shape
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{
2
,
2
}};
...
...
test/print_graph_test.cpp
View file @
e2eb6036
...
...
@@ -34,12 +34,12 @@ TEST_CASE(basic_graph_test)
EXPECT
(
migraphx
::
contains
(
test
,
"
\"
main:@0
\"
[label=
\"
@literal
\"
]"
));
EXPECT
(
migraphx
::
contains
(
test
,
"
\"
y
\"
[label=
\"
@param:y
\"
]"
));
EXPECT
(
migraphx
::
contains
(
test
,
"
\"
x
\"
[label=
\"
@param:x
\"
]"
));
EXPECT
(
migraphx
::
contains
(
test
,
"
\"
main:@
1
\"
[label=
\"
sum
\"
]"
));
EXPECT
(
migraphx
::
contains
(
test
,
"
\"
main:@
2
\"
[label=
\"
sum
\"
]"
));
EXPECT
(
migraphx
::
contains
(
test
,
"
\"
x
\"
->
\"
main:@
1
\"
"
));
EXPECT
(
migraphx
::
contains
(
test
,
"
\"
y
\"
->
\"
main:@
1
\"
"
));
EXPECT
(
migraphx
::
contains
(
test
,
"
\"
main:@
1
\"
->
\"
main:@
2
\"
"
));
EXPECT
(
migraphx
::
contains
(
test
,
"
\"
main:@0
\"
->
\"
main:@
2
\"
"
));
EXPECT
(
migraphx
::
contains
(
test
,
"
\"
main:@
3
\"
[label=
\"
sum
\"
]"
));
EXPECT
(
migraphx
::
contains
(
test
,
"
\"
main:@
4
\"
[label=
\"
sum
\"
]"
));
EXPECT
(
migraphx
::
contains
(
test
,
"
\"
x
\"
->
\"
main:@
3
\"
"
));
EXPECT
(
migraphx
::
contains
(
test
,
"
\"
y
\"
->
\"
main:@
3
\"
"
));
EXPECT
(
migraphx
::
contains
(
test
,
"
\"
main:@
3
\"
->
\"
main:@
4
\"
"
));
EXPECT
(
migraphx
::
contains
(
test
,
"
\"
main:@0
\"
->
\"
main:@
4
\"
"
));
EXPECT
(
migraphx
::
contains
(
test
,
"[label=
\"
int64_type, {1}, {0}
\"
]"
));
}
...
...
test/py/CMakeLists.txt
View file @
e2eb6036
...
...
@@ -25,10 +25,12 @@ endforeach()
add_py_test
(
ref test_cpu.py WORKING_DIRECTORY
${
TEST_ONNX_DIR
}
)
add_py_test
(
save_load test_save_load.py WORKING_DIRECTORY
${
TEST_ONNX_DIR
}
)
add_py_test
(
op test_op.py WORKING_DIRECTORY
${
TEST_ONNX_DIR
}
)
add_py_test
(
shape test_shape.py WORKING_DIRECTORY
${
TEST_ONNX_DIR
}
)
add_py_test
(
module_construct test_module_construct.py WORKING_DIRECTORY
${
TEST_ONNX_DIR
}
)
if
(
MIGRAPHX_ENABLE_GPU
)
add_py_test
(
gpu_offload test_gpu_offload.py WORKING_DIRECTORY
${
TEST_ONNX_DIR
}
)
add_py_test
(
gpu test_gpu.py WORKING_DIRECTORY
${
TEST_ONNX_DIR
}
)
add_py_test
(
array test_array.py WORKING_DIRECTORY
${
TEST_ONNX_DIR
}
)
add_py_test
(
backend onnx_backend_test.py WORKING_DIRECTORY
${
TEST_ONNX_DIR
}
)
add_py_test
(
op test_op.py WORKING_DIRECTORY
${
TEST_ONNX_DIR
}
)
endif
()
Prev
1
…
7
8
9
10
11
12
13
14
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