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
380 additions
and
0 deletions
+380
-0
test/onnx/parse/elu_test.cpp
test/onnx/parse/elu_test.cpp
+17
-0
test/onnx/parse/embedding_bag_offset_test.cpp
test/onnx/parse/embedding_bag_offset_test.cpp
+10
-0
test/onnx/parse/embedding_bag_test.cpp
test/onnx/parse/embedding_bag_test.cpp
+26
-0
test/onnx/parse/equal_bool_test.cpp
test/onnx/parse/equal_bool_test.cpp
+26
-0
test/onnx/parse/equal_test.cpp
test/onnx/parse/equal_test.cpp
+26
-0
test/onnx/parse/erf_test.cpp
test/onnx/parse/erf_test.cpp
+16
-0
test/onnx/parse/exp_test.cpp
test/onnx/parse/exp_test.cpp
+16
-0
test/onnx/parse/expand_test.cpp
test/onnx/parse/expand_test.cpp
+19
-0
test/onnx/parse/ext_path_external_data_test.cpp
test/onnx/parse/ext_path_external_data_test.cpp
+14
-0
test/onnx/parse/external_constant_test.cpp
test/onnx/parse/external_constant_test.cpp
+15
-0
test/onnx/parse/external_data_test.cpp
test/onnx/parse/external_data_test.cpp
+14
-0
test/onnx/parse/eyelike_default_test.cpp
test/onnx/parse/eyelike_default_test.cpp
+26
-0
test/onnx/parse/eyelike_double_test.cpp
test/onnx/parse/eyelike_double_test.cpp
+26
-0
test/onnx/parse/eyelike_half_test.cpp
test/onnx/parse/eyelike_half_test.cpp
+26
-0
test/onnx/parse/eyelike_k_outofbounds_neg_test.cpp
test/onnx/parse/eyelike_k_outofbounds_neg_test.cpp
+10
-0
test/onnx/parse/eyelike_k_outofbounds_pos_test.cpp
test/onnx/parse/eyelike_k_outofbounds_pos_test.cpp
+10
-0
test/onnx/parse/eyelike_k_test.cpp
test/onnx/parse/eyelike_k_test.cpp
+26
-0
test/onnx/parse/eyelike_not_rank2_test.cpp
test/onnx/parse/eyelike_not_rank2_test.cpp
+10
-0
test/onnx/parse/eyelike_set_dtype_test.cpp
test/onnx/parse/eyelike_set_dtype_test.cpp
+26
-0
test/onnx/parse/flatten_dyn_test.cpp
test/onnx/parse/flatten_dyn_test.cpp
+21
-0
No files found.
test/onnx/parse/elu_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
elu_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
input
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"elu"
,
{{
"alpha"
,
0.01
}}),
input
);
auto
prog
=
optimize_onnx
(
"elu_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/embedding_bag_offset_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
embedding_bag_offset_test
)
{
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"embedding_bag_offset_test.onnx"
);
}));
}
test/onnx/parse/embedding_bag_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
embedding_bag_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"weight"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
,
2
}});
migraphx
::
literal
l
{
migraphx
::
shape
{
migraphx
::
shape
::
int32_type
,
{
3
}},
{
1
,
0
,
2
}};
auto
l1
=
mm
->
add_literal
(
l
);
mm
->
add_literal
(
0
);
auto
l4
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"gather"
),
l0
,
l1
);
auto
r1
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reduce_sum"
,
{{
"axes"
,
{
0
}}}),
l4
);
auto
l5
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"gather"
),
l0
,
l1
);
auto
r2
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reduce_mean"
,
{{
"axes"
,
{
0
}}}),
l5
);
auto
l6
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"gather"
),
l0
,
l1
);
auto
r3
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reduce_max"
,
{{
"axes"
,
{
0
}}}),
l6
);
mm
->
add_return
({
r1
,
r2
,
r3
});
auto
prog
=
migraphx
::
parse_onnx
(
"embedding_bag_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/equal_bool_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
equal_bool_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
sf
{
migraphx
::
shape
::
float_type
,
{
2
,
3
}};
migraphx
::
shape
sb
{
migraphx
::
shape
::
bool_type
,
{
2
,
3
}};
auto
input1
=
mm
->
add_parameter
(
"x1"
,
sf
);
auto
input2
=
mm
->
add_parameter
(
"x2"
,
sb
);
auto
cin1
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
to_value
(
migraphx
::
shape
::
bool_type
)}}),
input1
);
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"equal"
),
cin1
,
input2
);
mm
->
add_return
({
ret
});
auto
prog
=
migraphx
::
parse_onnx
(
"equal_bool_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/equal_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
equal_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
2
,
3
}};
std
::
vector
<
float
>
data
=
{
1.0
f
,
2.0
f
,
3.0
f
,
4.0
f
,
5.0
f
,
6.0
f
};
auto
input1
=
mm
->
add_literal
(
migraphx
::
literal
(
s
,
data
));
auto
input2
=
mm
->
add_parameter
(
"x2"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
3
}});
auto
eq
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"equal"
),
input1
,
input2
);
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
to_value
(
migraphx
::
shape
::
bool_type
)}}),
eq
);
mm
->
add_return
({
ret
});
auto
prog
=
migraphx
::
parse_onnx
(
"equal_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/erf_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
erf_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
input
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
10
,
15
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"erf"
),
input
);
auto
prog
=
optimize_onnx
(
"erf_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/exp_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
exp_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
(
"exp"
),
input
);
auto
prog
=
optimize_onnx
(
"exp_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/expand_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
expand_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
(
migraphx
::
shape
::
float_type
,
{
3
,
1
,
1
});
auto
param
=
mm
->
add_parameter
(
"x"
,
s
);
migraphx
::
shape
ss
(
migraphx
::
shape
::
int32_type
,
{
4
});
mm
->
add_literal
(
migraphx
::
literal
(
ss
,
{
2
,
3
,
4
,
5
}));
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
2
,
3
,
4
,
5
}}}),
param
);
auto
prog
=
optimize_onnx
(
"expand_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/ext_path_external_data_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <onnx_test_utils.hpp>
TEST_CASE
(
external_data_diff_path_test
)
{
migraphx
::
program
p
=
create_external_data_prog
();
auto
prog
=
optimize_onnx
(
"ext_path/external_data_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/external_constant_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
external_constant_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
mm
->
add_literal
(
migraphx
::
literal
{{
migraphx
::
shape
::
int64_type
,
{
3
}},
{
0
,
1
,
2
}});
auto
prog
=
optimize_onnx
(
"external_constant_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/external_data_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <onnx_test_utils.hpp>
TEST_CASE
(
external_data_test
)
{
migraphx
::
program
p
=
create_external_data_prog
();
auto
prog
=
optimize_onnx
(
"external_data_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/eyelike_default_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <onnx_test_utils.hpp>
TEST_CASE
(
eyelike_default_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
std
::
vector
<
std
::
size_t
>
input_lens
{
3
,
4
};
const
size_t
k
=
0
;
auto
num_rows
=
input_lens
.
front
();
auto
num_cols
=
input_lens
.
back
();
auto
input_type
=
migraphx
::
shape
::
float_type
;
auto
output_type
=
migraphx
::
shape
::
float_type
;
migraphx
::
shape
s
{
input_type
,
input_lens
};
mm
->
add_parameter
(
"T1"
,
s
);
auto
eyelike_mat
=
make_r_eyelike
(
num_rows
,
num_cols
,
k
);
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
output_type
,
input_lens
},
eyelike_mat
});
auto
prog
=
optimize_onnx
(
"eyelike_default_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/eyelike_double_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <onnx_test_utils.hpp>
TEST_CASE
(
eyelike_double_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
std
::
vector
<
std
::
size_t
>
input_lens
{
6
,
15
};
const
size_t
k
=
0
;
auto
num_rows
=
input_lens
.
front
();
auto
num_cols
=
input_lens
.
back
();
auto
input_type
=
migraphx
::
shape
::
double_type
;
auto
output_type
=
migraphx
::
shape
::
double_type
;
migraphx
::
shape
s
{
input_type
,
input_lens
};
mm
->
add_parameter
(
"T1"
,
s
);
auto
eyelike_mat
=
make_r_eyelike
(
num_rows
,
num_cols
,
k
);
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
output_type
,
input_lens
},
eyelike_mat
});
auto
prog
=
optimize_onnx
(
"eyelike_double_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/eyelike_half_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <onnx_test_utils.hpp>
TEST_CASE
(
eyelike_half_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
std
::
vector
<
std
::
size_t
>
input_lens
{
8
,
8
};
const
size_t
k
=
0
;
auto
num_rows
=
input_lens
.
front
();
auto
num_cols
=
input_lens
.
back
();
auto
input_type
=
migraphx
::
shape
::
half_type
;
auto
output_type
=
migraphx
::
shape
::
half_type
;
migraphx
::
shape
s
{
input_type
,
input_lens
};
mm
->
add_parameter
(
"T1"
,
s
);
auto
eyelike_mat
=
make_r_eyelike
(
num_rows
,
num_cols
,
k
);
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
output_type
,
input_lens
},
eyelike_mat
});
auto
prog
=
optimize_onnx
(
"eyelike_half_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/eyelike_k_outofbounds_neg_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
eyelike_k_outofbounds_neg_test
)
{
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"eyelike_k_outofbounds_neg_test.onnx"
);
}));
}
test/onnx/parse/eyelike_k_outofbounds_pos_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
eyelike_k_outofbounds_pos_test
)
{
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"eyelike_k_outofbounds_pos_test.onnx"
);
}));
}
test/onnx/parse/eyelike_k_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <onnx_test_utils.hpp>
TEST_CASE
(
eyelike_k_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
std
::
vector
<
std
::
size_t
>
input_lens
{
3
,
4
};
const
size_t
k
=
1
;
auto
num_rows
=
input_lens
.
front
();
auto
num_cols
=
input_lens
.
back
();
auto
input_type
=
migraphx
::
shape
::
float_type
;
auto
output_type
=
migraphx
::
shape
::
float_type
;
migraphx
::
shape
s
{
input_type
,
input_lens
};
mm
->
add_parameter
(
"T1"
,
s
);
auto
eyelike_mat
=
make_r_eyelike
(
num_rows
,
num_cols
,
k
);
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
output_type
,
input_lens
},
eyelike_mat
});
auto
prog
=
optimize_onnx
(
"eyelike_k_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/eyelike_not_rank2_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
eyelike_not_rank2_test
)
{
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"eyelike_not_rank2_test.onnx"
);
}));
}
test/onnx/parse/eyelike_set_dtype_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <onnx_test_utils.hpp>
TEST_CASE
(
eyelike_set_dtype_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
std
::
vector
<
std
::
size_t
>
input_lens
{
3
,
4
};
const
size_t
k
=
0
;
auto
num_rows
=
input_lens
.
front
();
auto
num_cols
=
input_lens
.
back
();
auto
input_type
=
migraphx
::
shape
::
float_type
;
auto
output_type
=
migraphx
::
shape
::
double_type
;
migraphx
::
shape
s
{
input_type
,
input_lens
};
mm
->
add_parameter
(
"T1"
,
s
);
auto
eyelike_mat
=
make_r_eyelike
(
num_rows
,
num_cols
,
k
);
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
output_type
,
input_lens
},
eyelike_mat
});
auto
prog
=
optimize_onnx
(
"eyelike_set_dtype_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/flatten_dyn_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
flatten_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
},
{
5
,
5
}}});
auto
c0
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"contiguous"
),
l0
);
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"flatten"
,
{{
"axis"
,
2
}}),
c0
);
mm
->
add_return
({
ret
});
migraphx
::
onnx_options
options
;
options
.
default_dyn_dim_value
=
{
1
,
4
};
auto
prog
=
parse_onnx
(
"flatten_dyn_test.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
Prev
1
…
3
4
5
6
7
8
9
10
11
…
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