| 483 | } |
| 484 | |
| 485 | inline void deserialize(resizable_tensor& item, std::istream& in) |
| 486 | { |
| 487 | int version; |
| 488 | deserialize(version, in); |
| 489 | if (version != 2) |
| 490 | throw serialization_error("Unexpected version found while deserializing dlib::resizable_tensor."); |
| 491 | |
| 492 | long long num_samples=0, k=0, nr=0, nc=0; |
| 493 | deserialize(num_samples, in); |
| 494 | deserialize(k, in); |
| 495 | deserialize(nr, in); |
| 496 | deserialize(nc, in); |
| 497 | item.set_size(num_samples, k, nr, nc); |
| 498 | byte_orderer bo; |
| 499 | auto sbuf = in.rdbuf(); |
| 500 | for (auto& d : item) |
| 501 | { |
| 502 | static_assert(sizeof(d)==4, "This serialization code assumes we are writing 4 byte floats"); |
| 503 | if (sbuf->sgetn((char*)&d,sizeof(d)) != sizeof(d)) |
| 504 | { |
| 505 | in.setstate(std::ios::badbit); |
| 506 | throw serialization_error("Error reading data while deserializing dlib::resizable_tensor."); |
| 507 | } |
| 508 | bo.little_to_host(d); |
| 509 | } |
| 510 | } |
| 511 | |
| 512 | // ---------------------------------------------------------------------------------------- |
| 513 |
nothing calls this directly
no test coverage detected