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
10 changed files
with
314 additions
and
0 deletions
+314
-0
test/onnx/parse/unknown_aten_test.cpp
test/onnx/parse/unknown_aten_test.cpp
+10
-0
test/onnx/parse/unknown_test.cpp
test/onnx/parse/unknown_test.cpp
+31
-0
test/onnx/parse/upsample_linear_test.cpp
test/onnx/parse/upsample_linear_test.cpp
+13
-0
test/onnx/parse/upsample_test.cpp
test/onnx/parse/upsample_test.cpp
+28
-0
test/onnx/parse/upsample_ver7_test.cpp
test/onnx/parse/upsample_ver7_test.cpp
+26
-0
test/onnx/parse/variable_batch_leq_zero_test.cpp
test/onnx/parse/variable_batch_leq_zero_test.cpp
+17
-0
test/onnx/parse/variable_batch_test.cpp
test/onnx/parse/variable_batch_test.cpp
+120
-0
test/onnx/parse/where_dyn_test.cpp
test/onnx/parse/where_dyn_test.cpp
+28
-0
test/onnx/parse/where_mixed_test.cpp
test/onnx/parse/where_mixed_test.cpp
+13
-0
test/onnx/parse/where_test.cpp
test/onnx/parse/where_test.cpp
+28
-0
No files found.
test/onnx/parse/unknown_aten_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
unknown_aten_test
)
{
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"unknown_aten_test.onnx"
);
}));
}
test/onnx/parse/unknown_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <migraphx/op/unknown.hpp>
TEST_CASE
(
unknown_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
5
}});
auto
l1
=
mm
->
add_parameter
(
"1"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
4
}});
auto
l2
=
mm
->
add_instruction
(
migraphx
::
op
::
unknown
{
"Unknown"
},
l0
,
l1
);
mm
->
add_instruction
(
migraphx
::
op
::
unknown
{
"Unknown"
},
l2
);
auto
prog
=
optimize_onnx
(
"unknown_test.onnx"
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
unknown_test_throw
)
{
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"unknown_test.onnx"
);
}));
}
TEST_CASE
(
unknown_test_throw_print_error
)
{
migraphx
::
onnx_options
options
;
options
.
print_program_on_error
=
true
;
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"unknown_test.onnx"
,
options
);
}));
}
test/onnx/parse/upsample_linear_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <onnx_test_utils.hpp>
TEST_CASE
(
upsample_linear_test
)
{
auto
p
=
create_upsample_linear_prog
();
auto
prog
=
migraphx
::
parse_onnx
(
"upsample_linear_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/upsample_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
upsample_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
ss
{
migraphx
::
shape
::
float_type
,
{
4
}};
mm
->
add_literal
(
migraphx
::
literal
(
ss
,
{
1.0
f
,
1.0
f
,
2.0
f
,
3.0
f
}));
migraphx
::
shape
sx
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
2
,
2
}};
auto
ix
=
mm
->
add_parameter
(
"X"
,
sx
);
migraphx
::
shape
si
{
migraphx
::
shape
::
int32_type
,
{
1
,
1
,
4
,
6
}};
std
::
vector
<
int
>
ind
=
{
0
,
0
,
0
,
1
,
1
,
1
,
0
,
0
,
0
,
1
,
1
,
1
,
2
,
2
,
2
,
3
,
3
,
3
,
2
,
2
,
2
,
3
,
3
,
3
};
auto
li
=
mm
->
add_literal
(
migraphx
::
literal
(
si
,
ind
));
auto
rsp
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reshape"
,
{{
"dims"
,
{
4
}}}),
ix
);
auto
r
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"gather"
,
{{
"axis"
,
0
}}),
rsp
,
li
);
mm
->
add_return
({
r
});
auto
prog
=
migraphx
::
parse_onnx
(
"upsample_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/upsample_ver7_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
upsample_ver7_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
sx
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
2
,
2
}};
auto
ix
=
mm
->
add_parameter
(
"X"
,
sx
);
migraphx
::
shape
si
{
migraphx
::
shape
::
int32_type
,
{
1
,
1
,
4
,
6
}};
std
::
vector
<
int
>
ind
=
{
0
,
0
,
0
,
1
,
1
,
1
,
0
,
0
,
0
,
1
,
1
,
1
,
2
,
2
,
2
,
3
,
3
,
3
,
2
,
2
,
2
,
3
,
3
,
3
};
auto
li
=
mm
->
add_literal
(
migraphx
::
literal
(
si
,
ind
));
auto
rsp
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reshape"
,
{{
"dims"
,
{
4
}}}),
ix
);
auto
r
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"gather"
,
{{
"axis"
,
0
}}),
rsp
,
li
);
mm
->
add_return
({
r
});
auto
prog
=
migraphx
::
parse_onnx
(
"upsample_ver7_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/variable_batch_leq_zero_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
variable_batch_leq_zero_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
16
,
16
}});
auto
l1
=
mm
->
add_parameter
(
"1"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
16
,
16
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
l0
,
l1
);
auto
prog
=
optimize_onnx
(
"variable_batch_leq_zero_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/variable_batch_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
variable_batch_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
16
,
16
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"identity"
),
l0
);
auto
prog
=
optimize_onnx
(
"variable_batch_test.onnx"
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
variable_batch_user_input_test1
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
16
,
16
}});
auto
r
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"identity"
),
l0
);
mm
->
add_return
({
r
});
migraphx
::
onnx_options
options
;
options
.
default_dyn_dim_value
=
{
2
,
2
};
auto
prog
=
migraphx
::
parse_onnx
(
"variable_batch_test.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
variable_batch_user_input_test2
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
2
,
5
},
{
3
,
3
},
{
16
,
16
},
{
16
,
16
}}});
auto
r
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"identity"
),
l0
);
mm
->
add_return
({
r
});
migraphx
::
onnx_options
options
;
options
.
default_dyn_dim_value
=
{
2
,
5
};
auto
prog
=
migraphx
::
parse_onnx
(
"variable_batch_test.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
variable_batch_user_input_test3
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
2
,
5
},
{
3
,
3
},
{
16
,
16
},
{
16
,
16
}}});
auto
r
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"identity"
),
l0
);
mm
->
add_return
({
r
});
migraphx
::
onnx_options
options
;
options
.
map_dyn_input_dims
[
"0"
]
=
{{
2
,
5
},
{
3
,
3
},
{
16
,
16
},
{
16
,
16
}};
auto
prog
=
migraphx
::
parse_onnx
(
"variable_batch_test.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
variable_batch_user_input_test4
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
16
,
16
}});
auto
r
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"identity"
),
l0
);
mm
->
add_return
({
r
});
migraphx
::
onnx_options
options
;
options
.
default_dim_value
=
2
;
auto
prog
=
migraphx
::
parse_onnx
(
"variable_batch_test.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
variable_batch_user_input_test5
)
{
// Error using default_dim_value and default_dyn_dim_value
migraphx
::
onnx_options
options
;
options
.
default_dim_value
=
2
;
options
.
default_dyn_dim_value
=
{
1
,
2
};
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"variable_batch_test.onnx"
,
options
);
}));
}
TEST_CASE
(
variable_batch_user_input_test6
)
{
// Error using both map_dyn_input_dims and map_input_dims
migraphx
::
onnx_options
options
;
options
.
map_dyn_input_dims
[
"0"
]
=
{{
2
,
5
},
{
3
,
3
},
{
16
,
16
},
{
16
,
16
}};
options
.
map_input_dims
[
"0"
]
=
{
2
,
3
,
16
,
16
};
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"variable_batch_test.onnx"
,
options
);
}));
}
TEST_CASE
(
variable_batch_user_input_test7
)
{
// if entry in map_dyn_input_dims is all fixed dynamic_dimensions, convert it to a static
// shape
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
16
,
16
}});
auto
r
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"identity"
),
l0
);
mm
->
add_return
({
r
});
migraphx
::
onnx_options
options
;
options
.
map_dyn_input_dims
[
"0"
]
=
{{
2
,
2
,
{
2
}},
{
3
,
3
},
{
16
,
16
},
{
16
,
16
}};
auto
prog
=
migraphx
::
parse_onnx
(
"variable_batch_test.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/where_dyn_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
where_dyn_test
)
{
// TODO: broadcasting for dynamic shapes isn't implemented at time of writing.
// Update this test case to use shapes that require broadcasting, when available.
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
lc
=
mm
->
add_parameter
(
"c"
,
migraphx
::
shape
{
migraphx
::
shape
::
bool_type
,
{{
1
,
4
},
{
2
,
2
},
{
2
,
2
}}});
auto
lx
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
},
{
2
,
2
},
{
2
,
2
}}});
auto
ly
=
mm
->
add_parameter
(
"y"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
},
{
2
,
2
},
{
2
,
2
}}});
auto
r
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"where"
),
lc
,
lx
,
ly
);
mm
->
add_return
({
r
});
migraphx
::
onnx_options
options
;
options
.
default_dyn_dim_value
=
{
1
,
4
};
auto
prog
=
parse_onnx
(
"where_dyn_test.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/where_mixed_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
where_mixed_test
)
{
// mixture of static and dynamic input shapes is not supported
migraphx
::
onnx_options
options
;
options
.
default_dyn_dim_value
=
{
1
,
4
};
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"where_mixed_test.onnx"
,
options
);
}));
}
test/onnx/parse/where_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
where_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
lc
=
mm
->
add_parameter
(
"c"
,
migraphx
::
shape
{
migraphx
::
shape
::
bool_type
,
{
2
}});
auto
lx
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
2
,
2
}});
auto
ly
=
mm
->
add_parameter
(
"y"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
1
,
2
,
2
}});
auto
lccm
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
2
,
2
,
2
,
2
}}}),
lc
);
auto
lxm
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
2
,
2
,
2
,
2
}}}),
lx
);
auto
lym
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
2
,
2
,
2
,
2
}}}),
ly
);
auto
r
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"where"
),
lccm
,
lxm
,
lym
);
mm
->
add_return
({
r
});
auto
prog
=
migraphx
::
parse_onnx
(
"where_test.onnx"
);
EXPECT
(
p
==
prog
);
}
Prev
1
…
21
22
23
24
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