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
383 additions
and
0 deletions
+383
-0
test/onnx/parse/randomuniform_dtype_error_test.cpp
test/onnx/parse/randomuniform_dtype_error_test.cpp
+10
-0
test/onnx/parse/randomuniform_generated_seed_test.cpp
test/onnx/parse/randomuniform_generated_seed_test.cpp
+13
-0
test/onnx/parse/randomuniform_shape_error_test.cpp
test/onnx/parse/randomuniform_shape_error_test.cpp
+10
-0
test/onnx/parse/randomuniform_test.cpp
test/onnx/parse/randomuniform_test.cpp
+29
-0
test/onnx/parse/randomuniformlike_test.cpp
test/onnx/parse/randomuniformlike_test.cpp
+30
-0
test/onnx/parse/randomuniformlike_type_error_test.cpp
test/onnx/parse/randomuniformlike_type_error_test.cpp
+10
-0
test/onnx/parse/range_float_test.cpp
test/onnx/parse/range_float_test.cpp
+19
-0
test/onnx/parse/range_test.cpp
test/onnx/parse/range_test.cpp
+19
-0
test/onnx/parse/recip_test.cpp
test/onnx/parse/recip_test.cpp
+17
-0
test/onnx/parse/reduce_log_sum_exp_test.cpp
test/onnx/parse/reduce_log_sum_exp_test.cpp
+18
-0
test/onnx/parse/reduce_log_sum_test.cpp
test/onnx/parse/reduce_log_sum_test.cpp
+17
-0
test/onnx/parse/reducel1_dyn_test.cpp
test/onnx/parse/reducel1_dyn_test.cpp
+49
-0
test/onnx/parse/reducel1_test.cpp
test/onnx/parse/reducel1_test.cpp
+18
-0
test/onnx/parse/reducel2_test.cpp
test/onnx/parse/reducel2_test.cpp
+19
-0
test/onnx/parse/reducemax_dyn_test.cpp
test/onnx/parse/reducemax_dyn_test.cpp
+23
-0
test/onnx/parse/reducemax_test.cpp
test/onnx/parse/reducemax_test.cpp
+16
-0
test/onnx/parse/reducemean_keepdims_test.cpp
test/onnx/parse/reducemean_keepdims_test.cpp
+16
-0
test/onnx/parse/reducemean_test.cpp
test/onnx/parse/reducemean_test.cpp
+17
-0
test/onnx/parse/reducemin_test.cpp
test/onnx/parse/reducemin_test.cpp
+17
-0
test/onnx/parse/reduceprod_test.cpp
test/onnx/parse/reduceprod_test.cpp
+16
-0
No files found.
test/onnx/parse/randomuniform_dtype_error_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
randomuniform_dtype_error_test
)
{
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"randomuniform_dtype_error_test.onnx"
);
}));
}
test/onnx/parse/randomuniform_generated_seed_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
randomuniform_generated_seed_test
)
{
auto
p1
=
optimize_onnx
(
"randomuniform_generated_seed_test.onnx"
);
auto
p2
=
optimize_onnx
(
"randomuniform_generated_seed_test.onnx"
);
EXPECT
(
p1
!=
p2
);
}
test/onnx/parse/randomuniform_shape_error_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
randomuniform_shape_error_test
)
{
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"randomuniform_shape_error_test.onnx"
);
}));
}
test/onnx/parse/randomuniform_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <random>
TEST_CASE
(
randomuniform_test
)
{
float
high
=
1.0
;
float
low
=
0.0
;
float
seed
=
0.0
;
std
::
vector
<
int
>
shape_attr
{
2
,
3
,
4
};
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
double_type
,
shape_attr
};
std
::
vector
<
double
>
rand_vals
(
s
.
elements
());
std
::
mt19937
gen
(
seed
);
std
::
uniform_real_distribution
<>
d
(
low
,
high
);
std
::
generate
(
rand_vals
.
begin
(),
rand_vals
.
end
(),
[
&
]()
{
return
d
(
gen
);
});
mm
->
add_literal
(
migraphx
::
literal
{
s
,
rand_vals
});
auto
prog
=
optimize_onnx
(
"randomuniform_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/randomuniformlike_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <random>
TEST_CASE
(
randomuniformlike_test
)
{
float
high
=
10.0
;
float
low
=
1.0
;
float
seed
=
0.0
;
std
::
vector
<
int
>
shape_attr
{
2
,
3
,
4
};
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
half_type
,
shape_attr
};
std
::
vector
<
double
>
rand_vals
(
s
.
elements
());
std
::
mt19937
gen
(
seed
);
std
::
uniform_real_distribution
<>
d
(
low
,
high
);
std
::
generate
(
rand_vals
.
begin
(),
rand_vals
.
end
(),
[
&
]()
{
return
d
(
gen
);
});
mm
->
add_parameter
(
"input"
,
s
);
mm
->
add_literal
(
migraphx
::
literal
{
s
,
rand_vals
});
auto
prog
=
optimize_onnx
(
"randomuniformlike_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/randomuniformlike_type_error_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
randomuniformlike_type_error_test
)
{
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"randomuniformlike_type_error_test.onnx"
);
}));
}
test/onnx/parse/range_float_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
range_float_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
mm
->
add_literal
(
float
{
2
});
mm
->
add_literal
(
float
{
11
});
mm
->
add_literal
(
float
{
2
});
mm
->
add_literal
(
migraphx
::
literal
{{
migraphx
::
shape
::
float_type
,
{
5
}},
{
2
,
4
,
6
,
8
,
10
}});
auto
prog
=
optimize_onnx
(
"range_float_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/range_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
range_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
mm
->
add_literal
(
int64_t
{
10
});
mm
->
add_literal
(
int64_t
{
6
});
mm
->
add_literal
(
int64_t
{
-
3
});
mm
->
add_literal
(
migraphx
::
literal
{{
migraphx
::
shape
::
int64_type
,
{
2
}},
{
10
,
7
}});
auto
prog
=
optimize_onnx
(
"range_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/recip_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
recip_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
input
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"recip"
),
input
);
auto
prog
=
optimize_onnx
(
"recip_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/reduce_log_sum_exp_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
reduce_log_sum_exp_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
4
,
5
,
6
}});
auto
exp_l0
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"exp"
),
l0
);
auto
sum_l0
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reduce_sum"
,
{{
"axes"
,
{
-
4
}}}),
exp_l0
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"log"
),
sum_l0
);
auto
prog
=
optimize_onnx
(
"reduce_log_sum_exp_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/reduce_log_sum_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
reduce_log_sum_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
4
,
5
,
6
}});
auto
sum_l0
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reduce_sum"
,
{{
"axes"
,
{
-
3
}}}),
l0
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"log"
),
sum_l0
);
auto
prog
=
optimize_onnx
(
"reduce_log_sum_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/reducel1_dyn_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
reducel1_dyn_test
)
{
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
// a shape with 4 dynamic dimensions
auto
l0
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
3
,
3
},
{
3
,
5
},
{
4
,
6
,
{
5
}},
{
5
,
7
,
{
6
}}}});
auto
abs_ins
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"abs"
),
l0
);
auto
sum_ins
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reduce_sum"
,
{{
"axes"
,
{
-
2
}}}),
abs_ins
);
auto
sq_ins
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"squeeze"
,
{{
"axes"
,
{
-
2
}}}),
sum_ins
);
mm
->
add_return
({
sq_ins
});
migraphx
::
onnx_options
options
;
options
.
map_dyn_input_dims
[
"x"
]
=
{{
3
,
3
},
{
3
,
5
},
{
4
,
6
,
{
5
}},
{
5
,
7
,
{
6
}}};
auto
prog
=
migraphx
::
parse_onnx
(
"reducel1_dyn_test.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
// No axes given in the onnx file. Parser should default to all axes.
auto
l0
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
3
,
3
},
{
3
,
5
},
{
4
,
6
,
{
5
}},
{
5
,
7
,
{
6
}}}});
auto
abs_ins
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"abs"
),
l0
);
auto
sum_ins
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reduce_sum"
,
{{
"axes"
,
{
0
,
1
,
2
,
3
}}}),
abs_ins
);
auto
sq_ins
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"squeeze"
,
{{
"axes"
,
{
0
,
1
,
2
,
3
}}}),
sum_ins
);
mm
->
add_return
({
sq_ins
});
migraphx
::
onnx_options
options
;
options
.
map_dyn_input_dims
[
"x"
]
=
{{
3
,
3
},
{
3
,
5
},
{
4
,
6
,
{
5
}},
{
5
,
7
,
{
6
}}};
auto
prog
=
migraphx
::
parse_onnx
(
"reducel1_dyn_noaxes_test.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
}
test/onnx/parse/reducel1_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
reducel1_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
4
,
5
,
6
}});
auto
abs_l0
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"abs"
),
l0
);
auto
sum_l0
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reduce_sum"
,
{{
"axes"
,
{
-
2
}}}),
abs_l0
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"squeeze"
,
{{
"axes"
,
{
-
2
}}}),
sum_l0
);
auto
prog
=
optimize_onnx
(
"reducel1_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/reducel2_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
reducel2_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
4
,
5
,
6
}});
auto
square_l0
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
l0
,
l0
);
auto
sum_l0
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reduce_sum"
,
{{
"axes"
,
{
-
1
}}}),
square_l0
);
auto
squ_l0
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"squeeze"
,
{{
"axes"
,
{
-
1
}}}),
sum_l0
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"sqrt"
),
squ_l0
);
auto
prog
=
optimize_onnx
(
"reducel2_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/reducemax_dyn_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
reducemax_dyn_test
)
{
// input shape with 4 dynamic dimensions
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
3
,
5
},
{
4
,
4
},
{
5
,
5
},
{
6
,
6
}}});
auto
r0
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reduce_max"
,
{{
"axes"
,
{
2
}}}),
l0
);
auto
r1
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"squeeze"
,
{{
"axes"
,
{
2
}}}),
r0
);
mm
->
add_return
({
r1
});
migraphx
::
onnx_options
options
;
options
.
map_dyn_input_dims
[
"x"
]
=
{{
3
,
5
},
{
4
,
4
},
{
5
,
5
},
{
6
,
6
}};
auto
prog
=
migraphx
::
parse_onnx
(
"reducemax_dyn_test.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/reducemax_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
reducemax_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
4
,
5
,
6
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"reduce_max"
,
{{
"axes"
,
{
2
}}}),
l0
);
auto
prog
=
optimize_onnx
(
"reducemax_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/reducemean_keepdims_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
reducemean_keepdims_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
4
,
5
,
6
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"reduce_mean"
,
{{
"axes"
,
{
2
}}}),
l0
);
auto
prog
=
optimize_onnx
(
"reducemean_keepdims_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/reducemean_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
reducemean_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
4
,
5
,
6
}});
auto
l1
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reduce_mean"
,
{{
"axes"
,
{
2
,
3
}}}),
l0
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"squeeze"
,
{{
"axes"
,
{
2
,
3
}}}),
l1
);
auto
prog
=
optimize_onnx
(
"reducemean_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/reducemin_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
reducemin_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
4
,
5
,
6
}});
auto
l1
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reduce_min"
,
{{
"axes"
,
{
2
,
3
}}}),
l0
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"squeeze"
,
{{
"axes"
,
{
2
,
3
}}}),
l1
);
auto
prog
=
optimize_onnx
(
"reducemin_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/reduceprod_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
reduceprod_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
4
,
5
,
6
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"reduce_prod"
,
{{
"axes"
,
{
2
}}}),
l0
);
auto
prog
=
optimize_onnx
(
"reduceprod_test.onnx"
);
EXPECT
(
p
==
prog
);
}
Prev
1
…
14
15
16
17
18
19
20
21
22
…
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