| 534 | } |
| 535 | |
| 536 | class TorchBinTensorSource final : public TensorSource { |
| 537 | public: |
| 538 | explicit TorchBinTensorSource(std::filesystem::path path) |
| 539 | : path_(std::move(path)), bytes_(read_file(path_)) { |
| 540 | const auto entries = read_zip_entries(bytes_); |
| 541 | std::string prefix; |
| 542 | const ZipEntry * pickle = nullptr; |
| 543 | for (const auto & [name, entry] : entries) { |
| 544 | if (name == "data.pkl" || (name.size() >= 9 && name.compare(name.size() - 9, 9, "/data.pkl") == 0)) { |
| 545 | prefix = name.substr(0, name.size() - std::string("data.pkl").size()); // keeps trailing '/' |
| 546 | pickle = &entry; |
| 547 | break; |
| 548 | } |
| 549 | } |
| 550 | if (pickle == nullptr) { |
nothing calls this directly
no test coverage detected