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
93c89587
Commit
93c89587
authored
Dec 13, 2023
by
Paul
Browse files
Split onnx tests
parent
d2532d0e
Changes
490
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
716 additions
and
0 deletions
+716
-0
test/onnx/parse/qlinearaveragepool_notset_test.cpp
test/onnx/parse/qlinearaveragepool_notset_test.cpp
+54
-0
test/onnx/parse/qlinearconcat_test.cpp
test/onnx/parse/qlinearconcat_test.cpp
+58
-0
test/onnx/parse/qlinearconv_test.cpp
test/onnx/parse/qlinearconv_test.cpp
+60
-0
test/onnx/parse/qlinearglobalavgpool_test.cpp
test/onnx/parse/qlinearglobalavgpool_test.cpp
+51
-0
test/onnx/parse/qlinearleakyrelu_test.cpp
test/onnx/parse/qlinearleakyrelu_test.cpp
+45
-0
test/onnx/parse/qlinearmatmul_1D_test.cpp
test/onnx/parse/qlinearmatmul_1D_test.cpp
+64
-0
test/onnx/parse/qlinearmatmul_2D_test.cpp
test/onnx/parse/qlinearmatmul_2D_test.cpp
+58
-0
test/onnx/parse/qlinearmul_test.cpp
test/onnx/parse/qlinearmul_test.cpp
+58
-0
test/onnx/parse/qlinearsigmoid_test.cpp
test/onnx/parse/qlinearsigmoid_test.cpp
+45
-0
test/onnx/parse/quantizelinear_axis_test.cpp
test/onnx/parse/quantizelinear_axis_test.cpp
+14
-0
test/onnx/parse/quantizelinear_int32_test.cpp
test/onnx/parse/quantizelinear_int32_test.cpp
+31
-0
test/onnx/parse/quantizelinear_neg_axis_test.cpp
test/onnx/parse/quantizelinear_neg_axis_test.cpp
+14
-0
test/onnx/parse/quantizelinear_test.cpp
test/onnx/parse/quantizelinear_test.cpp
+27
-0
test/onnx/parse/quantizelinear_zero_point_test.cpp
test/onnx/parse/quantizelinear_zero_point_test.cpp
+35
-0
test/onnx/parse/randomnormal_dtype_error_test.cpp
test/onnx/parse/randomnormal_dtype_error_test.cpp
+10
-0
test/onnx/parse/randomnormal_generated_seed_test.cpp
test/onnx/parse/randomnormal_generated_seed_test.cpp
+13
-0
test/onnx/parse/randomnormal_shape_error_test.cpp
test/onnx/parse/randomnormal_shape_error_test.cpp
+10
-0
test/onnx/parse/randomnormal_test.cpp
test/onnx/parse/randomnormal_test.cpp
+29
-0
test/onnx/parse/randomnormallike_test.cpp
test/onnx/parse/randomnormallike_test.cpp
+30
-0
test/onnx/parse/randomnormallike_type_error_test.cpp
test/onnx/parse/randomnormallike_type_error_test.cpp
+10
-0
No files found.
test/onnx/parse/qlinearaveragepool_notset_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <migraphx/op/pooling.hpp>
TEST_CASE
(
qlinearaveragepool_notset_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
sc_x
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
float_type
,
{
0.5
}});
auto
z_pt_x
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
int8_type
,
{
0
}});
auto
sc_y
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
float_type
,
{
0.5
}});
auto
z_pt_y
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
int8_type
,
{
10
}});
auto
x
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
int8_type
,
{
1
,
1
,
5
,
5
}});
auto
scale_x_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
1
,
1
,
5
,
5
}}}),
sc_x
);
auto
z_pt_x_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
1
,
1
,
5
,
5
}}}),
z_pt_x
);
auto
fp_x
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"dequantizelinear"
),
x
,
scale_x_bcast
,
z_pt_x_bcast
);
auto
fp_y
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
average
},
{
"padding"
,
{
2
,
2
,
2
,
2
}},
{
"stride"
,
{
2
,
2
}},
{
"lengths"
,
{
6
,
6
}}}),
fp_x
);
fp_y
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"axes"
,
{
2
,
3
}},
{
"starts"
,
{
1
,
1
}},
{
"ends"
,
{
2
,
2
}}}),
fp_y
);
auto
scale_y_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
1
,
1
,
1
,
1
}}}),
sc_y
);
auto
z_pt_y_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
1
,
1
,
1
,
1
}}}),
z_pt_y
);
auto
y
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"quantizelinear"
),
fp_y
,
scale_y_bcast
,
z_pt_y_bcast
);
mm
->
add_return
({
y
});
auto
prog
=
migraphx
::
parse_onnx
(
"qlinearaveragepool_notset_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/qlinearconcat_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
qlinearconcat_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
sc_y
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
float_type
,
{
0.5
}});
auto
z_pt_y
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
int8_type
,
{
2
}});
auto
sc_0
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
float_type
,
{
0.5
}});
auto
z_pt_0
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
int8_type
,
{
1
}});
auto
sc_1
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
float_type
,
{
0.25
}});
auto
z_pt_1
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
int8_type
,
{
0
}});
auto
t0
=
mm
->
add_parameter
(
"t0"
,
{
migraphx
::
shape
::
int8_type
,
{
2
}});
auto
t1
=
mm
->
add_parameter
(
"t1"
,
{
migraphx
::
shape
::
int8_type
,
{
3
}});
auto
scale_0_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
2
}}}),
sc_0
);
auto
z_pt_0_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
2
}}}),
z_pt_0
);
auto
fp_0
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"dequantizelinear"
),
t0
,
scale_0_bcast
,
z_pt_0_bcast
);
auto
scale_1_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
3
}}}),
sc_1
);
auto
z_pt_1_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
3
}}}),
z_pt_1
);
auto
fp_1
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"dequantizelinear"
),
t1
,
scale_1_bcast
,
z_pt_1_bcast
);
auto
fp_y
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"concat"
,
{{
"axis"
,
0
}}),
fp_0
,
fp_1
);
auto
scale_y_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
5
}}}),
sc_y
);
auto
z_pt_y_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
5
}}}),
z_pt_y
);
auto
y
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"quantizelinear"
),
fp_y
,
scale_y_bcast
,
z_pt_y_bcast
);
mm
->
add_return
({
y
});
auto
prog
=
migraphx
::
parse_onnx
(
"qlinearconcat_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/qlinearconv_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
qlinearconv_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
x
=
mm
->
add_parameter
(
"X"
,
{
migraphx
::
shape
::
uint8_type
,
{
1
,
1
,
7
,
7
}});
auto
sc_x
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
float_type
,
{
0.00369204697
}});
auto
z_pt_x
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
uint8_type
,
{
132
}});
auto
w
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
migraphx
::
shape
::
uint8_type
,
{
1
,
1
,
1
,
1
}},
{
0
}});
auto
sc_w
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
float_type
,
{
0.00172794575
}});
auto
z_pt_w
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
uint8_type
,
{
255
}});
auto
sc_y
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
float_type
,
{
0.00162681262
}});
auto
z_pt_y
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
uint8_type
,
{
123
}});
auto
scale_x_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
1
,
1
,
7
,
7
}}}),
sc_x
);
auto
z_pt_x_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
1
,
1
,
7
,
7
}}}),
z_pt_x
);
auto
fp_x
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"dequantizelinear"
),
x
,
scale_x_bcast
,
z_pt_x_bcast
);
auto
scale_w_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
1
,
1
,
1
,
1
}}}),
sc_w
);
auto
z_pt_w_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
1
,
1
,
1
,
1
}}}),
z_pt_w
);
auto
fp_w
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"dequantizelinear"
),
w
,
scale_w_bcast
,
z_pt_w_bcast
);
auto
fp_y
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convolution"
),
fp_x
,
fp_w
);
auto
scale_y_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
1
,
1
,
7
,
7
}}}),
sc_y
);
auto
z_pt_y_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
1
,
1
,
7
,
7
}}}),
z_pt_y
);
auto
y
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"quantizelinear"
),
fp_y
,
scale_y_bcast
,
z_pt_y_bcast
);
mm
->
add_return
({
y
});
auto
prog
=
migraphx
::
parse_onnx
(
"qlinearconv_test.onnx"
);
EXPECT
(
p
.
sort
()
==
prog
.
sort
());
}
test/onnx/parse/qlinearglobalavgpool_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <migraphx/op/pooling.hpp>
TEST_CASE
(
qlinearglobalavgpool_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
x
=
mm
->
add_parameter
(
"X"
,
{
migraphx
::
shape
::
uint8_type
,
{
1
,
3
,
4
,
4
}});
auto
sc_x
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
float_type
,
{
0.05
}});
auto
z_pt_x
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
uint8_type
,
{
128
}});
auto
sc_y
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
float_type
,
{
0.025
}});
auto
z_pt_y
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
uint8_type
,
{
64
}});
auto
scale_x_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
1
,
3
,
4
,
4
}}}),
sc_x
);
auto
z_pt_x_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
1
,
3
,
4
,
4
}}}),
z_pt_x
);
auto
fp_x
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"dequantizelinear"
),
x
,
scale_x_bcast
,
z_pt_x_bcast
);
auto
fp_y
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
average
},
{
"padding"
,
{
0
,
0
,
0
,
0
}},
{
"lengths"
,
{
4
,
4
}}}),
fp_x
);
auto
scale_y_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
1
,
3
,
1
,
1
}}}),
sc_y
);
auto
z_pt_y_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
1
,
3
,
1
,
1
}}}),
z_pt_y
);
auto
y
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"quantizelinear"
),
fp_y
,
scale_y_bcast
,
z_pt_y_bcast
);
mm
->
add_return
({
y
});
auto
prog
=
migraphx
::
parse_onnx
(
"qlinearglobalavgpool_test.onnx"
);
EXPECT
(
p
.
sort
()
==
prog
.
sort
());
}
test/onnx/parse/qlinearleakyrelu_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
qlinearleakyrelu_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
x
=
mm
->
add_parameter
(
"X"
,
{
migraphx
::
shape
::
int8_type
,
{
64
}});
auto
sc_x
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
float_type
,
{
0.05
}});
auto
z_pt_x
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
int8_type
,
{
0
}});
auto
sc_y
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
float_type
,
{
0.05
}});
auto
z_pt_y
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
int8_type
,
{
10
}});
auto
scale_x_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
64
}}}),
sc_x
);
auto
z_pt_x_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
64
}}}),
z_pt_x
);
auto
fp_x
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"dequantizelinear"
),
x
,
scale_x_bcast
,
z_pt_x_bcast
);
auto
fp_y
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"leaky_relu"
,
{{
"alpha"
,
1.1
}}),
fp_x
);
auto
scale_y_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
64
}}}),
sc_y
);
auto
z_pt_y_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
64
}}}),
z_pt_y
);
auto
y
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"quantizelinear"
),
fp_y
,
scale_y_bcast
,
z_pt_y_bcast
);
mm
->
add_return
({
y
});
auto
prog
=
migraphx
::
parse_onnx
(
"qlinearleakyrelu_test.onnx"
);
EXPECT
(
p
.
sort
()
==
prog
.
sort
());
}
test/onnx/parse/qlinearmatmul_1D_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
qlinearmatmul_1D_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
a
=
mm
->
add_parameter
(
"A"
,
{
migraphx
::
shape
::
uint8_type
,
{
8
}});
auto
b
=
mm
->
add_parameter
(
"B"
,
{
migraphx
::
shape
::
uint8_type
,
{
8
}});
auto
sc_a
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
float_type
,
{
0.05
}});
auto
z_pt_a
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
uint8_type
,
{
0
}});
auto
sc_b
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
float_type
,
{
0.05
}});
auto
z_pt_b
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
uint8_type
,
{
128
}});
auto
sc_c
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
float_type
,
{
0.05
}});
auto
z_pt_c
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
uint8_type
,
{
64
}});
auto
scale_a_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
8
}}}),
sc_a
);
auto
z_pt_a_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
8
}}}),
z_pt_a
);
auto
fp_a
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"dequantizelinear"
),
a
,
scale_a_bcast
,
z_pt_a_bcast
);
auto
scale_b_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
8
}}}),
sc_b
);
auto
z_pt_b_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
8
}}}),
z_pt_b
);
auto
fp_b
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"dequantizelinear"
),
b
,
scale_b_bcast
,
z_pt_b_bcast
);
auto
sq_a
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"unsqueeze"
,
{{
"axes"
,
{
0
}}}),
fp_a
);
auto
sq_b
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"unsqueeze"
,
{{
"axes"
,
{
1
}}}),
fp_b
);
auto
fp_c
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"dot"
),
sq_a
,
sq_b
);
auto
sq_c
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"squeeze"
,
{{
"axes"
,
{
0
}}}),
fp_c
);
auto
scale_c_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
1
}}}),
sc_c
);
auto
z_pt_c_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
1
}}}),
z_pt_c
);
auto
c
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"quantizelinear"
),
sq_c
,
scale_c_bcast
,
z_pt_c_bcast
);
mm
->
add_return
({
c
});
auto
prog
=
migraphx
::
parse_onnx
(
"qlinearmatmul_1D_test.onnx"
);
EXPECT
(
p
.
sort
()
==
prog
.
sort
());
}
test/onnx/parse/qlinearmatmul_2D_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
qlinearmatmul_2D_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
a
=
mm
->
add_parameter
(
"A"
,
{
migraphx
::
shape
::
uint8_type
,
{
1
,
8
}});
auto
b
=
mm
->
add_parameter
(
"B"
,
{
migraphx
::
shape
::
uint8_type
,
{
8
,
1
}});
auto
sc_a
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
float_type
,
{
0.05
}});
auto
z_pt_a
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
uint8_type
,
{
0
}});
auto
sc_b
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
float_type
,
{
0.05
}});
auto
z_pt_b
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
uint8_type
,
{
128
}});
auto
sc_c
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
float_type
,
{
0.05
}});
auto
z_pt_c
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
uint8_type
,
{
64
}});
auto
scale_a_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
1
,
8
}}}),
sc_a
);
auto
z_pt_a_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
1
,
8
}}}),
z_pt_a
);
auto
fp_a
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"dequantizelinear"
),
a
,
scale_a_bcast
,
z_pt_a_bcast
);
auto
scale_b_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
8
,
1
}}}),
sc_b
);
auto
z_pt_b_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
8
,
1
}}}),
z_pt_b
);
auto
fp_b
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"dequantizelinear"
),
b
,
scale_b_bcast
,
z_pt_b_bcast
);
auto
fp_c
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"dot"
),
fp_a
,
fp_b
);
auto
scale_c_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
1
,
1
}}}),
sc_c
);
auto
z_pt_c_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
1
,
1
}}}),
z_pt_c
);
auto
c
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"quantizelinear"
),
fp_c
,
scale_c_bcast
,
z_pt_c_bcast
);
mm
->
add_return
({
c
});
auto
prog
=
migraphx
::
parse_onnx
(
"qlinearmatmul_2D_test.onnx"
);
EXPECT
(
p
.
sort
()
==
prog
.
sort
());
}
test/onnx/parse/qlinearmul_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
qlinearmul_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
a
=
mm
->
add_parameter
(
"A"
,
{
migraphx
::
shape
::
uint8_type
,
{
64
}});
auto
b
=
mm
->
add_parameter
(
"B"
,
{
migraphx
::
shape
::
uint8_type
,
{
64
}});
auto
sc_a
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
float_type
,
{
0.05
}});
auto
z_pt_a
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
uint8_type
,
{
0
}});
auto
sc_b
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
float_type
,
{
0.05
}});
auto
z_pt_b
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
uint8_type
,
{
16
}});
auto
sc_c
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
float_type
,
{
0.05
}});
auto
z_pt_c
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
uint8_type
,
{
100
}});
auto
scale_a_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
64
}}}),
sc_a
);
auto
z_pt_a_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
64
}}}),
z_pt_a
);
auto
fp_a
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"dequantizelinear"
),
a
,
scale_a_bcast
,
z_pt_a_bcast
);
auto
scale_b_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
64
}}}),
sc_b
);
auto
z_pt_b_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
64
}}}),
z_pt_b
);
auto
fp_b
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"dequantizelinear"
),
b
,
scale_b_bcast
,
z_pt_b_bcast
);
auto
fp_c
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
fp_a
,
fp_b
);
auto
scale_c_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
64
}}}),
sc_c
);
auto
z_pt_c_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
64
}}}),
z_pt_c
);
auto
c
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"quantizelinear"
),
fp_c
,
scale_c_bcast
,
z_pt_c_bcast
);
mm
->
add_return
({
c
});
auto
prog
=
migraphx
::
parse_onnx
(
"qlinearmul_test.onnx"
);
EXPECT
(
p
.
sort
()
==
prog
.
sort
());
}
test/onnx/parse/qlinearsigmoid_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
qlinearsigmoid_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
x
=
mm
->
add_parameter
(
"X"
,
{
migraphx
::
shape
::
int8_type
,
{
64
}});
auto
sc_x
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
float_type
,
{
0.05
}});
auto
z_pt_x
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
int8_type
,
{
0
}});
auto
sc_y
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
float_type
,
{
0.0035
}});
auto
z_pt_y
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
int8_type
,
{
-
128
}});
auto
scale_x_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
64
}}}),
sc_x
);
auto
z_pt_x_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
64
}}}),
z_pt_x
);
auto
fp_x
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"dequantizelinear"
),
x
,
scale_x_bcast
,
z_pt_x_bcast
);
auto
fp_y
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"sigmoid"
),
fp_x
);
auto
scale_y_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
64
}}}),
sc_y
);
auto
z_pt_y_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
64
}}}),
z_pt_y
);
auto
y
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"quantizelinear"
),
fp_y
,
scale_y_bcast
,
z_pt_y_bcast
);
mm
->
add_return
({
y
});
auto
prog
=
migraphx
::
parse_onnx
(
"qlinearsigmoid_test.onnx"
);
EXPECT
(
p
.
sort
()
==
prog
.
sort
());
}
test/onnx/parse/quantizelinear_axis_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <onnx_test_utils.hpp>
TEST_CASE
(
quantizelinear_axis_test
)
{
migraphx
::
program
p
=
make_quantizelinear_axis_prog
();
auto
prog
=
optimize_onnx
(
"quantizelinear_axis_test.onnx"
,
true
);
EXPECT
(
p
.
sort
()
==
prog
.
sort
());
}
test/onnx/parse/quantizelinear_int32_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <onnx_test_utils.hpp>
TEST_CASE
(
quantizelinear_int32_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"0"
,
{
migraphx
::
shape
::
int32_type
,
{
5
}});
auto
l1
=
mm
->
add_parameter
(
"1"
,
{
migraphx
::
shape
::
float_type
,
{
1
}});
auto
l1_mbcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
5
}}}),
l1
);
l0
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
to_value
(
migraphx
::
shape
::
float_type
)}}),
l0
);
auto
div
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"div"
),
l0
,
l1_mbcast
);
auto
nearbyint
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"nearbyint"
),
div
);
auto
s
=
nearbyint
->
get_shape
();
auto
clip
=
insert_quantizelinear_clip
(
*
mm
,
div
,
nearbyint
,
s
,
0
,
255
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
to_value
(
migraphx
::
shape
::
uint8_type
)}}),
clip
);
auto
prog
=
optimize_onnx
(
"quantizelinear_int32_test.onnx"
,
true
);
EXPECT
(
p
.
sort
()
==
prog
.
sort
());
}
test/onnx/parse/quantizelinear_neg_axis_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <onnx_test_utils.hpp>
TEST_CASE
(
quantizelinear_neg_axis_test
)
{
migraphx
::
program
p
=
make_quantizelinear_axis_prog
();
auto
prog
=
optimize_onnx
(
"quantizelinear_neg_axis_test.onnx"
,
true
);
EXPECT
(
p
.
sort
()
==
prog
.
sort
());
}
test/onnx/parse/quantizelinear_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <onnx_test_utils.hpp>
TEST_CASE
(
quantizelinear_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"0"
,
{
migraphx
::
shape
::
float_type
,
{
5
}});
auto
l1
=
mm
->
add_parameter
(
"1"
,
{
migraphx
::
shape
::
float_type
,
{
1
}});
auto
l1_mbcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
5
}}}),
l1
);
auto
div
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"div"
),
l0
,
l1_mbcast
);
auto
nearbyint
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"nearbyint"
),
div
);
auto
s
=
nearbyint
->
get_shape
();
auto
clip
=
insert_quantizelinear_clip
(
*
mm
,
div
,
nearbyint
,
s
,
0
,
255
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
to_value
(
migraphx
::
shape
::
uint8_type
)}}),
clip
);
auto
prog
=
optimize_onnx
(
"quantizelinear_test.onnx"
,
true
);
EXPECT
(
p
.
sort
()
==
prog
.
sort
());
}
test/onnx/parse/quantizelinear_zero_point_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <onnx_test_utils.hpp>
TEST_CASE
(
quantizelinear_zero_point_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"0"
,
{
migraphx
::
shape
::
float_type
,
{
5
}});
auto
l1
=
mm
->
add_parameter
(
"1"
,
{
migraphx
::
shape
::
float_type
,
{
1
}});
auto
l2
=
mm
->
add_parameter
(
"2"
,
{
migraphx
::
shape
::
int8_type
,
{
1
}});
auto
l1_mbcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
5
}}}),
l1
);
auto
div
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"div"
),
l0
,
l1_mbcast
);
auto
round
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"nearbyint"
),
div
);
auto
l2_mbcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
5
}}}),
l2
);
l2_mbcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
to_value
(
migraphx
::
shape
::
float_type
)}}),
l2_mbcast
);
auto
add
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
round
,
l2_mbcast
);
auto
s
=
round
->
get_shape
();
auto
clip
=
insert_quantizelinear_clip
(
*
mm
,
div
,
add
,
s
,
-
128
,
127
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
to_value
(
migraphx
::
shape
::
int8_type
)}}),
clip
);
auto
prog
=
optimize_onnx
(
"quantizelinear_zero_point_test.onnx"
,
true
);
EXPECT
(
p
.
sort
()
==
prog
.
sort
());
}
test/onnx/parse/randomnormal_dtype_error_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
randomnormal_dtype_error_test
)
{
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"randomnormal_dtype_error_test.onnx"
);
}));
}
test/onnx/parse/randomnormal_generated_seed_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
randomnormal_generated_seed_test
)
{
auto
p1
=
optimize_onnx
(
"randomnormal_generated_seed_test.onnx"
);
auto
p2
=
optimize_onnx
(
"randomnormal_generated_seed_test.onnx"
);
EXPECT
(
p1
!=
p2
);
}
test/onnx/parse/randomnormal_shape_error_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
randomnormal_shape_error_test
)
{
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"randomnormal_shape_error_test.onnx"
);
}));
}
test/onnx/parse/randomnormal_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <random>
TEST_CASE
(
randomnormal_test
)
{
float
mean
=
10.0
;
float
scale
=
1.5
;
float
seed
=
0.0
;
std
::
vector
<
int
>
shape_attr
{
2
,
3
,
4
};
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
double_type
,
shape_attr
};
std
::
vector
<
double
>
rand_vals
(
s
.
elements
());
std
::
mt19937
gen
(
seed
);
std
::
normal_distribution
<>
d
(
mean
,
scale
);
std
::
generate
(
rand_vals
.
begin
(),
rand_vals
.
end
(),
[
&
]()
{
return
d
(
gen
);
});
mm
->
add_literal
(
migraphx
::
literal
{
s
,
rand_vals
});
auto
prog
=
optimize_onnx
(
"randomnormal_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/randomnormallike_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <random>
TEST_CASE
(
randomnormallike_test
)
{
float
mean
=
10.0
;
float
scale
=
1.5
;
float
seed
=
0.0
;
std
::
vector
<
int
>
shape_attr
{
2
,
3
,
4
};
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
half_type
,
shape_attr
};
std
::
vector
<
double
>
rand_vals
(
s
.
elements
());
std
::
mt19937
gen
(
seed
);
std
::
normal_distribution
<>
d
(
mean
,
scale
);
std
::
generate
(
rand_vals
.
begin
(),
rand_vals
.
end
(),
[
&
]()
{
return
d
(
gen
);
});
mm
->
add_parameter
(
"input"
,
s
);
mm
->
add_literal
(
migraphx
::
literal
{
s
,
rand_vals
});
auto
prog
=
optimize_onnx
(
"randomnormallike_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/randomnormallike_type_error_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
randomnormallike_type_error_test
)
{
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"randomnormallike_type_error_test.onnx"
);
}));
}
Prev
1
…
13
14
15
16
17
18
19
20
21
…
25
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