"magic_pdf/git@developer.sourcefind.cn:wangsen/mineru.git" did not exist on "d19911f11302100ac7de61da3f51e66a55a637b8"
Commit c34bdf3b authored by wsttiger's avatar wsttiger
Browse files

Added a test for contiguous but not working

parent 3dc42104
......@@ -158,6 +158,45 @@ struct test_gemm
}
};
struct test_contiguous
{
migraph::program create_program() const
{
migraph::program p;
migraph::shape s{migraph::shape::float_type, {32, 16, 128, 128}, {262144, 128, 1, 16384}};
auto x = p.add_parameter("x", s);
p.add_instruction(migraph::contiguous{}, x);
return p;
}
migraph::program::parameter_map create_params() const
{
migraph::program::parameter_map m;
m["x"] = migraph::generate_argument({migraph::shape::float_type, {32, 16, 128, 128}});
return m;
}
};
void contiguous_test()
{
migraph::shape a_shape{migraph::shape::float_type, {1, 3, 2, 2}, {12, 1, 6, 3}};
std::vector<float> data(12);
std::iota(data.begin(), data.end(), 0);
migraph::program p;
auto l = p.add_literal(migraph::literal{a_shape, data});
p.add_instruction(migraph::contiguous{}, l);
p.compile(migraph::miopen::miopen_target{});
auto result = p.eval({});
std::vector<float> results_vector(12);
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
std::vector<size_t> new_lens = {1, 3, 2, 2};
std::vector<size_t> new_strides = {12, 1, 6, 3};
std::vector<float> gold = {0, 3, 6, 9, 1, 4, 7, 10, 2, 5, 8, 11};
EXPECT(test::verify_range(results_vector, gold));
}
int main()
{
verify_program<test_add>();
......@@ -165,4 +204,6 @@ int main()
verify_program<test_conv_relu>();
verify_program<test_conv_pooling>();
verify_program<test_gemm>();
// verify_program<test_contiguous>();
contiguous_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