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
386 additions
and
0 deletions
+386
-0
test/onnx/parse/castlike_error_test.cpp
test/onnx/parse/castlike_error_test.cpp
+10
-0
test/onnx/parse/castlike_test.cpp
test/onnx/parse/castlike_test.cpp
+20
-0
test/onnx/parse/ceil_test.cpp
test/onnx/parse/ceil_test.cpp
+17
-0
test/onnx/parse/celu_alpha_test.cpp
test/onnx/parse/celu_alpha_test.cpp
+19
-0
test/onnx/parse/celu_default_test.cpp
test/onnx/parse/celu_default_test.cpp
+19
-0
test/onnx/parse/celu_wrong_type_test.cpp
test/onnx/parse/celu_wrong_type_test.cpp
+10
-0
test/onnx/parse/celu_zero_alpha_test.cpp
test/onnx/parse/celu_zero_alpha_test.cpp
+10
-0
test/onnx/parse/clip_dyn_min_max_test.cpp
test/onnx/parse/clip_dyn_min_max_test.cpp
+27
-0
test/onnx/parse/clip_dyn_min_only_test.cpp
test/onnx/parse/clip_dyn_min_only_test.cpp
+24
-0
test/onnx/parse/clip_test.cpp
test/onnx/parse/clip_test.cpp
+22
-0
test/onnx/parse/clip_test_args_type_mismatch.cpp
test/onnx/parse/clip_test_args_type_mismatch.cpp
+27
-0
test/onnx/parse/clip_test_op11.cpp
test/onnx/parse/clip_test_op11.cpp
+22
-0
test/onnx/parse/clip_test_op11_max_only.cpp
test/onnx/parse/clip_test_op11_max_only.cpp
+22
-0
test/onnx/parse/clip_test_op11_min_only.cpp
test/onnx/parse/clip_test_op11_min_only.cpp
+19
-0
test/onnx/parse/clip_test_op11_no_args.cpp
test/onnx/parse/clip_test_op11_no_args.cpp
+16
-0
test/onnx/parse/clip_test_op11_no_args1.cpp
test/onnx/parse/clip_test_op11_no_args1.cpp
+19
-0
test/onnx/parse/concat_dyn_test.cpp
test/onnx/parse/concat_dyn_test.cpp
+24
-0
test/onnx/parse/concat_test.cpp
test/onnx/parse/concat_test.cpp
+17
-0
test/onnx/parse/const_of_shape_default_test.cpp
test/onnx/parse/const_of_shape_default_test.cpp
+19
-0
test/onnx/parse/const_of_shape_dyn_float_test.cpp
test/onnx/parse/const_of_shape_dyn_float_test.cpp
+23
-0
No files found.
test/onnx/parse/castlike_error_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
castlike_error_test
)
{
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"castlike_error_test.onnx"
);
}));
}
test/onnx/parse/castlike_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
castlike_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
half_type
,
{
10
}});
mm
->
add_parameter
(
"1"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
10
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
to_value
(
migraphx
::
shape
::
float_type
)}}),
l
);
auto
prog
=
optimize_onnx
(
"castlike_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/ceil_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
ceil_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
(
"ceil"
),
input
);
auto
prog
=
optimize_onnx
(
"ceil_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/celu_alpha_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <onnx_test_utils.hpp>
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/onnx/parse/celu_default_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <onnx_test_utils.hpp>
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/onnx/parse/celu_wrong_type_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
celu_wrong_type_test
)
{
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"celu_wrong_type_test.onnx"
);
}));
}
test/onnx/parse/celu_zero_alpha_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
celu_zero_alpha_test
)
{
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"celu_zero_alpha_test.onnx"
);
}));
}
test/onnx/parse/clip_dyn_min_max_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
clip_dyn_min_max_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
min_val
=
mm
->
add_literal
(
0.0
f
);
auto
max_val
=
mm
->
add_literal
(
6.0
f
);
std
::
vector
<
migraphx
::
shape
::
dynamic_dimension
>
dds
=
{{
2
,
8
,
{
3
}}};
auto
l0
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
dds
});
min_val
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_dyn_dims"
,
to_value
(
dds
)}}),
min_val
,
l0
);
max_val
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_dyn_dims"
,
to_value
(
dds
)}}),
max_val
,
l0
);
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"clip"
),
l0
,
min_val
,
max_val
);
mm
->
add_return
({
ret
});
migraphx
::
onnx_options
options
;
options
.
default_dyn_dim_value
=
{
2
,
8
,
{
3
}};
auto
prog
=
parse_onnx
(
"clip_dyn_min_max_test.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/clip_dyn_min_only_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
clip_dyn_min_only_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
min_val
=
mm
->
add_literal
(
0.0
f
);
std
::
vector
<
migraphx
::
shape
::
dynamic_dimension
>
dds
=
{{
2
,
8
,
{
3
}}};
auto
l0
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
dds
});
min_val
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_dyn_dims"
,
to_value
(
dds
)}}),
min_val
,
l0
);
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"max"
),
l0
,
min_val
);
mm
->
add_return
({
ret
});
migraphx
::
onnx_options
options
;
options
.
default_dyn_dim_value
=
{
2
,
8
,
{
3
}};
auto
prog
=
parse_onnx
(
"clip_dyn_min_only_test.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/clip_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
clip_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
}});
auto
min_val
=
mm
->
add_literal
(
0.0
f
);
auto
max_val
=
mm
->
add_literal
(
6.0
f
);
min_val
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
3
}}}),
min_val
);
max_val
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
3
}}}),
max_val
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"clip"
),
l0
,
min_val
,
max_val
);
auto
prog
=
optimize_onnx
(
"clip_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/clip_test_args_type_mismatch.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
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/onnx/parse/clip_test_op11.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
clip_test_op11
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
min_val
=
mm
->
add_literal
(
0.0
f
);
auto
max_val
=
mm
->
add_literal
(
6.0
f
);
auto
l0
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
}});
min_val
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
3
}}}),
min_val
);
max_val
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
3
}}}),
max_val
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"clip"
),
l0
,
min_val
,
max_val
);
auto
prog
=
optimize_onnx
(
"clip_test_op11.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/clip_test_op11_max_only.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
clip_test_op11_max_only
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
max_val
=
mm
->
add_literal
(
0.0
f
);
auto
l0
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"undefined"
));
max_val
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
3
}}}),
max_val
);
auto
r
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"min"
),
l0
,
max_val
);
mm
->
add_return
({
r
});
auto
prog
=
migraphx
::
parse_onnx
(
"clip_test_op11_max_only.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/clip_test_op11_min_only.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
clip_test_op11_min_only
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
min_val
=
mm
->
add_literal
(
0.0
f
);
auto
l0
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
}});
min_val
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
3
}}}),
min_val
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"max"
),
l0
,
min_val
);
auto
prog
=
optimize_onnx
(
"clip_test_op11_min_only.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/clip_test_op11_no_args.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
clip_test_op11_no_args
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"identity"
),
l0
);
auto
prog
=
optimize_onnx
(
"clip_test_op11_no_args.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/clip_test_op11_no_args1.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
clip_test_op11_no_args1
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"undefined"
));
auto
r
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"identity"
),
l0
);
mm
->
add_return
({
r
});
auto
prog
=
migraphx
::
parse_onnx
(
"clip_test_op11_no_args1.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/concat_dyn_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
concat_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
},
{
1
,
4
},
{
3
,
3
}}});
auto
l1
=
mm
->
add_parameter
(
"1"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
},
{
1
,
4
},
{
3
,
3
}}});
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"concat"
),
l0
,
l1
);
mm
->
add_return
({
ret
});
migraphx
::
onnx_options
options
;
options
.
default_dyn_dim_value
=
{
1
,
4
};
auto
prog
=
parse_onnx
(
"concat_dyn_test.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/concat_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
concat_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
4
,
3
}});
auto
l1
=
mm
->
add_parameter
(
"1"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
7
,
4
,
3
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"concat"
,
{{
"axis"
,
0
}}),
l0
,
l1
);
auto
prog
=
optimize_onnx
(
"concat_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/const_of_shape_default_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
const_of_shape_default_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
output_dims_shape
(
migraphx
::
shape
::
int64_type
,
{
3
});
mm
->
add_literal
(
migraphx
::
literal
(
output_dims_shape
,
{
2
,
3
,
4
}));
migraphx
::
shape
output_shape
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
}};
std
::
vector
<
float
>
vec
(
output_shape
.
elements
(),
0.0
);
mm
->
add_literal
(
migraphx
::
literal
(
output_shape
,
vec
));
auto
prog
=
optimize_onnx
(
"const_of_shape_default_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/const_of_shape_dyn_float_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
const_of_shape_dyn_float_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
od_param
=
mm
->
add_parameter
(
"output_dims"
,
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{
3
}});
auto
alloc_ins
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"allocate"
,
{{
"buf_type"
,
migraphx
::
shape
::
float_type
}}),
od_param
);
migraphx
::
shape
dv_shape
(
migraphx
::
shape
::
float_type
,
{
1
},
{
0
});
auto
dv_lit
=
mm
->
add_literal
(
migraphx
::
literal
(
dv_shape
,
{
10
}));
auto
fill_ins
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"fill"
),
dv_lit
,
alloc_ins
);
mm
->
add_return
({
fill_ins
});
migraphx
::
onnx_options
options
;
auto
prog
=
parse_onnx
(
"const_of_shape_dyn_float_test.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
Prev
1
2
3
4
5
6
7
…
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