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
687c6d17
Commit
687c6d17
authored
Nov 23, 2023
by
Artur Wojcik
Browse files
Merge branch 'develop' into uif2-initial
parents
6fd76845
d3e5a5c0
Changes
38
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
1153 additions
and
97 deletions
+1153
-97
test/onnx/qlinearsigmoid_test.onnx
test/onnx/qlinearsigmoid_test.onnx
+0
-0
test/onnx/verify_onnx.cpp
test/onnx/verify_onnx.cpp
+59
-0
test/op_shape_test.cpp
test/op_shape_test.cpp
+71
-5
test/py/onnx_backend_test.py
test/py/onnx_backend_test.py
+2
-1
test/ref/pooling.cpp
test/ref/pooling.cpp
+258
-68
test/rewrite_pooling_test.cpp
test/rewrite_pooling_test.cpp
+487
-5
test/simplify_dyn_ops_test.cpp
test/simplify_dyn_ops_test.cpp
+260
-8
test/simplify_qdq_test.cpp
test/simplify_qdq_test.cpp
+3
-0
test/verify/test_avg_pooling_1d.cpp
test/verify/test_avg_pooling_1d.cpp
+1
-1
test/verify/test_avg_pooling_3d.cpp
test/verify/test_avg_pooling_3d.cpp
+1
-1
test/verify/test_avg_pooling_3d_opt.cpp
test/verify/test_avg_pooling_3d_opt.cpp
+1
-1
test/verify/test_avg_pooling_ceil_3d.cpp
test/verify/test_avg_pooling_ceil_3d.cpp
+1
-1
test/verify/test_avg_pooling_pad.cpp
test/verify/test_avg_pooling_pad.cpp
+1
-1
test/verify/test_concat_pooling.cpp
test/verify/test_concat_pooling.cpp
+2
-1
test/verify/test_conv_bn_relu_pooling.cpp
test/verify/test_conv_bn_relu_pooling.cpp
+2
-1
test/verify/test_conv_bn_relu_pooling2.cpp
test/verify/test_conv_bn_relu_pooling2.cpp
+2
-1
test/verify/test_max_pooling_ceil_3d.cpp
test/verify/test_max_pooling_ceil_3d.cpp
+1
-1
tools/accuracy/requirements.txt
tools/accuracy/requirements.txt
+1
-1
No files found.
test/onnx/qlinearsigmoid_test.onnx
0 → 100644
View file @
687c6d17
File added
test/onnx/verify_onnx.cpp
View file @
687c6d17
...
...
@@ -1819,6 +1819,35 @@ TEST_CASE(qlinearglobalavgpool_test)
EXPECT
(
migraphx
::
verify
::
verify_rms_range
(
result_vector
,
gold
));
}
TEST_CASE
(
qlinearleakyrelu_test
)
{
// github.com/microsoft/onnxruntime/blob/main/docs/ContribOperators.md#com.microsoft.QLinearSigmoid
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"qlinearleakyrelu_test.onnx"
);
p
.
compile
(
migraphx
::
make_target
(
"ref"
));
migraphx
::
shape
x
{
migraphx
::
shape
::
int8_type
,
{
64
}};
std
::
vector
<
int8_t
>
data_x
=
{
-
128
,
-
124
,
-
120
,
-
116
,
-
112
,
-
108
,
-
104
,
-
100
,
-
96
,
-
92
,
-
88
,
-
84
,
-
80
,
-
76
,
-
72
,
-
68
,
-
64
,
-
60
,
-
56
,
-
52
,
-
48
,
-
44
,
-
40
,
-
36
,
-
32
,
-
28
,
-
24
,
-
20
,
-
16
,
-
12
,
-
8
,
-
4
,
0
,
4
,
8
,
12
,
16
,
20
,
24
,
28
,
32
,
36
,
40
,
44
,
48
,
52
,
56
,
60
,
64
,
68
,
72
,
76
,
80
,
84
,
88
,
92
,
96
,
100
,
104
,
108
,
112
,
116
,
120
,
124
};
migraphx
::
parameter_map
pp
;
pp
[
"X"
]
=
migraphx
::
argument
(
x
,
data_x
.
data
());
auto
result
=
p
.
eval
(
pp
).
back
();
std
::
vector
<
int8_t
>
result_vector
;
result
.
visit
([
&
](
auto
output
)
{
result_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
int8_t
>
gold
=
{
-
128
,
-
126
,
-
122
,
-
118
,
-
113
,
-
109
,
-
104
,
-
100
,
-
96
,
-
91
,
-
87
,
-
82
,
-
78
,
-
74
,
-
69
,
-
65
,
-
60
,
-
56
,
-
52
,
-
47
,
-
43
,
-
38
,
-
34
,
-
30
,
-
25
,
-
21
,
-
16
,
-
12
,
-
8
,
-
3
,
1
,
6
,
10
,
14
,
18
,
22
,
26
,
30
,
34
,
38
,
42
,
46
,
50
,
54
,
58
,
62
,
66
,
70
,
74
,
78
,
82
,
86
,
90
,
94
,
98
,
102
,
106
,
110
,
114
,
118
,
122
,
126
,
127
,
127
};
EXPECT
(
migraphx
::
verify
::
verify_rms_range
(
result_vector
,
gold
));
}
TEST_CASE
(
qlinearmatmul_1D_test
)
{
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"qlinearmatmul_1D_test.onnx"
);
...
...
@@ -1970,6 +1999,36 @@ TEST_CASE(qlinearmul_bcast_test)
EXPECT
(
migraphx
::
verify
::
verify_rms_range
(
result_vector
,
gold
));
}
TEST_CASE
(
qlinearsigmoid_test
)
{
// github.com/microsoft/onnxruntime/blob/main/docs/ContribOperators.md#com.microsoft.QLinearSigmoid
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"qlinearsigmoid_test.onnx"
);
p
.
compile
(
migraphx
::
make_target
(
"ref"
));
migraphx
::
shape
x
{
migraphx
::
shape
::
int8_type
,
{
64
}};
std
::
vector
<
int8_t
>
data_x
=
{
-
128
,
-
124
,
-
120
,
-
116
,
-
112
,
-
108
,
-
104
,
-
100
,
-
96
,
-
92
,
-
88
,
-
84
,
-
80
,
-
76
,
-
72
,
-
68
,
-
64
,
-
60
,
-
56
,
-
52
,
-
48
,
-
44
,
-
40
,
-
36
,
-
32
,
-
28
,
-
24
,
-
20
,
-
16
,
-
12
,
-
8
,
-
4
,
0
,
4
,
8
,
12
,
16
,
20
,
24
,
28
,
32
,
36
,
40
,
44
,
48
,
52
,
56
,
60
,
64
,
68
,
72
,
76
,
80
,
84
,
88
,
92
,
96
,
100
,
104
,
108
,
112
,
116
,
120
,
124
};
migraphx
::
parameter_map
pp
;
pp
[
"X"
]
=
migraphx
::
argument
(
x
,
data_x
.
data
());
auto
result
=
p
.
eval
(
pp
).
back
();
std
::
vector
<
int8_t
>
result_vector
;
result
.
visit
([
&
](
auto
output
)
{
result_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
int8_t
>
gold
=
{
-
128
,
-
127
,
-
127
,
-
127
,
-
127
,
-
127
,
-
126
,
-
126
,
-
126
,
-
125
,
-
125
,
-
124
,
-
123
,
-
122
,
-
120
,
-
119
,
-
117
,
-
114
,
-
112
,
-
108
,
-
104
,
-
99
,
-
94
,
-
87
,
-
80
,
-
71
,
-
62
,
-
51
,
-
39
,
-
27
,
-
13
,
1
,
15
,
29
,
43
,
56
,
69
,
81
,
92
,
101
,
110
,
117
,
124
,
127
,
127
,
127
,
127
,
127
,
127
,
127
,
127
,
127
,
127
,
127
,
127
,
127
,
127
,
127
,
127
,
127
,
127
,
127
,
127
,
127
};
EXPECT
(
migraphx
::
verify
::
verify_rms_range
(
result_vector
,
gold
));
}
TEST_CASE
(
resize_downsample_f_test
)
{
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"resize_downsample_f_test.onnx"
);
...
...
test/op_shape_test.cpp
View file @
687c6d17
...
...
@@ -2202,7 +2202,8 @@ TEST_CASE(pooling_shape0)
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
max
},
{
"padding"
,
{
1
}},
{
"stride"
,
{
0
}},
{
"lengths"
,
{
1
}}}),
{
"lengths"
,
{
1
}},
{
"dilations"
,
{
1
}}}),
input
);
}
...
...
@@ -2215,7 +2216,8 @@ TEST_CASE(pooling_shape1)
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
max
},
{
"padding"
,
{
0
,
0
}},
{
"stride"
,
{
3
,
3
}},
{
"lengths"
,
{
1
,
1
}}}),
{
"lengths"
,
{
1
,
1
}},
{
"dilations"
,
{
1
,
1
}}}),
input
);
}
...
...
@@ -2229,6 +2231,7 @@ TEST_CASE(pooling_shape2)
{
"padding"
,
{
0
,
0
}},
{
"stride"
,
{
3
,
3
}},
{
"lengths"
,
{
1
,
1
}},
{
"dilations"
,
{
1
,
1
}},
{
"ceil_mode"
,
true
}}),
input
);
}
...
...
@@ -2243,6 +2246,7 @@ TEST_CASE(pooling_shape3)
{
"padding"
,
{
2
,
2
}},
{
"stride"
,
{
3
,
3
}},
{
"lengths"
,
{
3
,
3
}},
{
"dilations"
,
{
1
,
1
}},
{
"ceil_mode"
,
true
}}),
input
);
}
...
...
@@ -2254,6 +2258,63 @@ TEST_CASE(pooling_shape4)
tiny_input
);
}
TEST_CASE
(
pooling_shape5
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{
4
,
3
,
3
,
3
}};
migraphx
::
shape
output
{
migraphx
::
shape
::
float_type
,
{
4
,
3
,
1
,
1
}};
expect_shape
(
output
,
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
max
},
{
"padding"
,
{
0
,
0
}},
{
"stride"
,
{
1
,
1
}},
{
"lengths"
,
{
2
,
2
}},
{
"dilations"
,
{
2
,
2
}}}),
input
);
}
TEST_CASE
(
pooling_shape6
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{
4
,
3
,
3
,
3
}};
migraphx
::
shape
output
{
migraphx
::
shape
::
float_type
,
{
4
,
3
,
2
,
2
}};
expect_shape
(
output
,
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
max
},
{
"padding"
,
{
0
,
0
}},
{
"stride"
,
{
2
,
2
}},
{
"lengths"
,
{
1
,
1
}},
{
"dilations"
,
{
2
,
2
}}}),
input
);
}
TEST_CASE
(
pooling_shape7
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{
4
,
3
,
3
,
3
}};
migraphx
::
shape
output
{
migraphx
::
shape
::
float_type
,
{
4
,
3
,
2
,
2
}};
expect_shape
(
output
,
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
max
},
{
"padding"
,
{
0
,
0
}},
{
"stride"
,
{
3
,
3
}},
{
"lengths"
,
{
1
,
1
}},
{
"dilations"
,
{
3
,
3
}},
{
"ceil_mode"
,
true
}}),
input
);
}
TEST_CASE
(
pooling_shape8
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{
4
,
3
,
3
,
3
}};
migraphx
::
shape
output
{
migraphx
::
shape
::
float_type
,
{
4
,
3
,
3
,
3
}};
expect_shape
(
output
,
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
max
},
{
"padding"
,
{
2
,
2
}},
{
"stride"
,
{
1
,
1
}},
{
"lengths"
,
{
3
,
3
}},
{
"dilations"
,
{
2
,
2
}}}),
input
);
}
TEST_CASE
(
pooling_dyn_shape0
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
},
{
3
,
3
,
{
3
}},
{
3
,
3
,
{
3
}},
{
3
,
3
}}};
...
...
@@ -2261,7 +2322,8 @@ TEST_CASE(pooling_dyn_shape0)
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
max
},
{
"padding"
,
{
1
}},
{
"stride"
,
{
0
}},
{
"lengths"
,
{
1
}}}),
{
"lengths"
,
{
1
}},
{
"dilations"
,
{
1
}}}),
input
);
}
...
...
@@ -2274,7 +2336,8 @@ TEST_CASE(pooling_dyn_shape1)
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
max
},
{
"padding"
,
{
0
,
0
}},
{
"stride"
,
{
3
,
3
}},
{
"lengths"
,
{
1
,
1
}}}),
{
"lengths"
,
{
1
,
1
}},
{
"dilations"
,
{
1
,
1
}}}),
input
);
}
...
...
@@ -2288,6 +2351,7 @@ TEST_CASE(pooling_dyn_shape2)
{
"padding"
,
{
0
,
0
}},
{
"stride"
,
{
3
,
3
}},
{
"lengths"
,
{
1
,
1
}},
{
"dilations"
,
{
1
,
1
}},
{
"ceil_mode"
,
true
}}),
input
);
}
...
...
@@ -2302,7 +2366,8 @@ TEST_CASE(pooling_dyn_shape3)
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
max
},
{
"padding"
,
{
0
,
0
}},
{
"stride"
,
{
3
,
3
}},
{
"lengths"
,
{
1
,
1
}}}),
{
"lengths"
,
{
1
,
1
}},
{
"dilations"
,
{
1
,
1
}}}),
input
);
}
...
...
@@ -2317,6 +2382,7 @@ TEST_CASE(pooling_dyn_shape4)
{
"padding"
,
{
2
,
2
}},
{
"stride"
,
{
3
,
3
}},
{
"lengths"
,
{
3
,
3
}},
{
"dilations"
,
{
1
,
1
}},
{
"ceil_mode"
,
true
}}),
input
);
}
...
...
test/py/onnx_backend_test.py
View file @
687c6d17
...
...
@@ -190,7 +190,6 @@ def disabled_tests_onnx_1_7_0(backend_test):
backend_test
.
exclude
(
r
'test_negative_log_likelihood_loss_input_shape_is_NCd1d2d3d4d5_none_no_weight_cpu'
)
backend_test
.
exclude
(
r
'test_qlinearconv_cpu'
)
backend_test
.
exclude
(
r
'test_qlinearmatmul_2D_cpu'
)
backend_test
.
exclude
(
r
'test_qlinearmatmul_3D_cpu'
)
backend_test
.
exclude
(
r
'test_range_float_type_positive_delta_expanded_cpu'
)
...
...
@@ -576,6 +575,8 @@ def disabled_tests_onnx_1_9_0(backend_test):
backend_test
.
exclude
(
r
'test_gru_batchwise_cpu'
)
backend_test
.
exclude
(
r
'test_simple_rnn_batchwise_cpu'
)
# from OnnxBackendPyTorchConvertedModelTest
# MaxPool dialtion is partially supported on GPU by a workaround
# But these tests require too large allocations to work properly
backend_test
.
exclude
(
r
'test_MaxPool1d_stride_padding_dilation_cpu'
)
backend_test
.
exclude
(
r
'test_MaxPool2d_stride_padding_dilation_cpu'
)
...
...
test/ref/pooling.cpp
View file @
687c6d17
This diff is collapsed.
Click to expand it.
test/rewrite_pooling_test.cpp
View file @
687c6d17
This diff is collapsed.
Click to expand it.
test/simplify_dyn_ops_test.cpp
View file @
687c6d17
...
...
@@ -155,29 +155,187 @@ TEST_CASE(after_split_dyn_broadcast_match)
EXPECT
(
p0
==
p1
);
}
TEST_CASE
(
const_slice_
3
input
)
TEST_CASE
(
const_slice_
2
input
_ends_axes
)
{
migraphx
::
module
m0
;
{
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
6
,
4
,
4
}};
auto
input
=
m0
.
add_parameter
(
"data"
,
s
);
auto
slice_ins
=
m0
.
add_instruction
(
auto
input
=
m0
.
add_parameter
(
"data"
,
s
);
migraphx
::
shape
s1
{
migraphx
::
shape
::
int32_type
,
{
1
}};
auto
input_starts
=
m0
.
add_literal
(
migraphx
::
literal
{
s1
,
{
0
}});
auto
slice_ins
=
m0
.
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"ends"
,
{
3
}},
{
"axes"
,
{
0
}}}),
input
,
input_starts
);
m0
.
add_return
({
slice_ins
});
}
run_pass
(
m0
);
migraphx
::
module
m1
;
{
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
6
,
4
,
4
}};
auto
input
=
m1
.
add_parameter
(
"data"
,
s
);
auto
slice_ins
=
m1
.
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"starts"
,
{
0
}},
{
"ends"
,
{
3
}},
{
"axes"
,
{
0
}}}),
input
);
m1
.
add_return
({
slice_ins
});
}
EXPECT
(
m0
==
m1
);
}
TEST_CASE
(
const_slice_2input_starts_axes
)
{
migraphx
::
module
m0
;
{
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
6
,
4
,
4
}};
auto
input
=
m0
.
add_parameter
(
"data"
,
s
);
migraphx
::
shape
s1
{
migraphx
::
shape
::
int32_type
,
{
1
}};
auto
input_ends
=
m0
.
add_literal
(
migraphx
::
literal
{
s1
,
{
3
}});
auto
slice_ins
=
m0
.
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"starts"
,
{
0
}},
{
"axes"
,
{
0
}}}),
input
,
input_ends
);
m0
.
add_return
({
slice_ins
});
}
run_pass
(
m0
);
migraphx
::
module
m1
;
{
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
6
,
4
,
4
}};
auto
input
=
m1
.
add_parameter
(
"data"
,
s
);
auto
input
=
m1
.
add_parameter
(
"data"
,
s
);
auto
slice_ins
=
m1
.
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"starts"
,
{
0
}},
{
"ends"
,
{
3
}},
{
"axes"
,
{
0
}}}),
input
);
m1
.
add_return
({
slice_ins
});
}
EXPECT
(
m0
==
m1
);
}
TEST_CASE
(
const_slice_2input_starts_ends
)
{
migraphx
::
module
m0
;
{
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
6
,
4
,
4
}};
auto
input
=
m0
.
add_parameter
(
"data"
,
s
);
migraphx
::
shape
s1
{
migraphx
::
shape
::
int32_type
,
{
1
}};
auto
input_starts
=
m1
.
add_literal
(
migraphx
::
literal
{
s1
,
{
0
}});
auto
input_ends
=
m1
.
add_literal
(
migraphx
::
literal
{
s1
,
{
3
}});
auto
slice_ins
=
m1
.
add_instruction
(
auto
input_axes
=
m0
.
add_literal
(
migraphx
::
literal
{
s1
,
{
0
}});
auto
slice_ins
=
m0
.
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"starts"
,
{
0
}},
{
"ends"
,
{
3
}}}),
input
,
input_axes
);
m0
.
add_return
({
slice_ins
});
}
run_pass
(
m0
);
migraphx
::
module
m1
;
{
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
6
,
4
,
4
}};
auto
input
=
m1
.
add_parameter
(
"data"
,
s
);
auto
slice_ins
=
m1
.
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"starts"
,
{
0
}},
{
"ends"
,
{
3
}},
{
"axes"
,
{
0
}}}),
input
);
m1
.
add_return
({
slice_ins
});
}
EXPECT
(
m0
==
m1
);
}
TEST_CASE
(
const_slice_3input_axes_only
)
{
migraphx
::
module
m0
;
{
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
6
,
4
,
4
}};
auto
input
=
m0
.
add_parameter
(
"data"
,
s
);
migraphx
::
shape
s1
{
migraphx
::
shape
::
int32_type
,
{
1
}};
auto
input_starts
=
m0
.
add_literal
(
migraphx
::
literal
{
s1
,
{
0
}});
auto
input_ends
=
m0
.
add_literal
(
migraphx
::
literal
{
s1
,
{
3
}});
auto
slice_ins
=
m0
.
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"axes"
,
{
0
}}}),
input
,
input_starts
,
input_ends
);
m0
.
add_return
({
slice_ins
});
}
run_pass
(
m0
);
migraphx
::
module
m1
;
{
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
6
,
4
,
4
}};
auto
input
=
m1
.
add_parameter
(
"data"
,
s
);
auto
slice_ins
=
m1
.
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"starts"
,
{
0
}},
{
"ends"
,
{
3
}},
{
"axes"
,
{
0
}}}),
input
);
m1
.
add_return
({
slice_ins
});
}
EXPECT
(
m0
==
m1
);
}
TEST_CASE
(
const_slice_3input_ends_only
)
{
migraphx
::
module
m0
;
{
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
6
,
4
,
4
}};
auto
input
=
m0
.
add_parameter
(
"data"
,
s
);
migraphx
::
shape
s1
{
migraphx
::
shape
::
int32_type
,
{
1
}};
auto
input_starts
=
m0
.
add_literal
(
migraphx
::
literal
{
s1
,
{
0
}});
auto
input_axes
=
m0
.
add_literal
(
migraphx
::
literal
{
s1
,
{
0
}});
auto
slice_ins
=
m0
.
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"ends"
,
{
3
}}}),
input
,
input_starts
,
input_axes
);
m0
.
add_return
({
slice_ins
});
}
run_pass
(
m0
);
migraphx
::
module
m1
;
{
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
6
,
4
,
4
}};
auto
input
=
m1
.
add_parameter
(
"data"
,
s
);
auto
slice_ins
=
m1
.
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"starts"
,
{
0
}},
{
"ends"
,
{
3
}},
{
"axes"
,
{
0
}}}),
input
);
m1
.
add_return
({
slice_ins
});
}
EXPECT
(
m0
==
m1
);
}
TEST_CASE
(
const_slice_3inputs_starts_only
)
{
migraphx
::
module
m0
;
{
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
6
,
4
,
4
}};
auto
input
=
m0
.
add_parameter
(
"data"
,
s
);
migraphx
::
shape
s1
{
migraphx
::
shape
::
int32_type
,
{
1
}};
auto
input_ends
=
m0
.
add_literal
(
migraphx
::
literal
{
s1
,
{
3
}});
auto
input_axes
=
m0
.
add_literal
(
migraphx
::
literal
{
s1
,
{
0
}});
auto
slice_ins
=
m0
.
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"starts"
,
{
0
}}}),
input
,
input_ends
,
input_axes
);
m0
.
add_return
({
slice_ins
});
}
run_pass
(
m0
);
migraphx
::
module
m1
;
{
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
6
,
4
,
4
}};
auto
input
=
m1
.
add_parameter
(
"data"
,
s
);
auto
slice_ins
=
m1
.
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"starts"
,
{
0
}},
{
"ends"
,
{
3
}},
{
"axes"
,
{
0
}}}),
input
);
m1
.
add_return
({
slice_ins
});
}
EXPECT
(
m0
==
m1
);
}
TEST_CASE
(
const_slice_2input_ends_axes_dyn
)
{
migraphx
::
module
m0
;
{
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{{
6
,
6
},
{
2
,
4
,
{
2
,
4
}},
{
2
,
4
,
{
2
,
4
}}}};
auto
input
=
m0
.
add_parameter
(
"data"
,
s
);
migraphx
::
shape
s1
{
migraphx
::
shape
::
int32_type
,
{
1
}};
auto
input_starts
=
m0
.
add_literal
(
migraphx
::
literal
{
s1
,
{
0
}});
auto
slice_ins
=
m0
.
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"ends"
,
{
3
}},
{
"axes"
,
{
0
}}}),
input
,
input_starts
);
m0
.
add_return
({
slice_ins
});
}
run_pass
(
m0
);
migraphx
::
module
m1
;
{
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{{
6
,
6
},
{
2
,
4
,
{
2
,
4
}},
{
2
,
4
,
{
2
,
4
}}}};
auto
input
=
m1
.
add_parameter
(
"data"
,
s
);
auto
slice_ins
=
m1
.
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"starts"
,
{
0
}},
{
"ends"
,
{
3
}},
{
"axes"
,
{
0
}}}),
input
);
m1
.
add_return
({
slice_ins
});
}
run_pass
(
m1
);
EXPECT
(
m0
==
m1
);
}
...
...
@@ -319,4 +477,98 @@ TEST_CASE(static_dimensions_of_nonfixed)
EXPECT
(
m0
==
m1
);
}
TEST_CASE
(
constant_alloc_reshape
)
{
migraphx
::
module
m0
;
{
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
32
}};
auto
input
=
m0
.
add_parameter
(
"data"
,
s
);
migraphx
::
shape
lit_s
{
migraphx
::
shape
::
int64_type
,
{
3
}};
auto
literal_ins
=
m0
.
add_literal
(
migraphx
::
literal
{
lit_s
,
{
3
,
4
,
8
}});
auto
alloc_ins
=
m0
.
add_instruction
(
migraphx
::
make_op
(
"allocate"
,
{{
"buf_type"
,
migraphx
::
shape
::
float_type
}}),
literal_ins
);
auto
reshape_ins
=
m0
.
add_instruction
(
migraphx
::
make_op
(
"reshape"
),
input
,
alloc_ins
);
m0
.
add_return
({
reshape_ins
});
}
run_pass
(
m0
);
migraphx
::
module
m1
;
{
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
32
}};
auto
input
=
m1
.
add_parameter
(
"data"
,
s
);
auto
reshape_ins
=
m1
.
add_instruction
(
migraphx
::
make_op
(
"reshape"
,
{{
"dims"
,
{
3
,
4
,
8
}}}),
input
);
m1
.
add_return
({
reshape_ins
});
}
EXPECT
(
m0
==
m1
);
}
// A more contrived example to test static dimensions_of and constant reshape
TEST_CASE
(
static_dimensions_of_to_constant_alloc_reshape
)
{
migraphx
::
module
m0
;
{
migraphx
::
shape
input_shape
{
migraphx
::
shape
::
float_type
,
{
3
,
4
,
8
}};
auto
x_param
=
m0
.
add_parameter
(
"x"
,
input_shape
);
auto
dimensions_of_ins
=
m0
.
add_instruction
(
migraphx
::
make_op
(
"dimensions_of"
,
{{
"end"
,
3
}}),
x_param
);
migraphx
::
shape
lit_shape
{
migraphx
::
shape
::
int64_type
,
{
1
}};
auto
lit0
=
m0
.
add_literal
(
migraphx
::
literal
{
lit_shape
,
{
0
}});
auto
gather_ins
=
m0
.
add_instruction
(
migraphx
::
make_op
(
"gather"
,
{{
"axis"
,
0
}}),
dimensions_of_ins
,
lit0
);
auto
slice_ins
=
m0
.
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"starts"
,
{
1
}},
{
"ends"
,
{
3
}},
{
"axes"
,
{
0
}}}),
dimensions_of_ins
);
auto
reduce_ins
=
m0
.
add_instruction
(
migraphx
::
make_op
(
"reduce_prod"
,
{{
"axes"
,
{
0
}}}),
slice_ins
);
auto
concat_ins
=
m0
.
add_instruction
(
migraphx
::
make_op
(
"concat"
,
{{
"axis"
,
0
}}),
gather_ins
,
reduce_ins
);
auto
alloc_ins
=
m0
.
add_instruction
(
migraphx
::
make_op
(
"allocate"
,
{{
"buf_type"
,
migraphx
::
shape
::
float_type
}}),
concat_ins
);
auto
reshape_ins
=
m0
.
add_instruction
(
migraphx
::
make_op
(
"reshape"
),
x_param
,
alloc_ins
);
m0
.
add_return
({
reshape_ins
});
}
run_pass
(
m0
);
migraphx
::
module
m1
;
{
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
4
,
8
}};
auto
x_param
=
m1
.
add_parameter
(
"x"
,
s
);
auto
reshape_ins
=
m1
.
add_instruction
(
migraphx
::
make_op
(
"reshape"
,
{{
"dims"
,
{
3
,
32
}}}),
x_param
);
m1
.
add_return
({
reshape_ins
});
}
EXPECT
(
m0
==
m1
);
}
TEST_CASE
(
const_alloc_fill
)
{
migraphx
::
module
m0
;
{
migraphx
::
shape
val_shape
{
migraphx
::
shape
::
int64_type
,
{
1
},
{
0
}};
std
::
vector
<
int64_t
>
lit_data
=
{
3
};
auto
value_lit
=
m0
.
add_literal
(
migraphx
::
literal
{
val_shape
,
lit_data
});
migraphx
::
shape
lit_s
{
migraphx
::
shape
::
int64_type
,
{
3
}};
auto
output_dim_lit
=
m0
.
add_literal
(
migraphx
::
literal
{
lit_s
,
{
3
,
4
,
4
}});
auto
alloc_ins
=
m0
.
add_instruction
(
migraphx
::
make_op
(
"allocate"
,
{{
"buf_type"
,
migraphx
::
shape
::
int64_type
}}),
output_dim_lit
);
auto
ret
=
m0
.
add_instruction
(
migraphx
::
make_op
(
"fill"
),
value_lit
,
alloc_ins
);
m0
.
add_return
({
ret
});
}
run_pass
(
m0
);
migraphx
::
module
m1
;
{
migraphx
::
shape
lit_shape
{
migraphx
::
shape
::
int64_type
,
{
3
,
4
,
4
}};
std
::
vector
<
int64_t
>
lit_data
(
3
*
4
*
4
,
3
);
auto
ret
=
m1
.
add_literal
(
migraphx
::
literal
{
lit_shape
,
lit_data
});
m1
.
add_return
({
ret
});
}
EXPECT
(
m0
==
m1
);
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
test
::
run
(
argc
,
argv
);
}
test/simplify_qdq_test.cpp
View file @
687c6d17
...
...
@@ -788,6 +788,7 @@ TEST_CASE(conv_pooling_dot)
{
"padding"
,
{
0
,
0
,
0
,
0
}},
{
"stride"
,
{
1
,
1
}},
{
"lengths"
,
{
7
,
7
}},
{
"dilations"
,
{
1
,
1
}},
{
"ceil_mode"
,
0
}}),
a1
);
auto
fl
=
m1
.
add_instruction
(
migraphx
::
make_op
(
"flatten"
,
{{
"axis"
,
1
}}),
ap
);
...
...
@@ -835,6 +836,7 @@ TEST_CASE(conv_pooling_dot)
{
"padding"
,
{
0
,
0
,
0
,
0
}},
{
"stride"
,
{
1
,
1
}},
{
"lengths"
,
{
7
,
7
}},
{
"dilations"
,
{
1
,
1
}},
{
"ceil_mode"
,
0
}}),
a1
);
auto
fl
=
m2
.
add_instruction
(
migraphx
::
make_op
(
"flatten"
,
{{
"axis"
,
1
}}),
ap
);
...
...
@@ -896,6 +898,7 @@ TEST_CASE(mobilenet_snippet)
{
"padding"
,
{
0
,
0
,
0
,
0
}},
{
"stride"
,
{
1
,
1
}},
{
"lengths"
,
{
7
,
7
}},
{
"dilations"
,
{
1
,
1
}},
{
"ceil_mode"
,
0
}}),
d6
);
auto
q3
=
add_quantize_op
(
mm
,
"quantizelinear"
,
ap
,
scale
,
zero
);
...
...
test/verify/test_avg_pooling_1d.cpp
View file @
687c6d17
...
...
@@ -35,7 +35,7 @@ struct test_avg_pooling_1d : verify_program<test_avg_pooling_1d>
auto
*
mm
=
p
.
get_main_module
();
auto
input
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
5
}});
auto
op
=
migraphx
::
op
::
pooling
{
migraphx
::
op
::
pooling_mode
::
average
,
{
0
},
{
1
},
{
3
}};
auto
op
=
migraphx
::
op
::
pooling
{
migraphx
::
op
::
pooling_mode
::
average
,
{
0
},
{
1
},
{
3
}
,
{
1
}
};
mm
->
add_instruction
(
op
,
input
);
return
p
;
}
...
...
test/verify/test_avg_pooling_3d.cpp
View file @
687c6d17
...
...
@@ -36,7 +36,7 @@ struct test_avg_pooling_3d : verify_program<test_avg_pooling_3d>
auto
input
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
5
,
5
,
5
}});
auto
op
=
migraphx
::
op
::
pooling
{
migraphx
::
op
::
pooling_mode
::
average
,
{
1
,
1
,
1
},
{
3
,
3
,
3
},
{
3
,
3
,
3
}};
migraphx
::
op
::
pooling_mode
::
average
,
{
1
,
1
,
1
},
{
3
,
3
,
3
},
{
3
,
3
,
3
}
,
{
1
,
1
,
1
}
};
mm
->
add_instruction
(
op
,
input
);
return
p
;
}
...
...
test/verify/test_avg_pooling_3d_opt.cpp
View file @
687c6d17
...
...
@@ -36,7 +36,7 @@ struct test_avg_pooling_3d_opt : verify_program<test_avg_pooling_3d_opt>
auto
input
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
,
2
,
3
,
3
,
3
}});
auto
op
=
migraphx
::
op
::
pooling
{
migraphx
::
op
::
pooling_mode
::
average
,
{
0
,
0
,
0
},
{
1
,
1
,
1
},
{
3
,
3
,
3
}};
migraphx
::
op
::
pooling_mode
::
average
,
{
0
,
0
,
0
},
{
1
,
1
,
1
},
{
3
,
3
,
3
}
,
{
1
,
1
,
1
}
};
mm
->
add_instruction
(
op
,
input
);
return
p
;
}
...
...
test/verify/test_avg_pooling_ceil_3d.cpp
View file @
687c6d17
...
...
@@ -37,7 +37,7 @@ struct test_avg_pooling_ceil_3d : verify_program<test_avg_pooling_ceil_3d>
auto
input
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
5
,
5
,
5
}});
auto
op
=
migraphx
::
op
::
pooling
{
migraphx
::
op
::
pooling_mode
::
average
,
{
1
,
1
,
1
},
{
3
,
3
,
3
},
{
3
,
3
,
3
},
true
};
migraphx
::
op
::
pooling_mode
::
average
,
{
1
,
1
,
1
},
{
3
,
3
,
3
},
{
3
,
3
,
3
},
{
1
,
1
,
1
},
true
};
mm
->
add_instruction
(
op
,
input
);
return
p
;
}
...
...
test/verify/test_avg_pooling_pad.cpp
View file @
687c6d17
...
...
@@ -36,7 +36,7 @@ struct test_avg_pooling_pad : verify_program<test_avg_pooling_pad>
auto
*
mm
=
p
.
get_main_module
();
auto
input
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
7
}});
auto
op
=
migraphx
::
op
::
pooling
{
migraphx
::
op
::
pooling_mode
::
average
,
{
2
},
{
1
},
{
3
}};
auto
op
=
migraphx
::
op
::
pooling
{
migraphx
::
op
::
pooling_mode
::
average
,
{
2
},
{
1
},
{
3
}
,
{
1
}
};
mm
->
add_instruction
(
op
,
input
);
return
p
;
}
...
...
test/verify/test_concat_pooling.cpp
View file @
687c6d17
...
...
@@ -47,7 +47,8 @@ struct test_concat_pooling : verify_program<test_concat_pooling>
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
average
},
{
"padding"
,
{
0
,
0
}},
{
"stride"
,
{
1
,
1
}},
{
"lengths"
,
{
8
,
8
}}}),
{
"lengths"
,
{
8
,
8
}},
{
"dilations"
,
{
1
,
1
}}}),
concat_t
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"relu"
),
pooling
);
return
p
;
...
...
test/verify/test_conv_bn_relu_pooling.cpp
View file @
687c6d17
...
...
@@ -76,7 +76,8 @@ struct test_conv_bn_relu_pooling : verify_program<test_conv_bn_relu_pooling>
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
average
},
{
"padding"
,
{
1
,
1
}},
{
"stride"
,
{
2
,
2
}},
{
"lengths"
,
{
3
,
3
}}}),
{
"lengths"
,
{
3
,
3
}},
{
"dilations"
,
{
1
,
1
}}}),
relu
);
return
p
;
}
...
...
test/verify/test_conv_bn_relu_pooling2.cpp
View file @
687c6d17
...
...
@@ -92,7 +92,8 @@ struct test_conv_bn_relu_pooling2 : verify_program<test_conv_bn_relu_pooling2>
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
average
},
{
"padding"
,
{
1
,
1
}},
{
"stride"
,
{
2
,
2
}},
{
"lengths"
,
{
3
,
3
}}}),
{
"lengths"
,
{
3
,
3
}},
{
"dilations"
,
{
1
,
1
}}}),
relu
);
return
p
;
}
...
...
test/verify/test_max_pooling_ceil_3d.cpp
View file @
687c6d17
...
...
@@ -36,7 +36,7 @@ struct test_max_pooling_ceil_3d : verify_program<test_max_pooling_ceil_3d>
auto
input
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
5
,
5
,
5
}});
auto
op
=
migraphx
::
op
::
pooling
{
migraphx
::
op
::
pooling_mode
::
max
,
{
1
,
1
,
1
},
{
3
,
3
,
3
},
{
3
,
3
,
3
},
true
};
migraphx
::
op
::
pooling_mode
::
max
,
{
1
,
1
,
1
},
{
3
,
3
,
3
},
{
3
,
3
,
3
},
{
1
,
1
,
1
},
true
};
mm
->
add_instruction
(
op
,
input
);
return
p
;
}
...
...
tools/accuracy/requirements.txt
View file @
687c6d17
...
...
@@ -22,4 +22,4 @@
# THE SOFTWARE.
#####################################################################################
numpy==1.21.6
onnxruntime==1.16.
2
onnxruntime==1.16.
3
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