Skip to content

Commit

Permalink
refine comments
Browse files Browse the repository at this point in the history
  • Loading branch information
frank-dong-ms authored Aug 21, 2024
1 parent c3bec9f commit 079295f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion include/onnxruntime/core/graph/graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -1140,13 +1140,21 @@ class Graph { // NOLINT(clang-analyzer-optin.performance.Padding): preserve exi
ONNX_NAMESPACE::GraphProto ToGraphProto() const;

// Options to align external initializer offset.
// For models running on CPU, ORT will try to use mmap to load external initializers.
// To use mmap, external initializer need to be offset aligned.
// ORT saves external initializers into signle data file, each initializer is accessed with
// offset(start position of initializer) and length(byte length of initializer) of the data file.
// To use mmap, each offset need to be aligned which means offset need to divisible by
// allocation granularity(64KB for windows and 4K for other OSes).
// With align_offset to true, ORT will align offset for large initializer when

Check warning on line 1149 in include/onnxruntime/core/graph/graph.h

View workflow job for this annotation

GitHub Actions / Optional Lint C++

[cpplint] reported by reviewdog 🐶 Line ends in whitespace. Consider deleting these extra spaces. [whitespace/end_of_line] [4] Raw Output: include/onnxruntime/core/graph/graph.h:1149: Line ends in whitespace. Consider deleting these extra spaces. [whitespace/end_of_line] [4]
// save ONNX model with external data file.
struct OffsetAlignmentInfo {
// Offset will always be page aligned and allocation granularity aligned for mmap support.
// This is done by padding previous tensor data with zeros keeping same length.
bool align_offset = false;
// Alignment threshold for size of data.
// Having a low threshold will waste file space for small initializers.
// Only when tensor's data is > the page_align_threshold it will be force aligned.
// Only when tensor's data size is > the page_align_threshold it will be force aligned.
// Default to 1MB.
int64_t align_threshold = 1048576;
// The allocation Granularity for mmap() support.
Expand Down

0 comments on commit 079295f

Please sign in to comment.