Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use the same mmap for all tensors from the same external data file #2331

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
check that mmap buffer identifier is file path
Signed-off-by: Soren Lassen <[email protected]>
sorenlassen committed Jun 21, 2023
commit b75378180aaf67e735882ec031fd3157d9268d2a
10 changes: 6 additions & 4 deletions src/Builder/FrontendDialectHelper.cpp
Original file line number Diff line number Diff line change
@@ -61,16 +61,18 @@ std::unique_ptr<llvm::MemoryBuffer> readExternalData_LE(
}
}
assert(!location.empty() && "missing external data location");
SmallVector<char> path(externalDataDir.begin(), externalDataDir.end());
llvm::sys::path::append(path, location);
SmallVector<char> pathBuf(externalDataDir.begin(), externalDataDir.end());
llvm::sys::path::append(pathBuf, location);
StringRef path(pathBuf.data(), pathBuf.size());
auto bufferOrError = llvm::MemoryBuffer::getFileSlice(
path, length, offset, /*IsVolatile=*/false);
if (std::error_code ec = bufferOrError.getError()) {
std::string pathStr(path.data(), path.size());
llvm::errs() << "Error " << ec.message() << " reading from file " << pathStr
llvm::errs() << "Error " << ec.message() << " reading from file " << path
<< ", offset=" << offset << ", length=" << length << "\n";
llvm_unreachable("llvm::MemoryBuffer::getFileSlice failed");
}
assert(bufferOrError.get()->getBufferIdentifier() == path &&
"buffer identifier is file path");
return std::move(bufferOrError.get());
}