"tests/python/pytorch/nn/test_nn.py" did not exist on "580c7024170954de8918112425a5aad07ed48bb8"
Unverified Commit ebc4d63d authored by Juha Reunanen's avatar Juha Reunanen Committed by GitHub
Browse files

Workaround for #2506 (#2570)

* Do not put variants that can hold immutable types to vectors

* Enable build on gcc 11
parent a76f205b
...@@ -36,7 +36,6 @@ jobs: ...@@ -36,7 +36,6 @@ jobs:
run: cmake --build ${{ env.build_dir }} --config ${{ env.config }} --parallel 2 run: cmake --build ${{ env.build_dir }} --config ${{ env.config }} --parallel 2
ubuntu-latest-gcc-11: ubuntu-latest-gcc-11:
if: ${{ false }} # disabled until https://github.com/davisking/dlib/issues/2506 has been resolved
runs-on: 'ubuntu-latest' runs-on: 'ubuntu-latest'
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
......
...@@ -448,7 +448,7 @@ namespace ...@@ -448,7 +448,7 @@ namespace
std::shared_ptr<string> ptr_shared2; std::shared_ptr<string> ptr_shared2;
std::vector<std::complex<double>> p; std::vector<std::complex<double>> p;
#if __cplusplus >= 201703L #if __cplusplus >= 201703L
std::variant<int,float,std::string,immutable_type> q; std::variant<int,float,std::string> q;
std::optional<std::vector<std::string>> r; std::optional<std::vector<std::string>> r;
#endif #endif
...@@ -1163,115 +1163,132 @@ namespace ...@@ -1163,115 +1163,132 @@ namespace
v1.v.push_back(t1); v1.v.push_back(t1);
v1.v.push_back(t2); v1.v.push_back(t2);
#if __cplusplus >= 201703L
std::variant<int,float,std::string,immutable_type> i1, i2;
i1 = std::string("hello from variant that can hold an immutable type");
#else
// make it so that we don't need to add #if guards in every block below
std::string i1, i2;
i1 = "std::variant not supported";
#endif
{ {
dlib::serialize("serialization_test_macros.dat") << t1 << t2 << v1 << uptr1 << uptr2; dlib::serialize("serialization_test_macros.dat") << t1 << t2 << v1 << uptr1 << uptr2 << i1;
dlib::deserialize("serialization_test_macros.dat") >> t3 >> t4 >> v2 >> uptr3 >> uptr4; dlib::deserialize("serialization_test_macros.dat") >> t3 >> t4 >> v2 >> uptr3 >> uptr4 >> i2;
DLIB_TEST(t1 == t3); DLIB_TEST(t1 == t3);
DLIB_TEST(t2 == t4); DLIB_TEST(t2 == t4);
DLIB_TEST(v1 == v2); DLIB_TEST(v1 == v2);
DLIB_TEST(pointers_values_equal(uptr1, uptr3)); DLIB_TEST(pointers_values_equal(uptr1, uptr3));
DLIB_TEST(pointers_values_equal(uptr2, uptr4)); DLIB_TEST(pointers_values_equal(uptr2, uptr4));
DLIB_TEST(i1 == i2);
} }
{ {
std::stringstream ss; std::stringstream ss;
dlib::serialize(ss) << t1 << t2 << v1 << uptr1 << uptr2; dlib::serialize(ss) << t1 << t2 << v1 << uptr1 << uptr2 << i1;
dlib::deserialize(ss) >> t3 >> t4 >> v2 >> uptr3 >> uptr4; dlib::deserialize(ss) >> t3 >> t4 >> v2 >> uptr3 >> uptr4 >> i2;
DLIB_TEST(t1 == t3); DLIB_TEST(t1 == t3);
DLIB_TEST(t2 == t4); DLIB_TEST(t2 == t4);
DLIB_TEST(v1 == v2); DLIB_TEST(v1 == v2);
DLIB_TEST(pointers_values_equal(uptr1, uptr3)); DLIB_TEST(pointers_values_equal(uptr1, uptr3));
DLIB_TEST(pointers_values_equal(uptr2, uptr4)); DLIB_TEST(pointers_values_equal(uptr2, uptr4));
DLIB_TEST(i1 == i2);
} }
{ {
std::ostringstream sout; std::ostringstream sout;
dlib::serialize(sout) << t1 << t2 << v1 << uptr1 << uptr2; dlib::serialize(sout) << t1 << t2 << v1 << uptr1 << uptr2 << i1;
std::istringstream sin(sout.str()); std::istringstream sin(sout.str());
dlib::deserialize(sin) >> t3 >> t4 >> v2 >> uptr3 >> uptr4; dlib::deserialize(sin) >> t3 >> t4 >> v2 >> uptr3 >> uptr4 >> i2;
DLIB_TEST(t1 == t3); DLIB_TEST(t1 == t3);
DLIB_TEST(t2 == t4); DLIB_TEST(t2 == t4);
DLIB_TEST(v1 == v2); DLIB_TEST(v1 == v2);
DLIB_TEST(pointers_values_equal(uptr1, uptr3)); DLIB_TEST(pointers_values_equal(uptr1, uptr3));
DLIB_TEST(pointers_values_equal(uptr2, uptr4)); DLIB_TEST(pointers_values_equal(uptr2, uptr4));
DLIB_TEST(i1 == i2);
} }
{ {
std::vector<char> buf; std::vector<char> buf;
dlib::serialize(buf) << t1 << t2 << v1 << uptr1 << uptr2; dlib::serialize(buf) << t1 << t2 << v1 << uptr1 << uptr2 << i1;
dlib::deserialize(buf) >> t3 >> t4 >> v2 >> uptr3 >> uptr4; dlib::deserialize(buf) >> t3 >> t4 >> v2 >> uptr3 >> uptr4 >> i2;
DLIB_TEST(t1 == t3); DLIB_TEST(t1 == t3);
DLIB_TEST(t2 == t4); DLIB_TEST(t2 == t4);
DLIB_TEST(v1 == v2); DLIB_TEST(v1 == v2);
DLIB_TEST(pointers_values_equal(uptr1, uptr3)); DLIB_TEST(pointers_values_equal(uptr1, uptr3));
DLIB_TEST(pointers_values_equal(uptr2, uptr4)); DLIB_TEST(pointers_values_equal(uptr2, uptr4));
DLIB_TEST(i1 == i2);
} }
{ {
std::vector<int8_t> buf; std::vector<int8_t> buf;
dlib::serialize(buf) << t1 << t2 << v1 << uptr1 << uptr2; dlib::serialize(buf) << t1 << t2 << v1 << uptr1 << uptr2 << i1;
dlib::deserialize(buf) >> t3 >> t4 >> v2 >> uptr3 >> uptr4; dlib::deserialize(buf) >> t3 >> t4 >> v2 >> uptr3 >> uptr4 >> i2;
DLIB_TEST(t1 == t3); DLIB_TEST(t1 == t3);
DLIB_TEST(t2 == t4); DLIB_TEST(t2 == t4);
DLIB_TEST(v1 == v2); DLIB_TEST(v1 == v2);
DLIB_TEST(pointers_values_equal(uptr1, uptr3)); DLIB_TEST(pointers_values_equal(uptr1, uptr3));
DLIB_TEST(pointers_values_equal(uptr2, uptr4)); DLIB_TEST(pointers_values_equal(uptr2, uptr4));
DLIB_TEST(i1 == i2);
} }
{ {
std::vector<uint8_t> buf; std::vector<uint8_t> buf;
dlib::serialize(buf) << t1 << t2 << v1 << uptr1 << uptr2; dlib::serialize(buf) << t1 << t2 << v1 << uptr1 << uptr2 << i1;
dlib::deserialize(buf) >> t3 >> t4 >> v2 >> uptr3 >> uptr4; dlib::deserialize(buf) >> t3 >> t4 >> v2 >> uptr3 >> uptr4 >> i2;
DLIB_TEST(t1 == t3); DLIB_TEST(t1 == t3);
DLIB_TEST(t2 == t4); DLIB_TEST(t2 == t4);
DLIB_TEST(v1 == v2); DLIB_TEST(v1 == v2);
DLIB_TEST(pointers_values_equal(uptr1, uptr3)); DLIB_TEST(pointers_values_equal(uptr1, uptr3));
DLIB_TEST(pointers_values_equal(uptr2, uptr4)); DLIB_TEST(pointers_values_equal(uptr2, uptr4));
DLIB_TEST(i1 == i2);
} }
{ {
std::vector<char> buf1; std::vector<char> buf1;
dlib::serialize(buf1) << t1 << t2 << v1 << uptr1 << uptr2; dlib::serialize(buf1) << t1 << t2 << v1 << uptr1 << uptr2 << i1;
std::vector<int8_t> buf2(buf1.begin(), buf1.end()); std::vector<int8_t> buf2(buf1.begin(), buf1.end());
dlib::deserialize(buf2) >> t3 >> t4 >> v2 >> uptr3 >> uptr4; dlib::deserialize(buf2) >> t3 >> t4 >> v2 >> uptr3 >> uptr4 >> i2;
DLIB_TEST(t1 == t3); DLIB_TEST(t1 == t3);
DLIB_TEST(t2 == t4); DLIB_TEST(t2 == t4);
DLIB_TEST(v1 == v2); DLIB_TEST(v1 == v2);
DLIB_TEST(pointers_values_equal(uptr1, uptr3)); DLIB_TEST(pointers_values_equal(uptr1, uptr3));
DLIB_TEST(pointers_values_equal(uptr2, uptr4)); DLIB_TEST(pointers_values_equal(uptr2, uptr4));
DLIB_TEST(i1 == i2);
} }
{ {
std::vector<char> buf1; std::vector<char> buf1;
dlib::serialize(buf1) << t1 << t2 << v1 << uptr1 << uptr2; dlib::serialize(buf1) << t1 << t2 << v1 << uptr1 << uptr2 << i1;
std::vector<uint8_t> buf2(buf1.begin(), buf1.end()); std::vector<uint8_t> buf2(buf1.begin(), buf1.end());
dlib::deserialize(buf2) >> t3 >> t4 >> v2 >> uptr3 >> uptr4; dlib::deserialize(buf2) >> t3 >> t4 >> v2 >> uptr3 >> uptr4 >> i2;
DLIB_TEST(t1 == t3); DLIB_TEST(t1 == t3);
DLIB_TEST(t2 == t4); DLIB_TEST(t2 == t4);
DLIB_TEST(v1 == v2); DLIB_TEST(v1 == v2);
DLIB_TEST(pointers_values_equal(uptr1, uptr3)); DLIB_TEST(pointers_values_equal(uptr1, uptr3));
DLIB_TEST(pointers_values_equal(uptr2, uptr4)); DLIB_TEST(pointers_values_equal(uptr2, uptr4));
DLIB_TEST(i1 == i2);
} }
{ {
std::vector<int8_t> buf1; std::vector<int8_t> buf1;
dlib::serialize(buf1) << t1 << t2 << v1 << uptr1 << uptr2; dlib::serialize(buf1) << t1 << t2 << v1 << uptr1 << uptr2 << i1;
std::vector<uint8_t> buf2(buf1.begin(), buf1.end()); std::vector<uint8_t> buf2(buf1.begin(), buf1.end());
dlib::deserialize(buf2) >> t3 >> t4 >> v2 >> uptr3 >> uptr4; dlib::deserialize(buf2) >> t3 >> t4 >> v2 >> uptr3 >> uptr4 >> i2;
DLIB_TEST(t1 == t3); DLIB_TEST(t1 == t3);
DLIB_TEST(t2 == t4); DLIB_TEST(t2 == t4);
DLIB_TEST(v1 == v2); DLIB_TEST(v1 == v2);
DLIB_TEST(pointers_values_equal(uptr1, uptr3)); DLIB_TEST(pointers_values_equal(uptr1, uptr3));
DLIB_TEST(pointers_values_equal(uptr2, uptr4)); DLIB_TEST(pointers_values_equal(uptr2, uptr4));
DLIB_TEST(i1 == i2);
} }
} }
......
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