Commit f729a7e0 authored by charlie's avatar charlie
Browse files

Add tests

parent a32a1040
......@@ -6174,6 +6174,21 @@ def transpose_test():
return ([node], [x], [y])
@onnx_test
def transpose_dyn_test():
x = helper.make_tensor_value_info('0', TensorProto.FLOAT, [None, 2, 2, 3])
y = helper.make_tensor_value_info('1', TensorProto.FLOAT, [None, 3, 2, 2])
node = onnx.helper.make_node(
'Transpose',
perm=[0, 3, 1, 2],
inputs=['0'],
outputs=['1'],
)
return ([node], [x], [y])
@onnx_test
def transpose_gather_test():
x = helper.make_tensor_value_info('data', TensorProto.FLOAT, [3, 5, 4, 6])
......
......@@ -5923,6 +5923,24 @@ TEST_CASE(transpose_test)
EXPECT(p == prog);
}
TEST_CASE(transpose_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
auto input = mm->add_parameter(
"0",
migraphx::shape{migraphx::shape::float_type, {{1, 4, 0}, {2, 2, 0}, {2, 2, 0}, {3, 3, 0}}});
std::vector<int64_t> perm{0, 3, 1, 2};
auto t0 = mm->add_instruction(migraphx::make_op("transpose", {{"permutation", perm}}), input);
mm->add_return({t0});
migraphx::onnx_options options;
options.default_dyn_dim_value = {1, 4, 0};
auto prog = migraphx::parse_onnx("transpose_dyn_test.onnx", options);
EXPECT(p == prog);
}
TEST_CASE(topk_attrk_test)
{
migraphx::program p;
......
......@@ -2243,6 +2243,22 @@ TEST_CASE(transpose_shape)
throws_shape(migraphx::make_op("transpose", {{"permutation", {1, 2}}}), input);
}
TEST_CASE(transpose_dyn_shape0)
{
migraphx::shape input{migraphx::shape::float_type, {{1, 4, 0}, {2, 2, 0}}};
migraphx::shape output{migraphx::shape::float_type, {{2, 2, 0}, {1, 4, 0}}};
expect_shape(input, migraphx::make_op("transpose", {{"permutation", {0, 1}}}), input);
expect_shape(output, migraphx::make_op("transpose", {{"permutation", {1, 0}}}), input);
}
TEST_CASE(transpose_dyn_shape1)
{
migraphx::shape input{migraphx::shape::float_type, {{1, 4, 0}, {4, 4, 0}, {4, 4, 0}}};
migraphx::shape output{migraphx::shape::float_type, {{4, 4, 0}, {4, 4, 0}, {1, 4, 0}}};
expect_shape(input, migraphx::make_op("transpose", {{"permutation", {0, 1, 2}}}), input);
expect_shape(output, migraphx::make_op("transpose", {{"permutation", {2, 1, 0}}}), input);
}
TEST_CASE(step_test)
{
migraphx::shape s1{migraphx::shape::float_type, {1, 2, 4}};
......
......@@ -60,15 +60,16 @@ TEST_CASE(abs_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(abs_dynamic_test)
TEST_CASE(abs_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
std::vector<float> a = {-1, 2, -3, 4};
auto* mm = p.get_main_module();
migraphx::shape s{migraphx::shape::float_type, {{2, 8, 0}, {2, 2, 0}}};
auto input = mm->add_parameter("X", s);
mm->add_instruction(migraphx::make_op("abs"), input);
p.compile(migraphx::ref::target{});
std::vector<float> a = {-1, 2, -3, 4};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {2, 2}};
params0["X"] = migraphx::argument(input_fixed_shape0, a.data());
......@@ -97,17 +98,17 @@ TEST_CASE(acos_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(acos_dynamic_test)
TEST_CASE(acos_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape::dynamic_dimension dd{3, 8, 0};
migraphx::shape s{migraphx::shape::float_type, {dd}};
auto input = mm->add_parameter("X", s);
std::vector<float> input_data{-0.8f, 0.0f, 1.0f};
mm->add_instruction(migraphx::make_op("acos"), input);
p.compile(migraphx::ref::target{});
std::vector<float> input_data{-0.8f, 0.0f, 1.0f};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {3}};
params0["X"] = migraphx::argument(input_fixed_shape0, input_data.data());
......@@ -138,7 +139,7 @@ TEST_CASE(acosh_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(acosh_dynamic_test)
TEST_CASE(acosh_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
......@@ -419,17 +420,17 @@ TEST_CASE(asin_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(asin_dynamic_test)
TEST_CASE(asin_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape::dynamic_dimension dd{3, 8, 0};
migraphx::shape s{migraphx::shape::float_type, {dd}};
auto input = mm->add_parameter("X", s);
std::vector<float> input_data{-0.5f, 0.0f, 0.9f};
mm->add_instruction(migraphx::make_op("asin"), input);
p.compile(migraphx::ref::target{});
std::vector<float> input_data{-0.5f, 0.0f, 0.9f};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {3}};
params0["X"] = migraphx::argument(input_fixed_shape0, input_data.data());
......@@ -460,17 +461,17 @@ TEST_CASE(asinh_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(asinh_dynamic_test)
TEST_CASE(asinh_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape::dynamic_dimension dd{3, 8, 0};
migraphx::shape s{migraphx::shape::float_type, {dd}};
auto input = mm->add_parameter("X", s);
std::vector<float> input_data{-0.5f, 0.0f, 0.9f};
mm->add_instruction(migraphx::make_op("asinh"), input);
p.compile(migraphx::ref::target{});
std::vector<float> input_data{-0.5f, 0.0f, 0.9f};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {3}};
params0["X"] = migraphx::argument(input_fixed_shape0, input_data.data());
......@@ -501,17 +502,17 @@ TEST_CASE(atan_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(atan_dynamic_test)
TEST_CASE(atan_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape::dynamic_dimension dd{3, 8, 0};
migraphx::shape s{migraphx::shape::float_type, {dd}};
auto input = mm->add_parameter("X", s);
std::vector<float> input_data{-1.0f, 0.0f, 1.0f};
mm->add_instruction(migraphx::make_op("atan"), input);
p.compile(migraphx::ref::target{});
std::vector<float> input_data{-1.0f, 0.0f, 1.0f};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {3}};
params0["X"] = migraphx::argument(input_fixed_shape0, input_data.data());
......@@ -542,17 +543,17 @@ TEST_CASE(atanh_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(atanh_dynamic_test)
TEST_CASE(atanh_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape::dynamic_dimension dd{3, 8, 0};
migraphx::shape s{migraphx::shape::float_type, {dd}};
auto input = mm->add_parameter("X", s);
std::vector<float> input_data{0.4435683f, 0.6223626f, 0.316958f};
mm->add_instruction(migraphx::make_op("atanh"), input);
p.compile(migraphx::ref::target{});
std::vector<float> input_data{0.4435683f, 0.6223626f, 0.316958f};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {3}};
params0["X"] = migraphx::argument(input_fixed_shape0, input_data.data());
......@@ -758,17 +759,17 @@ TEST_CASE(ceil_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(ceil_dynamic_test)
TEST_CASE(ceil_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape::dynamic_dimension dd{4, 12, 0};
migraphx::shape s{migraphx::shape::float_type, {dd}};
auto input = mm->add_parameter("X", s);
std::vector<float> input_data = {1.1, 1.5, 1.6, -1.1, -1.5, -1.6, 0.0, 2.0, -2.0};
auto input = mm->add_parameter("X", s);
mm->add_instruction(migraphx::make_op("ceil"), input);
p.compile(migraphx::ref::target{});
std::vector<float> input_data = {1.1, 1.5, 1.6, -1.1, -1.5, -1.6, 0.0, 2.0, -2.0};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {9}};
params0["X"] = migraphx::argument(input_fixed_shape0, input_data.data());
......@@ -925,7 +926,7 @@ TEST_CASE(contiguous_test)
EXPECT(migraphx::verify_range(results_vector, data));
}
TEST_CASE(conv_dynamic_batch_test)
TEST_CASE(conv_dyn_batch_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
......@@ -1042,7 +1043,7 @@ TEST_CASE(conv_dynamic_batch_test)
EXPECT(migraphx::verify_range(results_vector, sol));
}
TEST_CASE(conv_dynamic_img_shape_test)
TEST_CASE(conv_dyn_img_shape_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
......@@ -1131,7 +1132,7 @@ TEST_CASE(conv_dynamic_img_shape_test)
EXPECT(migraphx::verify_range(results_vector, sol));
}
TEST_CASE(conv_dynamic_weights_shape_test)
TEST_CASE(conv_dyn_weights_shape_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
......@@ -1208,7 +1209,7 @@ TEST_CASE(conv_dynamic_weights_shape_test)
EXPECT(migraphx::verify_range(results_vector, sol));
}
TEST_CASE(conv_dynamic_img_same_upper_test)
TEST_CASE(conv_dyn_img_same_upper_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
......@@ -1279,7 +1280,7 @@ TEST_CASE(conv_dynamic_img_same_upper_test)
EXPECT(migraphx::verify_range(results_vector, sol));
}
TEST_CASE(conv_dynamic_kernel_same_upper_test)
TEST_CASE(conv_dyn_kernel_same_upper_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
......@@ -1353,7 +1354,7 @@ TEST_CASE(conv_dynamic_kernel_same_upper_test)
EXPECT(migraphx::verify_range(results_vector, sol));
}
TEST_CASE(conv_dynamic_kernel_same_lower_test)
TEST_CASE(conv_dyn_kernel_same_lower_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
......@@ -1698,17 +1699,17 @@ TEST_CASE(cos_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(cos_dynamic_test)
TEST_CASE(cos_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape::dynamic_dimension dd{3, 8, 0};
migraphx::shape s{migraphx::shape::float_type, {dd}};
auto input = mm->add_parameter("X", s);
std::vector<float> input_data{-1, 0, 1};
mm->add_instruction(migraphx::make_op("cos"), input);
p.compile(migraphx::ref::target{});
std::vector<float> input_data{-1, 0, 1};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {3}};
params0["X"] = migraphx::argument(input_fixed_shape0, input_data.data());
......@@ -1739,17 +1740,17 @@ TEST_CASE(cosh_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(cosh_dynamic_test)
TEST_CASE(cosh_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape::dynamic_dimension dd{3, 8, 0};
migraphx::shape s{migraphx::shape::float_type, {dd}};
auto input = mm->add_parameter("X", s);
std::vector<float> input_data = {-1.0, 2.0, -3.0, 4.0};
auto input = mm->add_parameter("X", s);
mm->add_instruction(migraphx::make_op("cosh"), input);
p.compile(migraphx::ref::target{});
std::vector<float> input_data = {-1.0, 2.0, -3.0, 4.0};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {4}};
params0["X"] = migraphx::argument(input_fixed_shape0, input_data.data());
......@@ -1972,18 +1973,18 @@ TEST_CASE(elu_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(elu_dynamic_test)
TEST_CASE(elu_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape::dynamic_dimension dd{3, 8, 0};
migraphx::shape s{migraphx::shape::float_type, {dd}};
auto input = mm->add_parameter("X", s);
std::vector<float> input_data{-1.0, 2.0, -3.0, 4.0};
auto input = mm->add_parameter("X", s);
float alpha = 0.5;
mm->add_instruction(migraphx::make_op("elu", {{"alpha", alpha}}), input);
p.compile(migraphx::ref::target{});
std::vector<float> input_data{-1.0, 2.0, -3.0, 4.0};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {4}};
params0["X"] = migraphx::argument(input_fixed_shape0, input_data.data());
......@@ -2090,17 +2091,17 @@ TEST_CASE(erf_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(erf_dynamic_test)
TEST_CASE(erf_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape::dynamic_dimension dd{3, 8, 0};
migraphx::shape s{migraphx::shape::float_type, {dd}};
auto input = mm->add_parameter("X", s);
std::vector<float> input_data = {0.73785057, 1.58165966, -0.43597795, -0.01677432};
auto input = mm->add_parameter("X", s);
mm->add_instruction(migraphx::make_op("erf"), input);
p.compile(migraphx::ref::target{});
std::vector<float> input_data = {0.73785057, 1.58165966, -0.43597795, -0.01677432};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {4}};
params0["X"] = migraphx::argument(input_fixed_shape0, input_data.data());
......@@ -2131,17 +2132,17 @@ TEST_CASE(exp_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(exp_dynamic_test)
TEST_CASE(exp_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape::dynamic_dimension dd{3, 8, 0};
migraphx::shape s{migraphx::shape::float_type, {dd}};
auto input = mm->add_parameter("X", s);
std::vector<float> input_data{-1, 0, 1};
mm->add_instruction(migraphx::make_op("exp"), input);
p.compile(migraphx::ref::target{});
std::vector<float> input_data{-1, 0, 1};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {3}};
params0["X"] = migraphx::argument(input_fixed_shape0, input_data.data());
......@@ -2172,17 +2173,17 @@ TEST_CASE(floor_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(floor_dynamic_test)
TEST_CASE(floor_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape::dynamic_dimension dd{5, 12, 0};
migraphx::shape s{migraphx::shape::float_type, {dd}};
auto input = mm->add_parameter("X", s);
std::vector<float> input_data = {1.1, 1.5, 0.6, -1.1, -1.5, -0.6, 0.0, 2.0, -2.0};
auto input = mm->add_parameter("X", s);
mm->add_instruction(migraphx::make_op("floor"), input);
p.compile(migraphx::ref::target{});
std::vector<float> input_data = {1.1, 1.5, 0.6, -1.1, -1.5, -0.6, 0.0, 2.0, -2.0};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {9}};
params0["X"] = migraphx::argument(input_fixed_shape0, input_data.data());
......@@ -2776,16 +2777,16 @@ TEST_CASE(identity_test)
EXPECT(std::equal(data.begin(), data.end(), results_vector.begin()));
}
TEST_CASE(identity_dynamic_test)
TEST_CASE(identity_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape s{migraphx::shape::float_type, {{2, 4, 0}, {2, 4, 0}}};
auto input = mm->add_parameter("X", s);
std::vector<int> input_data{1, 2, 3, 4};
mm->add_instruction(migraphx::make_op("identity"), input);
p.compile(migraphx::ref::target{});
std::vector<int> input_data{1, 2, 3, 4};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::int32_type, {2, 2}};
params0["X"] = migraphx::argument(input_fixed_shape0, input_data.data());
......@@ -3022,17 +3023,17 @@ TEST_CASE(isnan_test)
}
}
TEST_CASE(isnan_dynamic_test)
TEST_CASE(isnan_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape s{migraphx::shape::float_type, {{2, 2, 0}, {3, 8, 0}}};
auto input = mm->add_parameter("X", s);
auto nan_val = std::numeric_limits<float>::quiet_NaN();
std::vector<float> input_data = {1.2, 5.2, nan_val, nan_val, 0., 100.};
auto input = mm->add_parameter("X", s);
auto nan_val = std::numeric_limits<float>::quiet_NaN();
mm->add_instruction(migraphx::make_op("isnan"), input);
p.compile(migraphx::ref::target{});
std::vector<float> input_data = {1.2, 5.2, nan_val, nan_val, 0., 100.};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {2, 3}};
params0["X"] = migraphx::argument(input_fixed_shape0, input_data.data());
......@@ -3393,17 +3394,17 @@ TEST_CASE(log_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(log_dynamic_test)
TEST_CASE(log_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape::dynamic_dimension dd{3, 8, 0};
migraphx::shape s{migraphx::shape::float_type, {dd}};
auto input = mm->add_parameter("X", s);
std::vector<float> input_data = {1, 2, 3};
auto input = mm->add_parameter("X", s);
mm->add_instruction(migraphx::make_op("log"), input);
p.compile(migraphx::ref::target{});
std::vector<float> input_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, input_data.data());
......@@ -4063,7 +4064,7 @@ TEST_CASE(fmod_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(fmod_dynamic_test)
TEST_CASE(fmod_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
......@@ -4359,16 +4360,17 @@ TEST_CASE(neg_test)
EXPECT(migraphx::verify_range(result_vector, gold));
}
TEST_CASE(neg_dynamic_test)
TEST_CASE(neg_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape s{migraphx::shape::float_type, {{2, 4, 0}, {3, 3, 0}}};
std::vector<float> a = {1.0f, 1.3f, -1.2f, 0.0f, -100.f, 200.f};
auto input = mm->add_parameter("X", s);
auto ret = mm->add_instruction(migraphx::make_op("neg"), input);
auto input = mm->add_parameter("X", s);
auto ret = mm->add_instruction(migraphx::make_op("neg"), input);
mm->add_return({ret});
p.compile(migraphx::ref::target{});
std::vector<float> a = {1.0f, 1.3f, -1.2f, 0.0f, -100.f, 200.f};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {2, 3}};
params0["X"] = migraphx::argument(input_fixed_shape0, a.data());
......@@ -4380,7 +4382,7 @@ TEST_CASE(neg_dynamic_test)
EXPECT(migraphx::verify_range(result_vector, gold));
}
TEST_CASE(nms_dynamic_out_test)
TEST_CASE(nms_dyn_out_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
......@@ -4415,7 +4417,7 @@ TEST_CASE(nms_dynamic_out_test)
EXPECT(migraphx::verify_range(result, gold));
}
TEST_CASE(nms_dynamic_batch_test)
TEST_CASE(nms_dyn_batch_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
......@@ -4461,7 +4463,7 @@ TEST_CASE(nms_dynamic_batch_test)
EXPECT(migraphx::verify_range(result, gold));
}
TEST_CASE(nms_dynamic_boxes_test)
TEST_CASE(nms_dyn_boxes_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
......@@ -4504,7 +4506,7 @@ TEST_CASE(nms_dynamic_boxes_test)
EXPECT(migraphx::verify_range(result, gold));
}
TEST_CASE(nms_dynamic_classes_test)
TEST_CASE(nms_dyn_classes_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
......@@ -4750,17 +4752,17 @@ TEST_CASE(not_test)
}
}
TEST_CASE(not_dynamic_test)
TEST_CASE(not_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape::dynamic_dimension dd{3, 8, 0};
migraphx::shape s{migraphx::shape::float_type, {dd}};
auto input = mm->add_parameter("X", s);
std::vector<float> input_data{0, 8, 1, -32};
mm->add_instruction(migraphx::make_op("not"), input);
p.compile(migraphx::ref::target{});
std::vector<float> input_data{0, 8, 1, -32};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {4}};
params0["X"] = migraphx::argument(input_fixed_shape0, input_data.data());
......@@ -5484,17 +5486,17 @@ TEST_CASE(recip_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(recip_dynamic_test)
TEST_CASE(recip_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape::dynamic_dimension dd{3, 8, 0};
migraphx::shape s{migraphx::shape::float_type, {dd}};
auto input = mm->add_parameter("X", s);
std::vector<float> input_data{-0.5f, 0.1f, 0.5f};
mm->add_instruction(migraphx::make_op("recip"), input);
p.compile(migraphx::ref::target{});
std::vector<float> input_data{-0.5f, 0.1f, 0.5f};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {3}};
params0["X"] = migraphx::argument(input_fixed_shape0, input_data.data());
......@@ -5792,17 +5794,17 @@ TEST_CASE(relu_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(relu_dynamic_test)
TEST_CASE(relu_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape::dynamic_dimension dd{3, 8, 0};
migraphx::shape s{migraphx::shape::float_type, {dd}};
auto input = mm->add_parameter("X", s);
std::vector<float> input_data{-1.f, 0.f, 1.f};
mm->add_instruction(migraphx::make_op("relu"), input);
p.compile(migraphx::ref::target{});
std::vector<float> input_data{-1.f, 0.f, 1.f};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {3}};
params0["X"] = migraphx::argument(input_fixed_shape0, input_data.data());
......@@ -6097,17 +6099,17 @@ TEST_CASE(round_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(round_dynamic_test)
TEST_CASE(round_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape::dynamic_dimension dd{4, 10, 0};
migraphx::shape s{migraphx::shape::float_type, {dd}};
auto input = mm->add_parameter("X", s);
std::vector<float> input_data{1.1, 1.5, 1.6, -1.1, -1.5, -1.6, 0.0, 2.0, -2.0};
mm->add_instruction(migraphx::make_op("round"), input);
p.compile(migraphx::ref::target{});
std::vector<float> input_data{1.1, 1.5, 1.6, -1.1, -1.5, -1.6, 0.0, 2.0, -2.0};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {9}};
params0["X"] = migraphx::argument(input_fixed_shape0, input_data.data());
......@@ -6133,17 +6135,17 @@ TEST_CASE(rsqrt_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(rsqrt_dynamic_test)
TEST_CASE(rsqrt_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape::dynamic_dimension dd{3, 8, 0};
migraphx::shape s{migraphx::shape::float_type, {dd}};
auto input = mm->add_parameter("X", s);
std::vector<float> input_data{4.0, 16.0, 64.0};
mm->add_instruction(migraphx::make_op("rsqrt"), input);
p.compile(migraphx::ref::target{});
std::vector<float> input_data{4.0, 16.0, 64.0};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {3}};
params0["X"] = migraphx::argument(input_fixed_shape0, input_data.data());
......@@ -6702,16 +6704,16 @@ TEST_CASE(sigmoid_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(sigmoid_dynamic_test)
TEST_CASE(sigmoid_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape s{migraphx::shape::float_type, {{2, 4, 0}, {2, 2, 0}}};
auto input = mm->add_parameter("X", s);
std::vector<float> input_data{-1, 2, -3, 4};
mm->add_instruction(migraphx::make_op("sigmoid"), input);
p.compile(migraphx::ref::target{});
std::vector<float> input_data{-1, 2, -3, 4};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {2, 2}};
params0["X"] = migraphx::argument(input_fixed_shape0, input_data.data());
......@@ -6738,17 +6740,17 @@ TEST_CASE(sign_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(sign_dynamic_test)
TEST_CASE(sign_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape::dynamic_dimension dd{3, 8, 0};
migraphx::shape s{migraphx::shape::float_type, {dd}};
auto input = mm->add_parameter("X", s);
std::vector<float> input_data{1.02481645, 0.85643062, -0.03404123, -0.92791926, 0.0};
mm->add_instruction(migraphx::make_op("sign"), input);
p.compile(migraphx::ref::target{});
std::vector<float> input_data{1.02481645, 0.85643062, -0.03404123, -0.92791926, 0.0};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {5}};
params0["X"] = migraphx::argument(input_fixed_shape0, input_data.data());
......@@ -6777,17 +6779,17 @@ TEST_CASE(sin_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(sin_dynamic_test)
TEST_CASE(sin_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape::dynamic_dimension dd{3, 8, 0};
migraphx::shape s{migraphx::shape::float_type, {dd}};
auto input = mm->add_parameter("X", s);
std::vector<float> input_data = {-1, 0, 1};
auto input = mm->add_parameter("X", s);
mm->add_instruction(migraphx::make_op("sin"), input);
p.compile(migraphx::ref::target{});
std::vector<float> input_data = {-1, 0, 1};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {3}};
params0["X"] = migraphx::argument(input_fixed_shape0, input_data.data());
......@@ -7328,11 +7330,6 @@ TEST_CASE(transpose_test)
mm->add_instruction(migraphx::make_op("transpose", {{"permutation", perm}}), l);
p.compile(migraphx::ref::target{});
auto result = p.eval({}).back();
result.visit([&](auto output) {
std::vector<size_t> new_lens = {1, 3, 2, 2};
EXPECT(bool{output.get_shape().lens() == new_lens});
});
}
{
migraphx::program p;
......@@ -7352,6 +7349,33 @@ TEST_CASE(transpose_test)
}
}
TEST_CASE(transpose_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape s{migraphx::shape::float_type, {{1, 4, 0}, {2, 2, 0}, {2, 2, 0}, {3, 3, 0}}};
auto l = mm->add_parameter("X", s);
std::vector<int64_t> perm = {0, 3, 1, 2};
mm->add_instruction(migraphx::make_op("transpose", {{"permutation", perm}}), l);
p.compile(migraphx::ref::target{});
std::vector<float> data(12);
std::iota(data.begin(), data.end(), 0);
migraphx::parameter_map params;
migraphx::shape input_fixed_shape{migraphx::shape::float_type, {1, 2, 2, 3}};
params["X"] = migraphx::argument(input_fixed_shape, data.data());
auto result = p.eval({}).back();
result.visit([&](auto output) {
std::vector<size_t> new_lens = {1, 3, 2, 2};
EXPECT(bool{output.get_shape().lens() == new_lens});
});
std::vector<float> results_vector(12);
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
// no change in the data buffer
EXPECT(migraphx::verify_range(results_vector, data));
}
TEST_CASE(unsqueeze_test)
{
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment