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
502 additions
and
0 deletions
+502
-0
test/onnx/parse/implicit_add_bcast_test.cpp
test/onnx/parse/implicit_add_bcast_test.cpp
+39
-0
test/onnx/parse/implicit_pow_bcast_test.cpp
test/onnx/parse/implicit_pow_bcast_test.cpp
+20
-0
test/onnx/parse/implicit_sub_bcast_test.cpp
test/onnx/parse/implicit_sub_bcast_test.cpp
+20
-0
test/onnx/parse/initializer_not_an_input.cpp
test/onnx/parse/initializer_not_an_input.cpp
+19
-0
test/onnx/parse/instance_norm_dyn_batch_half_test.cpp
test/onnx/parse/instance_norm_dyn_batch_half_test.cpp
+54
-0
test/onnx/parse/instance_norm_dyn_batch_test.cpp
test/onnx/parse/instance_norm_dyn_batch_test.cpp
+41
-0
test/onnx/parse/instance_norm_half_test.cpp
test/onnx/parse/instance_norm_half_test.cpp
+52
-0
test/onnx/parse/instance_norm_invalid_type_test.cpp
test/onnx/parse/instance_norm_invalid_type_test.cpp
+10
-0
test/onnx/parse/instance_norm_nonbroadcastable_test.cpp
test/onnx/parse/instance_norm_nonbroadcastable_test.cpp
+10
-0
test/onnx/parse/instance_norm_test.cpp
test/onnx/parse/instance_norm_test.cpp
+44
-0
test/onnx/parse/instance_norm_type_mismatch_test.cpp
test/onnx/parse/instance_norm_type_mismatch_test.cpp
+10
-0
test/onnx/parse/isinf_double_pos_test.cpp
test/onnx/parse/isinf_double_pos_test.cpp
+29
-0
test/onnx/parse/isinf_half_test.cpp
test/onnx/parse/isinf_half_test.cpp
+18
-0
test/onnx/parse/isinf_neg_test.cpp
test/onnx/parse/isinf_neg_test.cpp
+29
-0
test/onnx/parse/isinf_no_detect_test.cpp
test/onnx/parse/isinf_no_detect_test.cpp
+20
-0
test/onnx/parse/isnan_float_test.cpp
test/onnx/parse/isnan_float_test.cpp
+18
-0
test/onnx/parse/isnan_half_test.cpp
test/onnx/parse/isnan_half_test.cpp
+18
-0
test/onnx/parse/layer_norm_2d_axis_one_test.cpp
test/onnx/parse/layer_norm_2d_axis_one_test.cpp
+22
-0
test/onnx/parse/layer_norm_2d_axis_zero_test.cpp
test/onnx/parse/layer_norm_2d_axis_zero_test.cpp
+14
-0
test/onnx/parse/layer_norm_3d_half_test.cpp
test/onnx/parse/layer_norm_3d_half_test.cpp
+15
-0
No files found.
test/onnx/parse/implicit_add_bcast_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
implicit_add_bcast_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
,
1
}});
auto
l3
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
2
,
3
,
4
,
5
}}}),
l1
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
l0
,
l3
);
auto
prog
=
optimize_onnx
(
"implicit_add_bcast_test.onnx"
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
implicit_add_bcast_user_input_shape_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
4
,
5
,
6
}});
auto
l1
=
mm
->
add_parameter
(
"1"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
,
5
,
1
}});
auto
l3
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
3
,
4
,
5
,
6
}}}),
l1
);
auto
r
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
l0
,
l3
);
mm
->
add_return
({
r
});
migraphx
::
onnx_options
options
;
options
.
map_input_dims
[
"0"
]
=
{
3
,
4
,
5
,
6
};
options
.
map_input_dims
[
"1"
]
=
{
4
,
5
,
1
};
auto
prog
=
migraphx
::
parse_onnx
(
"implicit_add_bcast_test.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/implicit_pow_bcast_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
implicit_pow_bcast_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
,
1
}});
auto
l3
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
2
,
3
,
4
,
5
}}}),
l1
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"pow"
),
l0
,
l3
);
auto
prog
=
optimize_onnx
(
"implicit_pow_bcast_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/implicit_sub_bcast_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
implicit_sub_bcast_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
uint64_type
,
{
2
,
3
,
4
,
5
}});
auto
l1
=
mm
->
add_parameter
(
"1"
,
migraphx
::
shape
{
migraphx
::
shape
::
uint64_type
,
{
4
,
5
}});
auto
l3
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
2
,
3
,
4
,
5
}}}),
l1
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"sub"
),
l0
,
l3
);
auto
prog
=
optimize_onnx
(
"implicit_sub_bcast_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/initializer_not_an_input.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <migraphx/apply_alpha_beta.hpp>
TEST_CASE
(
initializer_not_an_input
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
std
::
vector
<
float
>
w
=
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
};
auto
l1
=
mm
->
add_literal
(
migraphx
::
literal
({
migraphx
::
shape
::
float_type
,
{
2
,
4
}},
w
));
auto
l0
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
5
,
2
}});
migraphx
::
add_apply_alpha_beta
(
*
mm
,
{
l0
,
l1
},
migraphx
::
make_op
(
"dot"
),
1.0
f
,
0.0
f
);
auto
prog
=
optimize_onnx
(
"initializer_not_an_input.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/instance_norm_dyn_batch_half_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
instance_norm_dyn_batch_half_test
)
{
// instancenorm with half type, dynamic input in the 0'th (batch) dimension
migraphx
::
shape
s1
{
migraphx
::
shape
::
half_type
,
{{
1
,
2
,
{
2
}},
{
2
,
2
},
{
3
,
3
},
{
3
,
3
}}};
migraphx
::
shape
s2
{
migraphx
::
shape
::
half_type
,
{
2
}};
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
x_fp16
=
mm
->
add_parameter
(
"0"
,
s1
);
auto
scale_fp16
=
mm
->
add_parameter
(
"1"
,
s2
);
auto
bias_fp16
=
mm
->
add_parameter
(
"2"
,
s2
);
// conversion of half type to float is enabled by default
auto
x
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
shape
::
float_type
}}),
x_fp16
);
auto
scale
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
shape
::
float_type
}}),
scale_fp16
);
auto
bias
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
shape
::
float_type
}}),
bias_fp16
);
auto
mean
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reduce_mean"
,
{{
"axes"
,
{
2
,
3
}}}),
x
);
auto
l0
=
add_common_op
(
*
mm
,
migraphx
::
make_op
(
"sub"
),
{
x
,
mean
});
auto
l1
=
add_common_op
(
*
mm
,
migraphx
::
make_op
(
"sqdiff"
),
{
x
,
mean
});
auto
variance
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reduce_mean"
,
{{
"axes"
,
{
2
,
3
}}}),
l1
);
// type of epsilon_literal is same as 0'th input; convert instruction will be added by
// add_common_op
auto
epsilon_literal
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
migraphx
::
shape
::
float_type
},
{
1e-5
}});
auto
l2
=
add_common_op
(
*
mm
,
migraphx
::
make_op
(
"add"
),
{
variance
,
epsilon_literal
});
auto
l3
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"rsqrt"
),
l2
);
auto
l4
=
add_common_op
(
*
mm
,
migraphx
::
make_op
(
"mul"
),
{
l0
,
l3
});
auto
scale_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
1
}}),
scale
,
x
);
auto
bias_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
1
}}),
bias
,
x
);
auto
l5
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
l4
,
scale_bcast
);
auto
instance_norm_fp32
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
l5
,
bias_bcast
);
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
shape
::
half_type
}}),
instance_norm_fp32
);
mm
->
add_return
({
ret
});
migraphx
::
onnx_options
options
;
options
.
default_dyn_dim_value
=
{
1
,
2
,
{
2
}};
auto
prog
=
migraphx
::
parse_onnx
(
"instance_norm_dyn_batch_half_test.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/instance_norm_dyn_batch_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
instance_norm_dyn_batch_test
)
{
// instancenorm with dynamic input in the 0'th (batch) dimension
migraphx
::
shape
s1
{
migraphx
::
shape
::
float_type
,
{{
1
,
2
,
{
2
}},
{
2
,
2
},
{
3
,
3
},
{
3
,
3
}}};
migraphx
::
shape
s2
{
migraphx
::
shape
::
float_type
,
{
2
}};
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
x
=
mm
->
add_parameter
(
"0"
,
s1
);
auto
scale
=
mm
->
add_parameter
(
"1"
,
s2
);
auto
bias
=
mm
->
add_parameter
(
"2"
,
s2
);
auto
mean
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reduce_mean"
,
{{
"axes"
,
{
2
,
3
}}}),
x
);
auto
l1
=
add_common_op
(
*
mm
,
migraphx
::
make_op
(
"sub"
),
{
x
,
mean
});
auto
l0
=
add_common_op
(
*
mm
,
migraphx
::
make_op
(
"sqdiff"
),
{
x
,
mean
});
auto
variance
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reduce_mean"
,
{{
"axes"
,
{
2
,
3
}}}),
l0
);
auto
epsilon_literal
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
migraphx
::
shape
::
float_type
},
{
1e-5
}});
auto
l2
=
add_common_op
(
*
mm
,
migraphx
::
make_op
(
"add"
),
{
variance
,
epsilon_literal
});
auto
l3
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"rsqrt"
),
l2
);
auto
l4
=
add_common_op
(
*
mm
,
migraphx
::
make_op
(
"mul"
),
{
l1
,
l3
});
auto
scale_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
1
}}),
scale
,
x
);
auto
bias_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
1
}}),
bias
,
x
);
auto
l5
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
l4
,
scale_bcast
);
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
l5
,
bias_bcast
);
mm
->
add_return
({
ret
});
migraphx
::
onnx_options
options
;
options
.
default_dyn_dim_value
=
{
1
,
2
,
{
2
}};
auto
prog
=
migraphx
::
parse_onnx
(
"instance_norm_dyn_batch_test.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/instance_norm_half_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
instance_norm_half_test
)
{
std
::
vector
<
size_t
>
dims
{
1
,
2
,
3
,
3
};
migraphx
::
shape
s1
{
migraphx
::
shape
::
half_type
,
dims
};
migraphx
::
shape
s2
{
migraphx
::
shape
::
half_type
,
{
2
}};
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
x_fp16
=
mm
->
add_parameter
(
"0"
,
s1
);
auto
scale_fp16
=
mm
->
add_parameter
(
"1"
,
s2
);
auto
bias_fp16
=
mm
->
add_parameter
(
"2"
,
s2
);
// conversion of half type to float is enabled by default
auto
x
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
shape
::
float_type
}}),
x_fp16
);
auto
scale
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
shape
::
float_type
}}),
scale_fp16
);
auto
bias
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
shape
::
float_type
}}),
bias_fp16
);
auto
mean
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reduce_mean"
,
{{
"axes"
,
{
2
,
3
}}}),
x
);
auto
l0
=
add_common_op
(
*
mm
,
migraphx
::
make_op
(
"sub"
),
{
x
,
mean
});
auto
l1
=
add_common_op
(
*
mm
,
migraphx
::
make_op
(
"sqdiff"
),
{
x
,
mean
});
auto
variance
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reduce_mean"
,
{{
"axes"
,
{
2
,
3
}}}),
l1
);
// type of epsilon_literal is same as 0'th input; convert instruction will be added by
// add_common_op
auto
epsilon_literal
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
migraphx
::
shape
::
float_type
},
{
1e-5
}});
auto
l2
=
add_common_op
(
*
mm
,
migraphx
::
make_op
(
"add"
),
{
variance
,
epsilon_literal
});
auto
l3
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"rsqrt"
),
l2
);
auto
l4
=
add_common_op
(
*
mm
,
migraphx
::
make_op
(
"mul"
),
{
l0
,
l3
});
auto
scale_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
1
},
{
"out_lens"
,
dims
}}),
scale
);
auto
bias_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
1
},
{
"out_lens"
,
dims
}}),
bias
);
auto
l5
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
l4
,
scale_bcast
);
auto
instance_norm_fp32
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
l5
,
bias_bcast
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
shape
::
half_type
}}),
instance_norm_fp32
);
auto
prog
=
optimize_onnx
(
"instance_norm_half_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/instance_norm_invalid_type_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
instance_norm_invalid_type_test
)
{
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"instance_norm_invalid_type_test.onnx"
);
}));
}
test/onnx/parse/instance_norm_nonbroadcastable_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
instance_norm_nonbroadcastable_test
)
{
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"instance_norm_nonbroadcastable_test.onnx"
);
}));
}
test/onnx/parse/instance_norm_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
instance_norm_test
)
{
std
::
vector
<
size_t
>
dims
{
1
,
2
,
3
,
3
};
migraphx
::
shape
s1
{
migraphx
::
shape
::
float_type
,
dims
};
migraphx
::
shape
s2
{
migraphx
::
shape
::
float_type
,
{
2
}};
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
x
=
mm
->
add_parameter
(
"0"
,
s1
);
auto
scale
=
mm
->
add_parameter
(
"1"
,
s2
);
auto
bias
=
mm
->
add_parameter
(
"2"
,
s2
);
auto
mean
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reduce_mean"
,
{{
"axes"
,
{
2
,
3
}}}),
x
);
auto
l1
=
add_common_op
(
*
mm
,
migraphx
::
make_op
(
"sub"
),
{
x
,
mean
});
auto
l0
=
add_common_op
(
*
mm
,
migraphx
::
make_op
(
"sqdiff"
),
{
x
,
mean
});
auto
variance
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reduce_mean"
,
{{
"axes"
,
{
2
,
3
}}}),
l0
);
auto
epsilon_literal
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
migraphx
::
shape
::
float_type
},
{
1e-5
}});
auto
l2
=
add_common_op
(
*
mm
,
migraphx
::
make_op
(
"add"
),
{
variance
,
epsilon_literal
});
auto
l3
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"rsqrt"
),
l2
);
auto
l4
=
add_common_op
(
*
mm
,
migraphx
::
make_op
(
"mul"
),
{
l1
,
l3
});
auto
scale_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
1
},
{
"out_lens"
,
dims
}}),
scale
);
auto
bias_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
1
},
{
"out_lens"
,
dims
}}),
bias
);
auto
l5
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
l4
,
scale_bcast
);
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
l5
,
bias_bcast
);
mm
->
add_return
({
ret
});
migraphx
::
onnx_options
options
;
auto
prog
=
migraphx
::
parse_onnx
(
"instance_norm_test.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/instance_norm_type_mismatch_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
instance_norm_type_mismatch_test
)
{
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"instance_norm_type_mismatch_test.onnx"
);
}));
}
test/onnx/parse/isinf_double_pos_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
isinf_double_pos_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
double_type
,
{
2
,
3
}};
auto
t1
=
mm
->
add_parameter
(
"t1"
,
s
);
auto
is_inf
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"isinf"
),
t1
);
auto
zero_l
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
double_type
,
{
0
}});
auto
mb_zero
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
s
.
lens
()}}),
zero_l
);
auto
is_neg
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"greater"
),
t1
,
mb_zero
);
if
(
is_neg
->
get_shape
().
type
()
!=
migraphx
::
shape
::
bool_type
)
{
is_neg
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
shape
::
bool_type
}}),
is_neg
);
}
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"logical_and"
),
is_inf
,
is_neg
);
mm
->
add_return
({
ret
});
auto
prog
=
migraphx
::
parse_onnx
(
"isinf_double_pos_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/isinf_half_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
isinf_half_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
half_type
,
{
2
,
3
}};
auto
t1
=
mm
->
add_parameter
(
"t1"
,
s
);
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"isinf"
),
t1
);
mm
->
add_return
({
ret
});
auto
prog
=
migraphx
::
parse_onnx
(
"isinf_half_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/isinf_neg_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
isinf_neg_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
2
,
3
}};
auto
t1
=
mm
->
add_parameter
(
"t1"
,
s
);
auto
is_inf
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"isinf"
),
t1
);
auto
zero_l
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
float_type
,
{
0
}});
auto
mb_zero
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
s
.
lens
()}}),
zero_l
);
auto
is_neg
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"less"
),
t1
,
mb_zero
);
if
(
is_neg
->
get_shape
().
type
()
!=
migraphx
::
shape
::
bool_type
)
{
is_neg
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
shape
::
bool_type
}}),
is_neg
);
}
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"logical_and"
),
is_inf
,
is_neg
);
mm
->
add_return
({
ret
});
auto
prog
=
migraphx
::
parse_onnx
(
"isinf_neg_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/isinf_no_detect_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
isinf_no_detect_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
2
,
3
}};
mm
->
add_parameter
(
"t1"
,
s
);
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
s
.
lens
()}}),
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
migraphx
::
shape
::
bool_type
},
{
false
}}));
mm
->
add_return
({
ret
});
auto
prog
=
migraphx
::
parse_onnx
(
"isinf_no_detect_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/isnan_float_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
isnan_float_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
2
,
3
}};
auto
t1
=
mm
->
add_parameter
(
"t1"
,
s
);
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"isnan"
),
t1
);
mm
->
add_return
({
ret
});
auto
prog
=
migraphx
::
parse_onnx
(
"isnan_float_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/isnan_half_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
isnan_half_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
half_type
,
{
2
,
3
}};
auto
t1
=
mm
->
add_parameter
(
"t1"
,
s
);
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"isnan"
),
t1
);
mm
->
add_return
({
ret
});
auto
prog
=
migraphx
::
parse_onnx
(
"isnan_half_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/layer_norm_2d_axis_one_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <onnx_test_utils.hpp>
TEST_CASE
(
layer_norm_2d_axis_one_test
)
{
migraphx
::
program
p
=
make_layer_norm
({
3
,
4
},
{
4
},
{
1
},
1
);
auto
prog
=
optimize_onnx
(
"layer_norm_2d_axis_one_test.onnx"
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
layer_norm_2d_axis_minus_one_test
)
{
migraphx
::
program
p
=
make_layer_norm
({
3
,
4
},
{
4
},
{
1
},
1
);
auto
prog
=
optimize_onnx
(
"layer_norm_2d_axis_one_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/layer_norm_2d_axis_zero_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <onnx_test_utils.hpp>
TEST_CASE
(
layer_norm_2d_axis_zero_test
)
{
migraphx
::
program
p
=
make_layer_norm
({
3
,
4
},
{
3
,
4
},
{
0
,
1
},
0
);
auto
prog
=
optimize_onnx
(
"layer_norm_2d_axis_zero_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/layer_norm_3d_half_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <onnx_test_utils.hpp>
TEST_CASE
(
layer_norm_3d_half_test
)
{
migraphx
::
program
p
=
make_layer_norm
({
1
,
4
,
2
},
{
2
},
{
2
},
2
,
false
,
1e-5
f
,
migraphx
::
shape
::
half_type
);
auto
prog
=
optimize_onnx
(
"layer_norm_3d_half_test.onnx"
);
EXPECT
(
p
==
prog
);
}
Prev
1
…
7
8
9
10
11
12
13
14
15
…
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