Skip to content

Commit

Permalink
lint format fix
Browse files Browse the repository at this point in the history
  • Loading branch information
frank-dong-ms committed Aug 2, 2024
1 parent 989d57e commit 6f7b950
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions include/onnxruntime/core/graph/graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -1144,11 +1144,11 @@ class Graph { // NOLINT(clang-analyzer-optin.performance.Padding): preserve exi
@param model_file_path path of the model file.
@param initializer_size_threshold initializers larger or equal to this threshold (in bytes) are saved
in the external file. Initializer smaller than this threshold are included in the onnx file.
@align_offset offset will always be page aligned and alloction granularity aligned for mmap support.
This is done by padding previous tensor data with zeros keeping same length.
@align_offset offset will always be page aligned and alloction granularity aligned for mmap support.
This is done by padding previous tensor data with zeros keeping same length.
Tensor data will be aligned if > align_threshold
@align_threshold alignment threshold for size of data.
Having a low threshold will waste file space for small initializers.
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.
Default to 1MB.
@allocation_granularity the allocation Granularity for mmap() support.
Expand Down
5 changes: 3 additions & 2 deletions onnxruntime/core/graph/graph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4034,7 +4034,7 @@ ONNX_NAMESPACE::GraphProto Graph::ToGraphProtoWithExternalInitializers(const std

std::ofstream external_stream(modified_external_file_path, std::ofstream::out | std::ofstream::binary);
ORT_ENFORCE(external_stream.is_open());
int64_t external_offset = 0;
size_t external_offset = 0;

// Add the initializers to the result graph.
const auto& model_path = ModelPath();
Expand Down Expand Up @@ -4072,7 +4072,8 @@ ONNX_NAMESPACE::GraphProto Graph::ToGraphProtoWithExternalInitializers(const std
size_t alignment_factor = std::max(static_cast<size_t>(4096), allocation_granularity);
// Align to the next page or alloc granularity boundary
size_t new_external_offset = static_cast<size_t>(
std::floor((external_offset + alignment_factor - 1) / alignment_factor)) * alignment_factor;
std::floor((external_offset + alignment_factor - 1) / alignment_factor)) *
alignment_factor;

// padding tensor with zeros for alignment
for (size_t index = external_offset; index != new_external_offset; ++index) {
Expand Down
2 changes: 1 addition & 1 deletion onnxruntime/core/graph/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class Model {
// Get model's serialization proto data.
// Save initializer larger than the given threshold (in bytes) into an external binary file
// with the given name. This function is useful to avoid hitting the size limit of protobuf files.
// initializer offset could be page aligned and allocation granularity aligned for mmap support.
// initializer offset could be page aligned and allocation granularity aligned for mmap support.
ONNX_NAMESPACE::ModelProto ToGraphProtoWithExternalInitializers(const std::filesystem::path& external_file_name,
const std::filesystem::path& file_path,
size_t initializer_size_threshold,
Expand Down

0 comments on commit 6f7b950

Please sign in to comment.