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
"driver/device_direct_convolution_1.hpp" did not exist on "1f3870ca19e6392c2453e63ed187f0cca6872295"
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
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
...
...
@@ -225,6 +225,30 @@ TEST_CASE(add_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(add_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
std::vector<migraphx::shape::dynamic_dimension> dd{{2, 6, 0}};
migraphx::shape s{migraphx::shape::float_type, dd};
auto x = mm->add_parameter("x", s);
auto y = mm->add_parameter("y", s);
mm->add_instruction(migraphx::make_op("add"), x, y);
p.compile(migraphx::ref::target{});
std::vector<float> x_data{-1, 0, 1};
std::vector<float> y_data{1, 2, 3};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {3}};
params0["x"] = migraphx::argument(input_fixed_shape0, x_data.data());
params0["y"] = migraphx::argument(input_fixed_shape0, y_data.data());
auto result = p.eval(params0).back();
std::vector<float> results_vector(3);
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
std::vector<float> gold = {0, 2, 4};
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(argmax_test_0)
{
migraphx::program p;
...
...
@@ -670,6 +694,52 @@ TEST_CASE(broadcast_test)
EXPECT(output(1, 1) == -3);
}
TEST_CASE(broadcast_2in_static_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape a_shape{migraphx::shape::int32_type, {2, 2}};
std::vector<int32_t> a_data{0, 0, 0, 0};
migraphx::shape b_shape{migraphx::shape::int32_type, {2}};
std::vector<int32_t> b_data{-2, -3};
uint64_t axis = 0;
auto l1 = mm->add_literal(migraphx::literal{a_shape, a_data});
auto l2 = mm->add_literal(migraphx::literal{b_shape, b_data});
mm->add_instruction(migraphx::make_op("broadcast", {{"axis", axis}}), l2, l1);
p.compile(migraphx::ref::target{});
auto result = p.eval({}).back();
auto output = result.get<int32_t>();
EXPECT(output(0, 0) == -2);
EXPECT(output(0, 1) == -2);
EXPECT(output(1, 0) == -3);
EXPECT(output(1, 1) == -3);
}
TEST_CASE(broadcast_2in_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape a_shape{migraphx::shape::int32_type, {{2, 2, 0}, {2, 4, 0}}};
migraphx::shape b_shape{migraphx::shape::int32_type, {2}};
std::vector<int32_t> b_data{-2, -3};
uint64_t axis = 0;
auto pa = mm->add_parameter("a", a_shape);
auto lb = mm->add_literal(migraphx::literal{b_shape, b_data});
mm->add_instruction(migraphx::make_op("broadcast", {{"axis", axis}}), lb, pa);
p.compile(migraphx::ref::target{});
std::vector<int32_t> a_data{0, 0, 0, 0};
migraphx::shape input_fixed_shape0{migraphx::shape::int32_type, {2, 2}};
migraphx::parameter_map params0;
params0["a"] = migraphx::argument(input_fixed_shape0, a_data.data());
auto result = p.eval(params0).back();
auto output = result.get<int32_t>();
EXPECT(output(0, 0) == -2);
EXPECT(output(0, 1) == -2);
EXPECT(output(1, 0) == -3);
EXPECT(output(1, 1) == -3);
}
TEST_CASE(ceil_test)
{
migraphx::program p;
...
...
@@ -855,6 +925,33 @@ TEST_CASE(contiguous_test)
EXPECT(migraphx::verify_range(results_vector, data));
}
TEST_CASE(contiguous_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape dyn_shape{migraphx::shape::float_type,
{{1, 1, 0}, {2, 6, 0}, {2, 2, 0}, {2, 2, 0}}};
auto input = mm->add_parameter("X", dyn_shape);
mm->add_instruction(migraphx::make_op("contiguous"), input);
p.compile(migraphx::ref::target{});
migraphx::shape static_shape{migraphx::shape::float_type, {1, 3, 2, 2}, {12, 1, 6, 3}};
std::vector<float> data(12);
std::iota(data.begin(), data.end(), 0);
migraphx::parameter_map params;
params["X"] = migraphx::argument(static_shape, data.data());
auto result = p.eval(params).back();
std::vector<size_t> new_strides = {12, 4, 2, 1};
EXPECT(result.get_shape().strides() == new_strides);
std::vector<float> results_vector(12);
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
std::vector<float> gold = {0, 3, 6, 9, 1, 4, 7, 10, 2, 5, 8, 11};
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(conv_dynamic_batch_test)
{
migraphx::program p;
...
...
@@ -1860,6 +1957,32 @@ TEST_CASE(div_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(div_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
std::vector<migraphx::shape::dynamic_dimension> dd{{2, 6, 3}};
migraphx::shape s{migraphx::shape::float_type, dd};
auto x = mm->add_parameter("x", s);
auto y = mm->add_parameter("y", s);
mm->add_instruction(migraphx::make_op("div"), x, y);
p.compile(migraphx::ref::target{});
std::vector<float> x_data{-1.0f, 0.5f, 1.0f};
std::vector<float> y_data{1.0f, 2.0f, 4.0f};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {3}};
params0["x"] = migraphx::argument(input_fixed_shape0, x_data.data());
params0["y"] = migraphx::argument(input_fixed_shape0, y_data.data());
auto result = p.eval(params0).back();
std::vector<float> results_vector(3);
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
std::vector<float> gold(x_data.size());
std::transform(
x_data.begin(), x_data.end(), y_data.begin(), gold.begin(), std::divides<float>());
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(elu_test)
{
migraphx::program p;
...
...
@@ -1947,6 +2070,35 @@ TEST_CASE(equal_test)
EXPECT(results_vector == gold);
}
TEST_CASE(equal_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
std::vector<migraphx::shape::dynamic_dimension> dd{{6, 12, 9}};
migraphx::shape s{migraphx::shape::float_type, dd};
auto p0 = mm->add_parameter("l", s);
auto p1 = mm->add_parameter("r", s);
auto eq = mm->add_instruction(migraphx::make_op("equal"), p0, p1);
auto r = mm->add_instruction(
migraphx::make_op("convert",
{{"target_type", migraphx::to_value(migraphx::shape::bool_type)}}),
eq);
mm->add_return({r});
p.compile(migraphx::ref::target{});
std::vector<float> l_data{1.1, 1.5, 0.1, -1.1, -1.5, -0.6, 0.0, 2.0, -2.0};
std::vector<float> r_data{1.1, 1.6, -0.1, -1.2, -1.5, -0.7, 0.0, 2.3, -2.1};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {9}};
params0["l"] = migraphx::argument(input_fixed_shape0, l_data.data());
params0["r"] = migraphx::argument(input_fixed_shape0, r_data.data());
auto result = p.eval(params0).back();
std::vector<bool> results_vector;
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
std::vector<bool> gold = {true, false, false, false, true, false, true, false, false};
EXPECT(results_vector == gold);
}
TEST_CASE(erf_test)
{
migraphx::program p;
...
...
@@ -2607,6 +2759,35 @@ TEST_CASE(greater_test)
EXPECT(results_vector == gold);
}
TEST_CASE(greater_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
std::vector<migraphx::shape::dynamic_dimension> dd{{8, 10, 9}};
migraphx::shape s{migraphx::shape::float_type, dd};
auto left = mm->add_parameter("l", s);
auto right = mm->add_parameter("r", s);
auto gr = mm->add_instruction(migraphx::make_op("greater"), left, right);
auto r = mm->add_instruction(
migraphx::make_op("convert",
{{"target_type", migraphx::to_value(migraphx::shape::bool_type)}}),
gr);
mm->add_return({r});
p.compile(migraphx::ref::target{});
std::vector<float> left_data{1.1, 1.5, 0.1, -1.1, -1.5, -0.6, 0.0, 2.0, -2.0};
std::vector<float> right_data{1.1, 1.6, -0.1, -1.2, -1.5, -0.7, 0.0, 2.3, -2.1};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {9}};
params0["l"] = migraphx::argument(input_fixed_shape0, left_data.data());
params0["r"] = migraphx::argument(input_fixed_shape0, right_data.data());
auto result = p.eval(params0).back();
std::vector<bool> results_vector;
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
std::vector<bool> gold = {false, false, true, true, false, true, false, false, true};
EXPECT(results_vector == gold);
}
TEST_CASE(identity_test)
{
migraphx::program p;
...
...
@@ -3187,6 +3368,40 @@ TEST_CASE(less_test)
EXPECT(results_vector == gold);
}
TEST_CASE(less_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
std::vector<migraphx::shape::dynamic_dimension> dd{{8, 10, 9}};
migraphx::shape s{migraphx::shape::float_type, dd};
auto left = mm->add_parameter("l", s);
auto right = mm->add_parameter("r", s);
auto le = mm->add_instruction(migraphx::make_op("less"), left, right);
auto r = mm->add_instruction(
migraphx::make_op("convert",
{{"target_type", migraphx::to_value(migraphx::shape::bool_type)}}),
le);
mm->add_return({r});
p.compile(migraphx::ref::target{});
std::vector<float> left_data = {1.1, 1.5, 0.1, -1.1, -1.5, -0.6, 0.0, 2.0, -2.0};
std::vector<float> right_data = {1.1, 1.6, -0.1, -1.2, -1.5, -0.7, 0.0, 2.3, -2.1};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {9}};
params0["l"] = migraphx::argument(input_fixed_shape0, left_data.data());
params0["r"] = migraphx::argument(input_fixed_shape0, right_data.data());
auto result = p.eval(params0).back();
std::vector<bool> results_vector;
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
std::vector<bool> gold(left_data.size());
std::transform(left_data.begin(),
left_data.end(),
right_data.begin(),
gold.begin(),
[](float n1, float n2) -> bool { return n1 < n2; });
EXPECT(results_vector == gold);
}
TEST_CASE(log_test)
{
migraphx::program p;
...
...
@@ -3250,6 +3465,35 @@ TEST_CASE(logical_and_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(logical_and_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
std::vector<migraphx::shape::dynamic_dimension> dd{{2, 6, 4}};
migraphx::shape s{migraphx::shape::bool_type, dd};
auto left = mm->add_parameter("l", s);
auto right = mm->add_parameter("r", s);
mm->add_instruction(migraphx::make_op("logical_and"), left, right);
p.compile(migraphx::ref::target{});
std::vector<char> left_data{1, 0, 1, 0};
std::vector<char> right_data{1, 1, 0, 0};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::bool_type, {4}};
params0["l"] = migraphx::argument(input_fixed_shape0, left_data.data());
params0["r"] = migraphx::argument(input_fixed_shape0, right_data.data());
auto result = p.eval(params0).back();
std::vector<char> results_vector;
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
std::vector<bool> gold(left_data.size());
std::transform(left_data.begin(),
left_data.end(),
right_data.begin(),
gold.begin(),
[](bool n1, bool n2) -> bool { return n1 and n2; });
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(logical_or_test)
{
migraphx::program p;
...
...
@@ -3272,6 +3516,35 @@ TEST_CASE(logical_or_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(logical_or_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
std::vector<migraphx::shape::dynamic_dimension> dd{{2, 6, 4}};
migraphx::shape s{migraphx::shape::bool_type, dd};
auto left = mm->add_parameter("l", s);
auto right = mm->add_parameter("r", s);
mm->add_instruction(migraphx::make_op("logical_or"), left, right);
p.compile(migraphx::ref::target{});
std::vector<char> left_data{1, 0, 1, 0};
std::vector<char> right_data{1, 1, 0, 0};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::bool_type, {4}};
params0["l"] = migraphx::argument(input_fixed_shape0, left_data.data());
params0["r"] = migraphx::argument(input_fixed_shape0, right_data.data());
auto result = p.eval(params0).back();
std::vector<char> results_vector;
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
std::vector<bool> gold(left_data.size());
std::transform(left_data.begin(),
left_data.end(),
right_data.begin(),
gold.begin(),
[](bool n1, bool n2) -> bool { return n1 or n2; });
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(logical_xor_test)
{
migraphx::program p;
...
...
@@ -3294,6 +3567,35 @@ TEST_CASE(logical_xor_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(logical_xor_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
std::vector<migraphx::shape::dynamic_dimension> dd{{2, 6, 4}};
migraphx::shape s{migraphx::shape::bool_type, dd};
auto left = mm->add_parameter("l", s);
auto right = mm->add_parameter("r", s);
mm->add_instruction(migraphx::make_op("logical_xor"), left, right);
p.compile(migraphx::ref::target{});
std::vector<char> left_data{1, 0, 1, 0};
std::vector<char> right_data{1, 1, 0, 0};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::bool_type, {4}};
params0["l"] = migraphx::argument(input_fixed_shape0, left_data.data());
params0["r"] = migraphx::argument(input_fixed_shape0, right_data.data());
auto result = p.eval(params0).back();
std::vector<char> results_vector;
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
std::vector<bool> gold = {false, true, true, false};
std::transform(left_data.begin(),
left_data.end(),
right_data.begin(),
gold.begin(),
[](bool n1, bool n2) -> bool { return n1 ^ n2; });
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(logsoftmax_test_axis_0)
{
migraphx::program p;
...
...
@@ -3521,6 +3823,34 @@ TEST_CASE(max_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(max_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
std::vector<migraphx::shape::dynamic_dimension> dd{{2, 6, 0}};
migraphx::shape s{migraphx::shape::float_type, dd};
auto x = mm->add_parameter("x", s);
auto y = mm->add_parameter("y", s);
auto z = mm->add_parameter("z", s);
auto curr_max = mm->add_instruction(migraphx::make_op("max"), x, y);
mm->add_instruction(migraphx::make_op("max"), curr_max, z);
p.compile(migraphx::ref::target{});
std::vector<float> x_data{1, 4, 3};
std::vector<float> y_data{2, 8, 6};
std::vector<float> z_data{7, 5, 9};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {3}};
params0["x"] = migraphx::argument(input_fixed_shape0, x_data.data());
params0["y"] = migraphx::argument(input_fixed_shape0, y_data.data());
params0["z"] = migraphx::argument(input_fixed_shape0, z_data.data());
auto result = p.eval(params0).back();
std::vector<float> results_vector(4);
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
std::vector<float> gold{7, 8, 9};
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(maxpool_test)
{
migraphx::program p;
...
...
@@ -3714,6 +4044,34 @@ TEST_CASE(min_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(min_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
std::vector<migraphx::shape::dynamic_dimension> dd{{2, 6, 0}};
migraphx::shape s{migraphx::shape::float_type, dd};
auto x = mm->add_parameter("x", s);
auto y = mm->add_parameter("y", s);
auto z = mm->add_parameter("z", s);
auto curr_min = mm->add_instruction(migraphx::make_op("min"), x, y);
mm->add_instruction(migraphx::make_op("min"), curr_min, z);
p.compile(migraphx::ref::target{});
std::vector<float> x_data{1, 4, 3};
std::vector<float> y_data{2, 8, 6};
std::vector<float> z_data{7, 5, 9};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {3}};
params0["x"] = migraphx::argument(input_fixed_shape0, x_data.data());
params0["y"] = migraphx::argument(input_fixed_shape0, y_data.data());
params0["z"] = migraphx::argument(input_fixed_shape0, z_data.data());
auto result = p.eval(params0).back();
std::vector<float> results_vector(4);
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
std::vector<float> gold{1, 4, 3};
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(fmod_test)
{
migraphx::program p;
...
...
@@ -3732,6 +4090,34 @@ TEST_CASE(fmod_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(fmod_dynamic_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
std::vector<migraphx::shape::dynamic_dimension> dd{{2, 6, 0}};
migraphx::shape s{migraphx::shape::float_type, dd};
auto x = mm->add_parameter("x", s);
auto y = mm->add_parameter("y", s);
auto z = mm->add_parameter("z", s);
auto curr_mod = mm->add_instruction(migraphx::make_op("fmod"), x, y);
mm->add_instruction(migraphx::make_op("fmod"), curr_mod, z);
p.compile(migraphx::ref::target{});
std::vector<float> x_data{-7, 8, -3};
std::vector<float> y_data{2, 4, 6};
std::vector<float> z_data{7, 5, 9};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {3}};
params0["x"] = migraphx::argument(input_fixed_shape0, x_data.data());
params0["y"] = migraphx::argument(input_fixed_shape0, y_data.data());
params0["z"] = migraphx::argument(input_fixed_shape0, z_data.data());
auto result = p.eval(params0).back();
std::vector<float> results_vector(4);
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
std::vector<float> gold{-1, 0, -3};
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(fmod_float_test)
{
migraphx::program p;
...
...
@@ -3769,6 +4155,34 @@ TEST_CASE(mod_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(mod_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
std::vector<migraphx::shape::dynamic_dimension> dd{{2, 6, 0}};
migraphx::shape s{migraphx::shape::float_type, dd};
auto x = mm->add_parameter("x", s);
auto y = mm->add_parameter("y", s);
auto z = mm->add_parameter("z", s);
auto curr_mod = mm->add_instruction(migraphx::make_op("mod"), x, y);
mm->add_instruction(migraphx::make_op("mod"), curr_mod, z);
p.compile(migraphx::ref::target{});
std::vector<float> x_data{-3, 8, -7};
std::vector<float> y_data{3, 3, 3};
std::vector<float> z_data{10, 2, 9};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {3}};
params0["x"] = migraphx::argument(input_fixed_shape0, x_data.data());
params0["y"] = migraphx::argument(input_fixed_shape0, y_data.data());
params0["z"] = migraphx::argument(input_fixed_shape0, z_data.data());
auto result = p.eval(params0).back();
std::vector<float> results_vector(4);
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
std::vector<float> gold{0, 0, 2};
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(mod_float_test)
{
migraphx::program p;
...
...
@@ -3810,6 +4224,100 @@ TEST_CASE(mul_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(mul_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
std::vector<migraphx::shape::dynamic_dimension> dd{{2, 6, 0}};
migraphx::shape s{migraphx::shape::float_type, dd};
auto x = mm->add_parameter("x", s);
auto y = mm->add_parameter("y", s);
mm->add_instruction(migraphx::make_op("mul"), x, y);
p.compile(migraphx::ref::target{});
std::vector<float> x_data{-1, 0, 1};
std::vector<float> y_data{1, 2, 3};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {3}};
params0["x"] = migraphx::argument(input_fixed_shape0, x_data.data());
params0["y"] = migraphx::argument(input_fixed_shape0, y_data.data());
auto result = p.eval(params0).back();
std::vector<float> results_vector(3);
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
std::vector<float> gold(x_data.size());
std::transform(x_data.begin(),
x_data.end(),
y_data.begin(),
gold.begin(),
[](float n1, float n2) -> float { return n1 * n2; });
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(multibroadcast_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape a_shape{migraphx::shape::int32_type, {2, 2}};
std::vector<int32_t> a_data{0, 0, 0, 0};
migraphx::shape b_shape{migraphx::shape::int32_type, {2}};
std::vector<int32_t> b_data{-2, -3};
auto l1 = mm->add_literal(migraphx::literal{a_shape, a_data});
auto l2 = mm->add_literal(migraphx::literal{b_shape, b_data});
mm->add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", l1->get_shape().lens()}}),
l2);
p.compile(migraphx::ref::target{});
auto result = p.eval({}).back();
auto output = result.get<int32_t>();
EXPECT(output(0, 0) == -2);
EXPECT(output(0, 1) == -3);
EXPECT(output(1, 0) == -2);
EXPECT(output(1, 1) == -3);
}
TEST_CASE(multibroadcast_2in_static_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape a_shape{migraphx::shape::int32_type, {2, 2}};
std::vector<int32_t> a_data{0, 0, 0, 0};
migraphx::shape b_shape{migraphx::shape::int32_type, {2}};
std::vector<int32_t> b_data{-2, -3};
auto l1 = mm->add_literal(migraphx::literal{a_shape, a_data});
auto l2 = mm->add_literal(migraphx::literal{b_shape, b_data});
mm->add_instruction(migraphx::make_op("multibroadcast"), l2, l1);
p.compile(migraphx::ref::target{});
auto result = p.eval({}).back();
auto output = result.get<int32_t>();
EXPECT(output(0, 0) == -2);
EXPECT(output(0, 1) == -3);
EXPECT(output(1, 0) == -2);
EXPECT(output(1, 1) == -3);
}
TEST_CASE(multibroadcast_2in_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape a_shape{migraphx::shape::int32_type, {{2, 4, 0}, {2, 2, 0}}};
migraphx::shape b_shape{migraphx::shape::int32_type, {2}};
std::vector<int32_t> b_data{-2, -3};
auto l1 = mm->add_parameter("a", a_shape);
auto l2 = mm->add_literal(migraphx::literal{b_shape, b_data});
mm->add_instruction(migraphx::make_op("multibroadcast"), l2, l1);
p.compile(migraphx::ref::target{});
std::vector<int32_t> a_data{0, 0, 0, 0};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {2, 2}};
params0["a"] = migraphx::argument(input_fixed_shape0, a_data.data());
auto result = p.eval(params0).back();
auto output = result.get<int32_t>();
EXPECT(output(0, 0) == -2);
EXPECT(output(0, 1) == -3);
EXPECT(output(1, 0) == -2);
EXPECT(output(1, 1) == -3);
}
TEST_CASE(multinomial_test)
{
migraphx::program p;
...
...
@@ -4389,7 +4897,31 @@ TEST_CASE(pow_test)
mm->add_instruction(migraphx::make_op("pow"), b, e);
p.compile(migraphx::ref::target{});
auto result = p.eval({}).back();
std
::
vector
<
float
>
results_vector
;
std::vector<float> results_vector(3);
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
std::vector<float> gold = data;
std::transform(
gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return std::pow(n, n); });
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(pow_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape s{migraphx::shape::float_type, {3}};
auto b = mm->add_parameter("b", s);
auto e = mm->add_parameter("e", s);
mm->add_instruction(migraphx::make_op("pow"), b, e);
p.compile(migraphx::ref::target{});
std::vector<float> data = {1, 2, 3};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {3}};
params0["b"] = migraphx::argument(input_fixed_shape0, data.data());
params0["e"] = migraphx::argument(input_fixed_shape0, data.data());
auto result = p.eval(params0).back();
std::vector<float> results_vector(3);
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
std::vector<float> gold = data;
std::transform(
...
...
@@ -4778,6 +5310,30 @@ TEST_CASE(prelu_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(prelu_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
std::vector<migraphx::shape::dynamic_dimension> dd{{2, 6, 0}};
migraphx::shape s{migraphx::shape::float_type, dd};
auto x = mm->add_parameter("x", s);
auto slope = mm->add_parameter("slope", s);
mm->add_instruction(migraphx::make_op("prelu"), x, slope);
p.compile(migraphx::ref::target{});
std::vector<float> x_data{-1, 0, 2};
std::vector<float> slope_data{2, 1, 2};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {3}};
params0["x"] = migraphx::argument(input_fixed_shape0, x_data.data());
params0["slope"] = migraphx::argument(input_fixed_shape0, slope_data.data());
auto result = p.eval(params0).back();
std::vector<float> results_vector;
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
std::vector<float> gold = {-2.0f, 0.0f, 2.0f};
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(quant_conv2d_padding_stride_test)
{
migraphx::program p;
...
...
@@ -6449,6 +7005,30 @@ TEST_CASE(sqdiff_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(sqdiff_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
std::vector<migraphx::shape::dynamic_dimension> dd{{2, 6, 0}};
migraphx::shape s{migraphx::shape::float_type, dd};
auto x = mm->add_parameter("x", s);
auto y = mm->add_parameter("y", s);
mm->add_instruction(migraphx::make_op("sqdiff"), x, y);
p.compile(migraphx::ref::target{});
std::vector<float> x_data{-1, 0, 1};
std::vector<float> y_data{1, 2, 3};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {3}};
params0["x"] = migraphx::argument(input_fixed_shape0, x_data.data());
params0["y"] = migraphx::argument(input_fixed_shape0, y_data.data());
auto result = p.eval(params0).back();
std::vector<float> results_vector(3);
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
std::vector<float> gold = {4, 4, 4};
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(sqrt_test)
{
migraphx::program p;
...
...
@@ -6584,6 +7164,30 @@ TEST_CASE(sub_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(sub_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
std::vector<migraphx::shape::dynamic_dimension> dd{{2, 6, 0}};
migraphx::shape s{migraphx::shape::float_type, dd};
auto x = mm->add_parameter("x", s);
auto y = mm->add_parameter("y", s);
mm->add_instruction(migraphx::make_op("sub"), x, y);
p.compile(migraphx::ref::target{});
std::vector<float> x_data{-1, 0, 1};
std::vector<float> y_data{1, 2, 3};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {3}};
params0["x"] = migraphx::argument(input_fixed_shape0, x_data.data());
params0["y"] = migraphx::argument(input_fixed_shape0, y_data.data());
auto result = p.eval(params0).back();
std::vector<float> results_vector(3);
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
std::vector<float> gold = {-2, -2, -2};
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(tan_test)
{
migraphx::program p;
...
...
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