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
377 additions
and
0 deletions
+377
-0
test/onnx/parse/slice_reverse_dyn_test.cpp
test/onnx/parse/slice_reverse_dyn_test.cpp
+14
-0
test/onnx/parse/slice_step_dyn_test.cpp
test/onnx/parse/slice_step_dyn_test.cpp
+14
-0
test/onnx/parse/slice_test.cpp
test/onnx/parse/slice_test.cpp
+17
-0
test/onnx/parse/slice_var_input_default_steps.cpp
test/onnx/parse/slice_var_input_default_steps.cpp
+24
-0
test/onnx/parse/slice_var_input_dyn0.cpp
test/onnx/parse/slice_var_input_dyn0.cpp
+23
-0
test/onnx/parse/slice_var_input_dyn1.cpp
test/onnx/parse/slice_var_input_dyn1.cpp
+23
-0
test/onnx/parse/slice_var_input_static0.cpp
test/onnx/parse/slice_var_input_static0.cpp
+18
-0
test/onnx/parse/slice_var_input_static1.cpp
test/onnx/parse/slice_var_input_static1.cpp
+19
-0
test/onnx/parse/slice_var_input_steps_error.cpp
test/onnx/parse/slice_var_input_steps_error.cpp
+10
-0
test/onnx/parse/softmax_dyn_test.cpp
test/onnx/parse/softmax_dyn_test.cpp
+21
-0
test/onnx/parse/softmax_nonstd_input_test.cpp
test/onnx/parse/softmax_nonstd_input_test.cpp
+20
-0
test/onnx/parse/softmax_test.cpp
test/onnx/parse/softmax_test.cpp
+16
-0
test/onnx/parse/softplus_nd_test.cpp
test/onnx/parse/softplus_nd_test.cpp
+25
-0
test/onnx/parse/softplus_test.cpp
test/onnx/parse/softplus_test.cpp
+25
-0
test/onnx/parse/softsign_nd_test.cpp
test/onnx/parse/softsign_nd_test.cpp
+25
-0
test/onnx/parse/softsign_test.cpp
test/onnx/parse/softsign_test.cpp
+25
-0
test/onnx/parse/spacetodepth_invalid_blocksize_test.cpp
test/onnx/parse/spacetodepth_invalid_blocksize_test.cpp
+10
-0
test/onnx/parse/spacetodepth_nondivisibility_test.cpp
test/onnx/parse/spacetodepth_nondivisibility_test.cpp
+10
-0
test/onnx/parse/spacetodepth_simple_test.cpp
test/onnx/parse/spacetodepth_simple_test.cpp
+19
-0
test/onnx/parse/spacetodepth_test.cpp
test/onnx/parse/spacetodepth_test.cpp
+19
-0
No files found.
test/onnx/parse/slice_reverse_dyn_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
slice_reverse_dyn_test
)
{
// A slice command with negative step on any axis will have a "Reverse" instruction added in
// parsing. At the time of writing, Reverse doesn't support dynamic shape input.
migraphx
::
onnx_options
options
;
options
.
default_dyn_dim_value
=
{
1
,
4
};
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"slice_reverse_dyn_test.onnx"
,
options
);
}));
}
test/onnx/parse/slice_step_dyn_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
slice_step_dyn_test
)
{
// A slice command with non-default steps will have a "Step" instruction added in parsing.
// At the time of writing, Step doesn't support dynamic shape input.
migraphx
::
onnx_options
options
;
options
.
default_dyn_dim_value
=
{
1
,
4
};
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"slice_step_dyn_test.onnx"
,
options
);
}));
}
test/onnx/parse/slice_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
slice_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
2
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"axes"
,
{
0
,
1
}},
{
"starts"
,
{
1
,
0
}},
{
"ends"
,
{
2
,
2
}}}),
l0
);
auto
prog
=
optimize_onnx
(
"slice_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/slice_var_input_default_steps.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
slice_var_input_default_steps
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
data
=
mm
->
add_parameter
(
"data"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
3
,
8
},
{
2
,
2
}}});
auto
starts
=
mm
->
add_parameter
(
"starts"
,
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{
2
}});
auto
ends
=
mm
->
add_parameter
(
"ends"
,
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{
2
}});
auto
axes
=
mm
->
add_parameter
(
"axes"
,
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{
2
}});
mm
->
add_literal
({{
migraphx
::
shape
::
int64_type
,
{
2
}},
{
1
,
1
}});
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"slice"
),
data
,
starts
,
ends
,
axes
);
mm
->
add_return
({
ret
});
migraphx
::
onnx_options
options
;
options
.
default_dyn_dim_value
=
{
3
,
8
};
auto
prog
=
parse_onnx
(
"slice_var_input_default_steps.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/slice_var_input_dyn0.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
slice_var_input_dyn0
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
data
=
mm
->
add_parameter
(
"data"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
3
,
8
},
{
2
,
2
}}});
auto
starts
=
mm
->
add_parameter
(
"starts"
,
migraphx
::
shape
{
migraphx
::
shape
::
int32_type
,
{
2
}});
auto
ends
=
mm
->
add_parameter
(
"ends"
,
migraphx
::
shape
{
migraphx
::
shape
::
int32_type
,
{
2
}});
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"axes"
,
{
0
,
1
}}}),
data
,
starts
,
ends
);
mm
->
add_return
({
ret
});
migraphx
::
onnx_options
options
;
options
.
default_dyn_dim_value
=
{
3
,
8
};
auto
prog
=
parse_onnx
(
"slice_var_input_dyn0.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/slice_var_input_dyn1.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
slice_var_input_dyn1
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
data
=
mm
->
add_parameter
(
"data"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
3
,
8
},
{
2
,
2
}}});
auto
starts
=
mm
->
add_parameter
(
"starts"
,
migraphx
::
shape
{
migraphx
::
shape
::
int32_type
,
{
2
}});
auto
ends
=
mm
->
add_parameter
(
"ends"
,
migraphx
::
shape
{
migraphx
::
shape
::
int32_type
,
{
2
}});
auto
axes
=
mm
->
add_parameter
(
"axes"
,
migraphx
::
shape
{
migraphx
::
shape
::
int32_type
,
{
2
}});
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"slice"
),
data
,
starts
,
ends
,
axes
);
mm
->
add_return
({
ret
});
migraphx
::
onnx_options
options
;
options
.
default_dyn_dim_value
=
{
3
,
8
};
auto
prog
=
parse_onnx
(
"slice_var_input_dyn1.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/slice_var_input_static0.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
slice_var_input_static0
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
data
=
mm
->
add_parameter
(
"data"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
2
}});
auto
starts
=
mm
->
add_parameter
(
"starts"
,
migraphx
::
shape
{
migraphx
::
shape
::
int32_type
,
{
2
}});
auto
ends
=
mm
->
add_parameter
(
"ends"
,
migraphx
::
shape
{
migraphx
::
shape
::
int32_type
,
{
2
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"axes"
,
{
0
,
1
}}}),
data
,
starts
,
ends
);
auto
prog
=
optimize_onnx
(
"slice_var_input_static0.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/slice_var_input_static1.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
slice_var_input_static1
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
data
=
mm
->
add_parameter
(
"data"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
2
}});
auto
starts
=
mm
->
add_parameter
(
"starts"
,
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{
2
}});
auto
ends
=
mm
->
add_parameter
(
"ends"
,
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{
2
}});
auto
axes
=
mm
->
add_parameter
(
"axes"
,
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{
2
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"slice"
),
data
,
starts
,
ends
,
axes
);
auto
prog
=
optimize_onnx
(
"slice_var_input_static1.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/slice_var_input_steps_error.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
slice_var_input_steps_error
)
{
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"slice_var_input_steps_error.onnx"
);
}));
}
test/onnx/parse/softmax_dyn_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
softmax_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
},
{
3
,
3
},
{
4
,
4
},
{
4
,
4
}}});
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"softmax"
,
{{
"axis"
,
-
1
}}),
l0
);
mm
->
add_return
({
ret
});
migraphx
::
onnx_options
options
;
options
.
default_dyn_dim_value
=
{
1
,
4
};
auto
prog
=
migraphx
::
parse_onnx
(
"softmax_dyn_test.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/softmax_nonstd_input_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
softmax_nonstd_input_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
6
,
8
}});
auto
l1
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"axes"
,
{
0
,
1
}},
{
"starts"
,
{
1
,
0
}},
{
"ends"
,
{
4
,
4
}}}),
l0
);
auto
l2
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"softmax"
,
{{
"axis"
,
-
1
}}),
l1
);
mm
->
add_return
({
l2
});
auto
prog
=
migraphx
::
parse_onnx
(
"softmax_nonstd_input_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/softmax_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
softmax_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
3
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"softmax"
,
{{
"axis"
,
1
}}),
l0
);
auto
prog
=
optimize_onnx
(
"softmax_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/softplus_nd_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
softplus_nd_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
std
::
vector
<
std
::
size_t
>
input_lens
{
3
,
4
,
5
};
auto
input_type
=
migraphx
::
shape
::
half_type
;
auto
x
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
input_type
,
input_lens
});
auto
mb_ones
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
input_lens
}}),
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
input_type
},
{
1
}}));
auto
exp
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"exp"
),
x
);
auto
add
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
exp
,
mb_ones
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"log"
),
add
);
auto
prog
=
optimize_onnx
(
"softplus_nd_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/softplus_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
softplus_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
std
::
vector
<
std
::
size_t
>
input_lens
{
5
};
auto
input_type
=
migraphx
::
shape
::
float_type
;
auto
x
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
input_type
,
input_lens
});
auto
mb_ones
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
input_lens
}}),
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
input_type
},
{
1
}}));
auto
exp
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"exp"
),
x
);
auto
add
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
exp
,
mb_ones
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"log"
),
add
);
auto
prog
=
optimize_onnx
(
"softplus_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/softsign_nd_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
softsign_nd_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
std
::
vector
<
std
::
size_t
>
input_lens
{
3
,
4
,
5
};
auto
input_type
=
migraphx
::
shape
::
half_type
;
auto
x
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
input_type
,
input_lens
});
auto
mb_ones
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
input_lens
}}),
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
input_type
},
{
1
}}));
auto
abs
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"abs"
),
x
);
auto
add
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
abs
,
mb_ones
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"div"
),
x
,
add
);
auto
prog
=
optimize_onnx
(
"softsign_nd_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/softsign_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
softsign_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
std
::
vector
<
std
::
size_t
>
input_lens
{
5
};
auto
input_type
=
migraphx
::
shape
::
float_type
;
auto
x
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
input_type
,
input_lens
});
auto
mb_ones
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
input_lens
}}),
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
input_type
},
{
1
}}));
auto
abs
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"abs"
),
x
);
auto
add
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
abs
,
mb_ones
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"div"
),
x
,
add
);
auto
prog
=
optimize_onnx
(
"softsign_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/spacetodepth_invalid_blocksize_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
spacetodepth_invalid_blocksize
)
{
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"spacetodepth_invalid_blocksize_test.onnx"
);
}));
}
test/onnx/parse/spacetodepth_nondivisibility_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
spacetodepth_nondivisibility_test
)
{
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"spacetodepth_nondivisibility_test.onnx"
);
}));
}
test/onnx/parse/spacetodepth_simple_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
spacetodepth_simple_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"x"
,
{
migraphx
::
shape
::
float_type
,
{
1
,
2
,
4
,
6
}});
auto
tmp1
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reshape"
,
{{
"dims"
,
{
1
,
2
,
2
,
2
,
3
,
2
}}}),
l0
);
auto
tmp2
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
0
,
3
,
5
,
1
,
2
,
4
}}}),
tmp1
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"reshape"
,
{{
"dims"
,
{
1
,
8
,
2
,
3
}}}),
tmp2
);
auto
prog
=
optimize_onnx
(
"spacetodepth_simple_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/spacetodepth_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
spacetodepth_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"x"
,
{
migraphx
::
shape
::
float_type
,
{
2
,
2
,
10
,
10
}});
auto
tmp1
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reshape"
,
{{
"dims"
,
{
2
,
2
,
5
,
2
,
5
,
2
}}}),
l0
);
auto
tmp2
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
0
,
3
,
5
,
1
,
2
,
4
}}}),
tmp1
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"reshape"
,
{{
"dims"
,
{
2
,
8
,
5
,
5
}}}),
tmp2
);
auto
prog
=
optimize_onnx
(
"spacetodepth_test.onnx"
);
EXPECT
(
p
==
prog
);
}
Prev
1
…
18
19
20
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