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
3eaeeca9
Unverified
Commit
3eaeeca9
authored
Nov 18, 2022
by
Ted Themistokleous
Committed by
GitHub
Nov 18, 2022
Browse files
Merge branch 'develop' into fix_parse_if
parents
cccf7d09
af7e6eaa
Changes
24
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1020 additions
and
1 deletion
+1020
-1
test/onnx/onnx_test.cpp
test/onnx/onnx_test.cpp
+70
-0
test/op_shape_test.cpp
test/op_shape_test.cpp
+284
-0
test/ref_ops_test.cpp
test/ref_ops_test.cpp
+605
-1
test/shape_test.cpp
test/shape_test.cpp
+61
-0
No files found.
test/onnx/onnx_test.cpp
View file @
3eaeeca9
...
...
@@ -521,6 +521,76 @@ TEST_CASE(batch_norm_invalid_bias_rank)
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"batch_norm_invalid_bias_rank.onnx"
);
}));
}
TEST_CASE
(
binary_dyn_brcst_prelu_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
3
,
3
,
0
},
{
4
,
4
,
0
},
{
5
,
5
,
0
}}});
auto
l1
=
mm
->
add_parameter
(
"1"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
,
5
}});
auto
ret
=
add_common_op
(
*
mm
,
migraphx
::
make_op
(
"prelu"
),
{
l0
,
l1
});
mm
->
add_return
({
ret
});
migraphx
::
onnx_options
options
;
options
.
default_dyn_dim_value
=
{
1
,
4
,
0
};
auto
prog
=
migraphx
::
parse_onnx
(
"binary_dyn_brcst_prelu_test.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
binary_dyn_brcst_add_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
half_type
,
{
4
,
5
}});
auto
l1
=
mm
->
add_parameter
(
"1"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
3
,
3
,
0
},
{
4
,
4
,
0
},
{
5
,
5
,
0
}}});
auto
ret
=
add_common_op
(
*
mm
,
migraphx
::
make_op
(
"add"
),
{
l0
,
l1
});
mm
->
add_return
({
ret
});
migraphx
::
onnx_options
options
;
options
.
default_dyn_dim_value
=
{
1
,
4
,
0
};
auto
prog
=
migraphx
::
parse_onnx
(
"binary_dyn_brcst_add_test.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
binary_dyn_brcst_attr_error_test
)
{
migraphx
::
onnx_options
options
;
options
.
default_dyn_dim_value
=
{
1
,
4
,
0
};
EXPECT
(
test
::
throws
(
[
&
]
{
migraphx
::
parse_onnx
(
"binary_dyn_brcst_attr_error_test.onnx"
,
options
);
}));
}
TEST_CASE
(
binary_dyn_brcst_mul_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
3
,
3
,
0
},
{
4
,
4
,
0
},
{
5
,
5
,
0
}}});
auto
l1
=
mm
->
add_parameter
(
"1"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
,
1
}});
auto
bl1
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_dyn_dims"
,
to_value
(
l0
->
get_shape
().
dyn_dims
())}}),
l1
,
l0
);
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
l0
,
bl1
);
mm
->
add_return
({
ret
});
migraphx
::
onnx_options
options
;
options
.
default_dyn_dim_value
=
{
1
,
4
,
0
};
auto
prog
=
migraphx
::
parse_onnx
(
"binary_dyn_brcst_mul_test.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
cast_test
)
{
migraphx
::
program
p
;
...
...
test/op_shape_test.cpp
View file @
3eaeeca9
...
...
@@ -81,6 +81,14 @@ void throws_shape(const migraphx::shape&, Ts...)
"An expected shape should not be passed to throws_shape function"
);
}
TEST_CASE
(
binary_dyn_static_error
)
{
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
float_type
,
{
1
,
4
,
4
}};
std
::
vector
<
migraphx
::
shape
::
dynamic_dimension
>
b
{{
1
,
1
,
0
},
{
4
,
4
,
4
},
{
4
,
4
,
0
}};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
b
};
throws_shape
(
migraphx
::
make_op
(
"add"
),
a_shape
,
b_shape
);
}
TEST_CASE
(
broadcast
)
{
{
...
...
@@ -118,6 +126,69 @@ TEST_CASE(broadcast)
}
}
TEST_CASE
(
broadcast_axis_out_of_range_error
)
{
std
::
vector
<
std
::
size_t
>
lens
{
1
,
1
};
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{
1
},
{
0
}};
throws_shape
(
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
4
},
{
"out_lens"
,
lens
}}),
input
);
}
TEST_CASE
(
broadcast_2in_static_static
)
{
migraphx
::
shape
a_input
{
migraphx
::
shape
::
float_type
,
{
4
},
{
1
}};
migraphx
::
shape
b_input
{
migraphx
::
shape
::
float_type
,
{
4
,
4
},
{
4
,
1
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
,
4
},
{
1
,
0
}},
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
0
}}),
a_input
,
b_input
);
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
,
4
},
{
0
,
1
}},
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
1
}}),
a_input
,
b_input
);
throws_shape
(
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
2
}}),
a_input
,
b_input
);
}
TEST_CASE
(
broadcast_2in_not_matching_error
)
{
migraphx
::
shape
a_input
{
migraphx
::
shape
::
float_type
,
{
4
},
{
1
}};
migraphx
::
shape
b_input
{
migraphx
::
shape
::
float_type
,
{
2
,
2
},
{
2
,
1
}};
throws_shape
(
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
1
}}),
a_input
,
b_input
);
}
TEST_CASE
(
broadcast_2in_dynamic_s0_error1
)
{
migraphx
::
shape
a_input
{
migraphx
::
shape
::
float_type
,
{
4
,
2
},
{
2
,
1
}};
migraphx
::
shape
b_input
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
4
,
4
,
0
},
{
2
,
2
,
0
}}};
throws_shape
(
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
0
}}),
b_input
,
a_input
);
}
TEST_CASE
(
broadcast_2in_dynamic_s0_error2
)
{
std
::
vector
<
migraphx
::
shape
::
dynamic_dimension
>
dd
{{
4
,
4
,
0
}};
migraphx
::
shape
a_input
{
migraphx
::
shape
::
float_type
,
dd
};
migraphx
::
shape
b_input
{
migraphx
::
shape
::
float_type
,
{
4
,
4
},
{
4
,
1
}};
throws_shape
(
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
0
}}),
a_input
,
b_input
);
}
TEST_CASE
(
broadcast_2in_static_dyn
)
{
migraphx
::
shape
a_input
{
migraphx
::
shape
::
float_type
,
{
4
},
{
1
}};
migraphx
::
shape
b_input
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
4
,
4
,
0
},
{
2
,
2
,
0
}}};
throws_shape
(
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
0
}}),
a_input
,
b_input
);
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
4
,
4
,
0
},
{
2
,
2
,
0
}}},
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
1
}}),
a_input
,
b_input
);
throws_shape
(
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
2
}}),
a_input
,
b_input
);
}
TEST_CASE
(
broadcast_2in_dyn_s0_ndim_greater_than_1_error
)
{
migraphx
::
shape
a_input
{
migraphx
::
shape
::
float_type
,
{
4
,
2
}};
migraphx
::
shape
b_input
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
4
,
4
,
0
},
{
2
,
2
,
0
}}};
throws_shape
(
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
0
}}),
a_input
,
b_input
);
}
TEST_CASE
(
convolution_shape
)
{
migraphx
::
shape
output
{
migraphx
::
shape
::
float_type
,
{
4
,
4
,
1
,
1
}};
...
...
@@ -294,6 +365,12 @@ TEST_CASE(contiguous_shape)
expect_shape
(
single
,
migraphx
::
make_op
(
"contiguous"
),
single
);
}
TEST_CASE
(
contiguous_dyn_shape
)
{
migraphx
::
shape
s0
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
2
,
2
,
2
}}};
expect_shape
(
s0
,
migraphx
::
make_op
(
"contiguous"
),
s0
);
}
TEST_CASE
(
contiguous_shape_scalar
)
{
migraphx
::
shape
output
{
migraphx
::
shape
::
float_type
};
...
...
@@ -1114,6 +1191,213 @@ TEST_CASE(multibroadcast)
}
}
TEST_CASE
(
multibroadcast_2in_static_dyn0
)
{
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
float_type
,
{
4
,
4
}};
std
::
vector
<
migraphx
::
shape
::
dynamic_dimension
>
b
{{
1
,
4
,
0
},
{
4
,
4
,
4
},
{
4
,
4
,
0
}};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
b
};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
4
,
4
,
0
},
{
4
,
4
,
0
}}},
migraphx
::
make_op
(
"multibroadcast"
),
a_shape
,
b_shape
);
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
4
,
4
,
0
},
{
4
,
4
,
0
}}},
migraphx
::
make_op
(
"multibroadcast"
),
b_shape
,
a_shape
);
}
TEST_CASE
(
multibroadcast_2in_static_dyn1
)
{
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
float_type
,
{
1
,
6
}};
std
::
vector
<
migraphx
::
shape
::
dynamic_dimension
>
b
{{
8
,
8
,
0
},
{
6
,
6
,
0
}};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
b
};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
8
,
8
,
0
},
{
6
,
6
,
0
}}},
migraphx
::
make_op
(
"multibroadcast"
),
a_shape
,
b_shape
);
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
8
,
8
,
0
},
{
6
,
6
,
0
}}},
migraphx
::
make_op
(
"multibroadcast"
),
b_shape
,
a_shape
);
}
TEST_CASE
(
multibroadcast_2in_static_dyn2
)
{
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
float_type
,
{
1
,
6
}};
std
::
vector
<
migraphx
::
shape
::
dynamic_dimension
>
b
{{
8
,
8
,
0
},
{
6
,
6
,
0
}};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
b
};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
8
,
8
,
0
},
{
6
,
6
,
0
}}},
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_dyn_dims"
,
migraphx
::
to_value
(
b
)}}),
a_shape
,
b_shape
);
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
8
,
8
,
0
},
{
6
,
6
,
0
}}},
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_dyn_dims"
,
migraphx
::
to_value
(
b
)}}),
b_shape
,
a_shape
);
}
TEST_CASE
(
multibroadcast_2in_static_dyn_error0
)
{
// doesn't match on first dimension
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
float_type
,
{
3
,
6
}};
std
::
vector
<
migraphx
::
shape
::
dynamic_dimension
>
b
{{
1
,
3
,
0
},
{
6
,
6
,
0
}};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
b
};
throws_shape
(
migraphx
::
make_op
(
"multibroadcast"
),
a_shape
,
b_shape
);
throws_shape
(
migraphx
::
make_op
(
"multibroadcast"
),
b_shape
,
a_shape
);
}
TEST_CASE
(
multibroadcast_2in_static_dyn_error1
)
{
// doesn't match on first dimension
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
float_type
,
{
3
,
6
}};
std
::
vector
<
migraphx
::
shape
::
dynamic_dimension
>
b
{{
1
,
4
,
0
},
{
6
,
6
,
0
}};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
b
};
throws_shape
(
migraphx
::
make_op
(
"multibroadcast"
),
a_shape
,
b_shape
);
throws_shape
(
migraphx
::
make_op
(
"multibroadcast"
),
b_shape
,
a_shape
);
}
TEST_CASE
(
multibroadcast_2in_static_dyn_error2
)
{
// doesn't match on first dimension
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
float_type
,
{
3
,
6
}};
std
::
vector
<
migraphx
::
shape
::
dynamic_dimension
>
b
{{
1
,
2
,
0
},
{
6
,
6
,
0
}};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
b
};
throws_shape
(
migraphx
::
make_op
(
"multibroadcast"
),
a_shape
,
b_shape
);
throws_shape
(
migraphx
::
make_op
(
"multibroadcast"
),
b_shape
,
a_shape
);
}
TEST_CASE
(
multibroadcast_2in_dyn_dyn0
)
{
std
::
vector
<
migraphx
::
shape
::
dynamic_dimension
>
a
{{
1
,
4
,
0
},
{
2
,
4
,
2
},
{
2
,
4
,
0
}};
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
float_type
,
a
};
std
::
vector
<
migraphx
::
shape
::
dynamic_dimension
>
b
{{
2
,
4
,
2
},
{
2
,
4
,
0
}};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
b
};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
2
,
4
,
2
},
{
2
,
4
,
0
}}},
migraphx
::
make_op
(
"multibroadcast"
),
a_shape
,
b_shape
);
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
2
,
4
,
2
},
{
2
,
4
,
0
}}},
migraphx
::
make_op
(
"multibroadcast"
),
b_shape
,
a_shape
);
}
TEST_CASE
(
multibroadcast_2in_dyn_dyn1
)
{
std
::
vector
<
migraphx
::
shape
::
dynamic_dimension
>
a
{{
1
,
4
,
0
},
{
2
,
4
,
2
},
{
2
,
4
,
0
}};
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
float_type
,
a
};
std
::
vector
<
migraphx
::
shape
::
dynamic_dimension
>
b
{{
2
,
4
,
2
},
{
2
,
4
,
0
}};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
b
};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
2
,
4
,
2
},
{
2
,
4
,
0
}}},
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_dyn_dims"
,
migraphx
::
to_value
(
a
)}}),
a_shape
,
b_shape
);
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
2
,
4
,
2
},
{
2
,
4
,
0
}}},
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_dyn_dims"
,
migraphx
::
to_value
(
a
)}}),
b_shape
,
a_shape
);
}
TEST_CASE
(
multibroadcast_2in_dyn_dyn_error0
)
{
// max doesn't match on second dimension of a
std
::
vector
<
migraphx
::
shape
::
dynamic_dimension
>
a
{{
1
,
4
,
0
},
{
2
,
4
,
2
},
{
2
,
4
,
0
}};
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
float_type
,
a
};
std
::
vector
<
migraphx
::
shape
::
dynamic_dimension
>
b
{{
2
,
5
,
2
},
{
2
,
4
,
0
}};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
b
};
throws_shape
(
migraphx
::
make_op
(
"multibroadcast"
),
a_shape
,
b_shape
);
throws_shape
(
migraphx
::
make_op
(
"multibroadcast"
),
b_shape
,
a_shape
);
}
TEST_CASE
(
multibroadcast_2in_dyn_dyn_error1
)
{
// opt doesn't match on second dimension of a
std
::
vector
<
migraphx
::
shape
::
dynamic_dimension
>
a
{{
1
,
4
,
0
},
{
2
,
4
,
2
},
{
2
,
4
,
0
}};
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
float_type
,
a
};
std
::
vector
<
migraphx
::
shape
::
dynamic_dimension
>
b
{{
2
,
4
,
3
},
{
2
,
4
,
0
}};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
b
};
throws_shape
(
migraphx
::
make_op
(
"multibroadcast"
),
a_shape
,
b_shape
);
throws_shape
(
migraphx
::
make_op
(
"multibroadcast"
),
b_shape
,
a_shape
);
}
TEST_CASE
(
multibroadcast_2in_static_static0
)
{
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
float_type
,
{
3
,
6
}};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
{
3
,
6
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
6
}},
migraphx
::
make_op
(
"multibroadcast"
),
a_shape
,
b_shape
);
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
6
}},
migraphx
::
make_op
(
"multibroadcast"
),
b_shape
,
a_shape
);
}
TEST_CASE
(
multibroadcast_2in_static_static1
)
{
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
float_type
,
{
1
,
8
}};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
{
4
,
8
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
,
8
},
{
0
,
1
}},
migraphx
::
make_op
(
"multibroadcast"
),
a_shape
,
b_shape
);
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
,
8
},
{
8
,
1
}},
migraphx
::
make_op
(
"multibroadcast"
),
b_shape
,
a_shape
);
}
TEST_CASE
(
multibroadcast_2in_static_static2
)
{
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
float_type
,
{
8
}};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
{
4
,
4
,
1
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
,
4
,
8
},
{
0
,
0
,
1
}},
migraphx
::
make_op
(
"multibroadcast"
),
a_shape
,
b_shape
);
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
,
4
,
8
},
{
4
,
1
,
0
}},
migraphx
::
make_op
(
"multibroadcast"
),
b_shape
,
a_shape
);
}
TEST_CASE
(
multibroadcast_2in_static_static3
)
{
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
float_type
,
{
3
,
4
,
4
}};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
{
4
,
1
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
4
,
4
},
{
16
,
4
,
1
}},
migraphx
::
make_op
(
"multibroadcast"
),
a_shape
,
b_shape
);
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
4
,
4
},
{
0
,
1
,
0
}},
migraphx
::
make_op
(
"multibroadcast"
),
b_shape
,
a_shape
);
}
TEST_CASE
(
multibroadcast_2in_static_static4
)
{
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
float_type
,
{
3
,
1
,
4
}};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
{
4
,
1
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
4
,
4
},
{
4
,
0
,
1
}},
migraphx
::
make_op
(
"multibroadcast"
),
a_shape
,
b_shape
);
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
4
,
4
},
{
0
,
1
,
0
}},
migraphx
::
make_op
(
"multibroadcast"
),
b_shape
,
a_shape
);
}
TEST_CASE
(
multibroadcast_2in_static_static_error0
)
{
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
float_type
,
{
3
,
4
,
4
}};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
{
4
,
3
}};
throws_shape
(
migraphx
::
make_op
(
"multibroadcast"
),
a_shape
,
b_shape
);
throws_shape
(
migraphx
::
make_op
(
"multibroadcast"
),
b_shape
,
a_shape
);
}
TEST_CASE
(
multinomial
)
{
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
2
,
5
}};
...
...
test/ref_ops_test.cpp
View file @
3eaeeca9
This diff is collapsed.
Click to expand it.
test/shape_test.cpp
View file @
3eaeeca9
...
...
@@ -38,6 +38,27 @@ TEST_CASE(test_shape_default)
EXPECT
(
s
.
elements
()
==
0
);
EXPECT
(
s
.
bytes
()
==
0
);
}
TEST_CASE
(
test_dyn_4arg_constructor
)
{
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
1
,
4
,
4
,
},
{
4
,
4
,
4
,
},
{
0
,
0
,
0
}};
std
::
vector
<
migraphx
::
shape
::
dynamic_dimension
>
expected_dyn_dims
=
{
{
1
,
4
,
0
},
{
4
,
4
,
0
},
{
4
,
4
,
0
}};
EXPECT
(
s
.
dynamic
());
EXPECT
(
s
.
dyn_dims
()
==
expected_dyn_dims
);
}
TEST_CASE
(
test_shape_assign
)
{
migraphx
::
shape
s1
{
migraphx
::
shape
::
float_type
,
{
100
,
32
,
8
,
8
}};
...
...
@@ -185,6 +206,31 @@ TEST_CASE(test_shape_packed)
EXPECT
(
not
s
.
broadcasted
());
}
TEST_CASE
(
test_shape_ndim_static
)
{
migraphx
::
shape
s0
{
migraphx
::
shape
::
float_type
,
{
2
,
2
}};
EXPECT
(
s0
.
ndim
()
==
2
);
migraphx
::
shape
s1
{
migraphx
::
shape
::
float_type
,
{
1
,
2
,
4
,
4
}};
EXPECT
(
s1
.
ndim
()
==
4
);
migraphx
::
shape
s2
{
migraphx
::
shape
::
float_type
,
{
2
,
4
,
4
,
1
,
3
}};
EXPECT
(
s2
.
ndim
()
==
5
);
}
TEST_CASE
(
test_shape_ndim_dyn
)
{
migraphx
::
shape
s0
{
migraphx
::
shape
::
float_type
,
{{
2
,
2
,
0
},
{
2
,
2
,
0
}}};
EXPECT
(
s0
.
ndim
()
==
2
);
migraphx
::
shape
s1
{
migraphx
::
shape
::
float_type
,
{{
1
,
1
,
0
},
{
2
,
4
,
0
},
{
2
,
4
,
0
},
{
2
,
4
,
0
}}};
EXPECT
(
s1
.
ndim
()
==
4
);
migraphx
::
shape
s2
{
migraphx
::
shape
::
float_type
,
{{
1
,
1
,
0
},
{
2
,
4
,
0
},
{
2
,
4
,
0
},
{
1
,
1
,
1
},
{
3
,
3
,
0
}}};
EXPECT
(
s2
.
ndim
()
==
5
);
}
TEST_CASE
(
test_shape_non_packed_single_dim
)
{
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
1
,
64
,
35
,
35
},
{
156800
,
1225
,
35
,
1
}};
...
...
@@ -212,6 +258,21 @@ TEST_CASE(test_shape_transposed2)
EXPECT
(
not
s
.
broadcasted
());
}
TEST_CASE
(
test_shape_static_to_dynamic
)
{
migraphx
::
shape
s0
{
migraphx
::
shape
::
float_type
,
{
1
,
2
,
4
,
4
}};
migraphx
::
shape
s1
=
s0
.
to_dynamic
();
migraphx
::
shape
s2
{
migraphx
::
shape
::
float_type
,
{{
1
,
1
,
0
},
{
2
,
2
,
0
},
{
4
,
4
,
0
},
{
4
,
4
,
0
}}};
EXPECT
(
s1
==
s2
);
}
TEST_CASE
(
test_shape_dyn_to_dynamic
)
{
migraphx
::
shape
s0
{
migraphx
::
shape
::
float_type
,
{{
1
,
1
,
0
},
{
2
,
4
,
0
},
{
2
,
4
,
0
},
{
2
,
4
,
0
}}};
migraphx
::
shape
s1
=
s0
.
to_dynamic
();
EXPECT
(
s0
==
s1
);
}
TEST_CASE
(
test_shape_overlap
)
{
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
2
,
2
,
3
},
{
6
,
3
,
2
}};
...
...
Prev
1
2
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