mirror of
https://github.com/marian-nmt/marian.git
synced 2024-09-17 09:47:34 +03:00
Merged PR 10383: Align items while saving at 256-byte boundary
Align items while saving at 256-byte boundary. Maintains binary-compatibility.
This commit is contained in:
parent
c96d709d58
commit
5dfd8a7026
@ -22,6 +22,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||
- Gradient-checkpointing
|
||||
|
||||
### Fixed
|
||||
- Make sure that items are 256-byte aligned during saving
|
||||
- Make explicit matmul functions respect setting of cublasMathMode
|
||||
- Fix memory mapping for mixed paramter models
|
||||
- Removed naked pointer and potential memory-leak from file_stream.{cpp,h}
|
||||
- Compilation for GCC >= 7 due to exception thrown in destructor
|
||||
- Sort parameters by lexicographical order during allocation to ensure consistent
|
||||
|
@ -123,8 +123,7 @@ void saveItems(const std::string& fileName,
|
||||
headers.push_back(Header{item.name.size() + 1,
|
||||
(size_t)item.type,
|
||||
item.shape.size(),
|
||||
item.size()}); // item size without padding
|
||||
// @TODO: should this be done with padding as asked below?
|
||||
item.bytes.size()}); // binary item size with padding, will be 256-byte-aligned
|
||||
}
|
||||
|
||||
size_t headerSize = headers.size();
|
||||
@ -152,10 +151,10 @@ void saveItems(const std::string& fileName,
|
||||
|
||||
// Write out all values
|
||||
for(const auto& item : items)
|
||||
pos += out.write(item.data(), item.size()); // writes out data without padding, not aligned, @BUGBUG?
|
||||
|
||||
// @TODO: find out if padding should be enforced for memory-mapped storage like this:
|
||||
// pos += out.write(item.data(), item.bytes.size()); // writes out data with padding
|
||||
pos += out.write(item.data(), item.bytes.size()); // writes out data with padding, keeps 256-byte boundary.
|
||||
// Amazingly this is binary-compatible with V1 and aligned and
|
||||
// non-aligned models can be read with the same procedure.
|
||||
// No version-bump required. Gets 5-8% of speed back when mmapped.
|
||||
}
|
||||
|
||||
} // namespace binary
|
||||
|
@ -522,7 +522,9 @@ public:
|
||||
LOG(info, "Memory mapping model at {}", ptr);
|
||||
auto items = io::mmapItems(ptr);
|
||||
|
||||
// deal with default parameter object that might not be a mapped object
|
||||
// Deal with default parameter set object that might not be a mapped object.
|
||||
// This gets assigned during ExpressionGraph::setDevice(...) and by default
|
||||
// would contain allocated tensors. Here we replace it with a mmapped version.
|
||||
auto it = paramsByElementType_.find(defaultElementType_);
|
||||
if(it != paramsByElementType_.end()) {
|
||||
// there is parameter object for that type
|
||||
|
@ -73,7 +73,7 @@ public:
|
||||
for(auto model : models) {
|
||||
marian::filesystem::Path modelPath(model);
|
||||
ABORT_IF(modelPath.extension() != marian::filesystem::Path(".bin"),
|
||||
"Non-binarized models cannot be mapped");
|
||||
"Non-binarized models cannot be mmapped");
|
||||
mmaps_.push_back(std::move(mio::mmap_source(model)));
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user