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
432 additions
and
0 deletions
+432
-0
test/onnx/parse/conv_transpose_input_pads_asymm_1d_test.cpp
test/onnx/parse/conv_transpose_input_pads_asymm_1d_test.cpp
+23
-0
test/onnx/parse/conv_transpose_input_pads_asymm_test.cpp
test/onnx/parse/conv_transpose_input_pads_asymm_test.cpp
+22
-0
test/onnx/parse/conv_transpose_input_pads_strides_test.cpp
test/onnx/parse/conv_transpose_input_pads_strides_test.cpp
+20
-0
test/onnx/parse/conv_transpose_output_padding_3d_test.cpp
test/onnx/parse/conv_transpose_output_padding_3d_test.cpp
+22
-0
test/onnx/parse/conv_transpose_output_padding_test.cpp
test/onnx/parse/conv_transpose_output_padding_test.cpp
+21
-0
test/onnx/parse/conv_transpose_output_shape_3d_test.cpp
test/onnx/parse/conv_transpose_output_shape_3d_test.cpp
+22
-0
test/onnx/parse/conv_transpose_output_shape_test.cpp
test/onnx/parse/conv_transpose_output_shape_test.cpp
+21
-0
test/onnx/parse/conv_transpose_test.cpp
test/onnx/parse/conv_transpose_test.cpp
+17
-0
test/onnx/parse/convinteger_bias_test.cpp
test/onnx/parse/convinteger_bias_test.cpp
+22
-0
test/onnx/parse/cos_test.cpp
test/onnx/parse/cos_test.cpp
+16
-0
test/onnx/parse/cosh_test.cpp
test/onnx/parse/cosh_test.cpp
+17
-0
test/onnx/parse/depthtospace_crd_test.cpp
test/onnx/parse/depthtospace_crd_test.cpp
+19
-0
test/onnx/parse/depthtospace_simple_test.cpp
test/onnx/parse/depthtospace_simple_test.cpp
+19
-0
test/onnx/parse/depthtospace_test.cpp
test/onnx/parse/depthtospace_test.cpp
+19
-0
test/onnx/parse/dequantizelinear_axis_test.cpp
test/onnx/parse/dequantizelinear_axis_test.cpp
+14
-0
test/onnx/parse/dequantizelinear_neg_axis_test.cpp
test/onnx/parse/dequantizelinear_neg_axis_test.cpp
+14
-0
test/onnx/parse/dequantizelinear_test.cpp
test/onnx/parse/dequantizelinear_test.cpp
+23
-0
test/onnx/parse/dequantizelinear_zero_point_test.cpp
test/onnx/parse/dequantizelinear_zero_point_test.cpp
+32
-0
test/onnx/parse/dropout_test.cpp
test/onnx/parse/dropout_test.cpp
+20
-0
test/onnx/parse/dynamicquantizelinear_2d_test.cpp
test/onnx/parse/dynamicquantizelinear_2d_test.cpp
+49
-0
No files found.
test/onnx/parse/conv_transpose_input_pads_asymm_1d_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
conv_transpose_input_pads_asymm_1d_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"x"
,
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
3
}});
auto
l1
=
mm
->
add_parameter
(
"w"
,
{
migraphx
::
shape
::
float_type
,
{
1
,
2
,
3
}});
auto
l2
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convolution_backwards"
,
{{
"padding"
,
{
0
}},
{
"stride"
,
{
2
}},
{
"dilation"
,
{
1
}}}),
l0
,
l1
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"axes"
,
{
2
}},
{
"starts"
,
{
0
}},
{
"ends"
,
{
6
}}}),
l2
);
auto
prog
=
optimize_onnx
(
"conv_transpose_input_pads_asymm_1d_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/conv_transpose_input_pads_asymm_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
conv_transpose_input_pads_asymm_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"x"
,
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
3
,
3
}});
auto
l1
=
mm
->
add_parameter
(
"w"
,
{
migraphx
::
shape
::
float_type
,
{
1
,
2
,
3
,
3
}});
auto
l2
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convolution_backwards"
,
{{
"padding"
,
{
0
,
0
}},
{
"stride"
,
{
3
,
2
}}}),
l0
,
l1
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"axes"
,
{
2
,
3
}},
{
"starts"
,
{
0
,
0
}},
{
"ends"
,
{
8
,
6
}}}),
l2
);
auto
prog
=
optimize_onnx
(
"conv_transpose_input_pads_asymm_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/conv_transpose_input_pads_strides_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
conv_transpose_input_pads_strides_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"x"
,
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
3
,
3
}});
auto
l1
=
mm
->
add_parameter
(
"w"
,
{
migraphx
::
shape
::
float_type
,
{
1
,
2
,
3
,
3
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"convolution_backwards"
,
{{
"padding"
,
{
1
,
1
}},
{
"stride"
,
{
3
,
2
}}}),
l0
,
l1
);
auto
prog
=
optimize_onnx
(
"conv_transpose_input_pads_strides_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/conv_transpose_output_padding_3d_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
conv_transpose_output_padding_3d_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"x"
,
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
3
,
3
,
3
}});
auto
l1
=
mm
->
add_parameter
(
"w"
,
{
migraphx
::
shape
::
float_type
,
{
1
,
2
,
3
,
3
,
3
}});
auto
l2
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convolution_backwards"
,
{{
"padding"
,
{
0
,
0
,
0
}},
{
"stride"
,
{
3
,
2
,
2
}},
{
"dilation"
,
{
1
,
1
,
1
}}}),
l0
,
l1
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"pad"
,
{{
"pads"
,
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
1
,
1
,
1
}}}),
l2
);
auto
prog
=
optimize_onnx
(
"conv_transpose_output_padding_3d_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/conv_transpose_output_padding_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
conv_transpose_output_padding_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"x"
,
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
3
,
3
}});
auto
l1
=
mm
->
add_parameter
(
"w"
,
{
migraphx
::
shape
::
float_type
,
{
1
,
2
,
3
,
3
}});
auto
l2
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convolution_backwards"
,
{{
"padding"
,
{
0
,
0
}},
{
"stride"
,
{
3
,
2
}}}),
l0
,
l1
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"pad"
,
{{
"pads"
,
{
0
,
0
,
0
,
0
,
0
,
0
,
1
,
1
}}}),
l2
);
auto
prog
=
optimize_onnx
(
"conv_transpose_output_padding_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/conv_transpose_output_shape_3d_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
conv_transpose_output_shape_3d_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"x"
,
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
3
,
3
,
3
}});
auto
l1
=
mm
->
add_parameter
(
"w"
,
{
migraphx
::
shape
::
float_type
,
{
1
,
2
,
3
,
3
,
3
}});
auto
l2
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convolution_backwards"
,
{{
"padding"
,
{
0
,
0
,
0
}},
{
"stride"
,
{
3
,
2
,
2
}},
{
"dilation"
,
{
1
,
1
,
1
}}}),
l0
,
l1
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"pad"
,
{{
"pads"
,
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
1
,
1
,
1
}}}),
l2
);
auto
prog
=
optimize_onnx
(
"conv_transpose_output_shape_3d_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/conv_transpose_output_shape_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
conv_transpose_output_shape_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"x"
,
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
3
,
3
}});
auto
l1
=
mm
->
add_parameter
(
"w"
,
{
migraphx
::
shape
::
float_type
,
{
1
,
2
,
3
,
3
}});
auto
l2
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convolution_backwards"
,
{{
"padding"
,
{
0
,
0
}},
{
"stride"
,
{
3
,
2
}}}),
l0
,
l1
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"pad"
,
{{
"pads"
,
{
0
,
0
,
0
,
0
,
0
,
0
,
1
,
1
}}}),
l2
);
auto
prog
=
optimize_onnx
(
"conv_transpose_output_shape_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/conv_transpose_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
conv_transpose_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"x"
,
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
3
,
3
}});
auto
l1
=
mm
->
add_parameter
(
"w"
,
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
3
,
3
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"convolution_backwards"
),
l0
,
l1
);
auto
prog
=
optimize_onnx
(
"conv_transpose_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/convinteger_bias_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
convinteger_bias_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"0"
,
{
migraphx
::
shape
::
int8_type
,
{
1
,
3
,
32
,
32
}});
auto
l1
=
mm
->
add_parameter
(
"1"
,
{
migraphx
::
shape
::
int8_type
,
{
1
,
3
,
5
,
5
}});
auto
l2
=
mm
->
add_parameter
(
"2"
,
{
migraphx
::
shape
::
int32_type
,
{
1
}});
uint64_t
axis
=
1
;
auto
l3
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"quant_convolution"
),
l0
,
l1
);
auto
l4
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
axis
},
{
"out_lens"
,
l3
->
get_shape
().
lens
()}}),
l2
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
l3
,
l4
);
auto
prog
=
optimize_onnx
(
"convinteger_bias_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/cos_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
cos_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
input
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
10
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"cos"
),
input
);
auto
prog
=
optimize_onnx
(
"cos_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/cosh_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
cosh_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
input
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"cosh"
),
input
);
auto
prog
=
optimize_onnx
(
"cosh_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/depthtospace_crd_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
depthtospace_crd_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"x"
,
{
migraphx
::
shape
::
float_type
,
{
2
,
8
,
5
,
5
}});
auto
tmp1
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reshape"
,
{{
"dims"
,
{
2
,
2
,
2
,
2
,
5
,
5
}}}),
l0
);
auto
tmp2
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
0
,
1
,
4
,
2
,
5
,
3
}}}),
tmp1
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"reshape"
,
{{
"dims"
,
{
2
,
2
,
10
,
10
}}}),
tmp2
);
auto
prog
=
optimize_onnx
(
"depthtospace_crd_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/depthtospace_simple_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
depthtospace_simple_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"x"
,
{
migraphx
::
shape
::
float_type
,
{
1
,
8
,
2
,
3
}});
auto
tmp1
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reshape"
,
{{
"dims"
,
{
1
,
2
,
2
,
2
,
2
,
3
}}}),
l0
);
auto
tmp2
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
0
,
3
,
4
,
1
,
5
,
2
}}}),
tmp1
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"reshape"
,
{{
"dims"
,
{
1
,
2
,
4
,
6
}}}),
tmp2
);
auto
prog
=
optimize_onnx
(
"depthtospace_simple_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/depthtospace_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
depthtospace_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"x"
,
{
migraphx
::
shape
::
float_type
,
{
2
,
8
,
5
,
5
}});
auto
tmp1
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reshape"
,
{{
"dims"
,
{
2
,
2
,
2
,
2
,
5
,
5
}}}),
l0
);
auto
tmp2
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
0
,
3
,
4
,
1
,
5
,
2
}}}),
tmp1
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"reshape"
,
{{
"dims"
,
{
2
,
2
,
10
,
10
}}}),
tmp2
);
auto
prog
=
optimize_onnx
(
"depthtospace_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/dequantizelinear_axis_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <onnx_test_utils.hpp>
TEST_CASE
(
dequantizelinear_axis_test
)
{
migraphx
::
program
p
=
make_dequantizelinear_axis_prog
();
auto
prog
=
optimize_onnx
(
"dequantizelinear_axis_test.onnx"
,
true
);
EXPECT
(
p
.
sort
()
==
prog
.
sort
());
}
test/onnx/parse/dequantizelinear_neg_axis_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <onnx_test_utils.hpp>
TEST_CASE
(
dequantizelinear_neg_axis_test
)
{
migraphx
::
program
p
=
make_dequantizelinear_axis_prog
();
auto
prog
=
optimize_onnx
(
"dequantizelinear_neg_axis_test.onnx"
,
true
);
EXPECT
(
p
.
sort
()
==
prog
.
sort
());
}
test/onnx/parse/dequantizelinear_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
dequantizelinear_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"0"
,
{
migraphx
::
shape
::
int8_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
dequant
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
to_value
(
migraphx
::
shape
::
float_type
)}}),
l0
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
dequant
,
l1_mbcast
);
auto
prog
=
optimize_onnx
(
"dequantizelinear_test.onnx"
,
true
);
EXPECT
(
p
.
sort
()
==
prog
.
sort
());
}
test/onnx/parse/dequantizelinear_zero_point_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
dequantizelinear_zero_point_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"0"
,
{
migraphx
::
shape
::
int8_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
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
);
l0
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
to_value
(
migraphx
::
shape
::
float_type
)}}),
l0
);
auto
sub
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"sub"
),
l0
,
l2_mbcast
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
sub
,
l1_mbcast
);
auto
prog
=
optimize_onnx
(
"dequantizelinear_zero_point_test.onnx"
,
true
);
EXPECT
(
p
.
sort
()
==
prog
.
sort
());
}
test/onnx/parse/dropout_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
dropout_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
input
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
2
,
2
}});
auto
out
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"identity"
),
input
);
migraphx
::
shape
s
{
migraphx
::
shape
::
bool_type
,
{
1
,
3
,
2
,
2
}};
std
::
vector
<
int8_t
>
vec
(
s
.
elements
(),
1
);
mm
->
add_literal
(
migraphx
::
literal
(
s
,
vec
));
mm
->
add_return
({
out
});
auto
prog
=
migraphx
::
parse_onnx
(
"dropout_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/dynamicquantizelinear_2d_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
dynamicquantizelinear_2d_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
x_dims
=
{
3
,
4
};
auto
x_type
=
migraphx
::
shape
::
float_type
;
auto
x
=
mm
->
add_parameter
(
"x"
,
{
x_type
,
x_dims
});
auto
l0
=
mm
->
add_literal
({
0.
f
});
auto
x_reshaped
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reshape"
,
{{
"dims"
,
{
12
}}}),
x
);
x_reshaped
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"concat"
,
{{
"axis"
,
0
}}),
x_reshaped
,
l0
);
auto
q_range
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
x_type
},
{
std
::
numeric_limits
<
uint8_t
>::
max
()}});
auto
max_x
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reduce_max"
,
{{
"axes"
,
{
0
}}}),
x_reshaped
);
auto
min_x
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reduce_min"
,
{{
"axes"
,
{
0
}}}),
x_reshaped
);
auto
sub0
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"sub"
),
max_x
,
min_x
);
auto
y_scale
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"div"
),
sub0
,
q_range
);
auto
q_min
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
x_type
},
{
std
::
numeric_limits
<
uint8_t
>::
min
()}});
auto
q_max
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
x_type
},
{
std
::
numeric_limits
<
uint8_t
>::
max
()}});
auto
sub1
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"sub"
),
q_min
,
min_x
);
auto
interm_zp
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"div"
),
sub1
,
y_scale
);
auto
saturate
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"clip"
),
interm_zp
,
q_min
,
q_max
);
auto
round
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"nearbyint"
),
saturate
);
auto
y_zero_point
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
shape
::
uint8_type
}}),
round
);
auto
scale_y_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
x_dims
}}),
y_scale
);
auto
y_pt_c_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
x_dims
}}),
y_zero_point
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"quantizelinear"
),
x
,
scale_y_bcast
,
y_pt_c_bcast
);
auto
prog
=
optimize_onnx
(
"dynamicquantizelinear_2d_test.onnx"
);
EXPECT
(
p
==
prog
);
}
Prev
1
2
3
4
5
6
7
8
9
10
…
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