fix inline_container.cc inplace loading (#108573)

Summary:
bypass-github-pytorch-ci-checks
bypass-github-export-checks
force-merge-on-github

Differential Revision: D48971847

Pull Request resolved: https://github.com/pytorch/pytorch/pull/108573
Approved by: https://github.com/wqfish
This commit is contained in:
Shiyan Deng
2023-09-06 00:02:42 +00:00
committed by PyTorch MergeBot
parent ff28b4b908
commit d471eaeb1d

View File

@ -368,7 +368,11 @@ size_t PyTorchStreamReader::getRecord(
iter != nullptr, iter != nullptr,
"Failed to create zip reader iter: ", "Failed to create zip reader iter: ",
mz_zip_get_error_string(mz_zip_get_last_error(ar_.get()))); mz_zip_get_error_string(mz_zip_get_last_error(ar_.get())));
std::vector<uint8_t> buffer;
if (buf == nullptr) {
buffer.resize(chunk_size);
buf = buffer.data();
}
for (size_t offset = 0; offset < stat.m_uncomp_size; offset += chunk_size) { for (size_t offset = 0; offset < stat.m_uncomp_size; offset += chunk_size) {
size_t want_size = size_t want_size =
std::min(chunk_size, (size_t)stat.m_uncomp_size - offset); std::min(chunk_size, (size_t)stat.m_uncomp_size - offset);