Skip to content

Commit

Permalink
Fix CI complaints
Browse files Browse the repository at this point in the history
  • Loading branch information
yuslepukhin committed Dec 10, 2024
1 parent 938bccf commit fab27a7
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 14 deletions.
11 changes: 6 additions & 5 deletions onnxruntime/core/framework/prepacked_weights_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ class PrepackedWeightsContainer final {
///
/// If saving is OFF, it is used to contain the weights memory mapped from disk.
/// Those weights are then moved to the shared container if weight sharing is enabled.
/// And also the interested kernels.
/// If x-session weight sharing is not enabled, the weights are stored in this container,
/// and shared with the interested kernels.
/// </summary>
class PrepackedForSerialization final {
public:
Expand All @@ -91,11 +92,11 @@ class PrepackedForSerialization final {

ORT_DISALLOW_COPY_ASSIGNMENT_AND_MOVE(PrepackedForSerialization);

// Maps a pre-packed weight blob key to PrepackedWeights instance
using KeyToBlobMap = std::unordered_map<std::string, PrePackedWeights>;

// Maps weight name to iterators in key_to_blobs_. It associates a weight name with its pre-packs.
// Normally, a single weight produces a single PrePackedWeights. But it is possible that a weight
// is pre-packed by different kernels.
// WeightToPrePacksMap maps weight name to a set of pre-packed
// keys contained in the KeyToBlobMap
using KeysPerWeight = std::unordered_set<std::string>; // blob keys
using WeightToPrePacksMap = std::unordered_map<std::string, KeysPerWeight>;

Expand Down Expand Up @@ -138,7 +139,7 @@ class PrepackedForSerialization final {
// The function would add or replace existing entry with references to it.
// If the entry is present, it would replace it with references to the existing entry.
// If the entry is not present, it would add reference to refer_if_absent
// If present it would return the existing entry otherwise std::nullopt
// If the entry is present it would return the existing entry otherwise std::nullopt
std::optional<PrePackedWeights> ReplaceWithReferenceIfSaving(const std::string& weight_name,
const std::string& key,
const PrePackedWeights& refer_if_absent);
Expand Down
2 changes: 1 addition & 1 deletion onnxruntime/core/framework/session_state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ Status SessionState::PrepackConstantInitializedTensors(
// everybody can share the same memory mapped entry
// the shared container takes ownership of the memory mapped entries

// The next like replaces the existing entry with references to it
// The next line replaces the existing entry with references to it
// and returns the container that holds the memory mapped entries
// so we can transfer it to shared container.
// if there is not an entry, we replace it with references to weights_to_be_filled_in
Expand Down
3 changes: 2 additions & 1 deletion onnxruntime/core/framework/tensor_external_data_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
// Licensed under the MIT License.
#pragma once

#include <cmath>
#include <filesystem>
#include <ostream>
#include <string>
#include <tuple>

#include <core/common/inlined_containers_fwd.h>
#include "core/common/status.h"
#include "core/common/path_string.h"
#include "core/common/status.h"
#include "core/framework/prepacked_weights_container.h"
#include "core/graph/onnx_protobuf.h"

Expand Down
2 changes: 1 addition & 1 deletion onnxruntime/core/graph/graph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4209,7 +4209,7 @@ Status Graph::ToGraphProtoWithExternalInitiallizersImpl(
}

if (!blob_keys_to_external_data.empty()) {
ORT_RETURN_IF_NOT(ExternalDataInfo::WritePrepackedToFileAndAddToProto(
ORT_RETURN_IF_NOT(!!ExternalDataInfo::WritePrepackedToFileAndAddToProto(

Check failure on line 4212 in onnxruntime/core/graph/graph.cc

View workflow job for this annotation

GitHub Actions / Vcpkg

expected expression
*model_saving_options.prepacked_for_save, blob_keys_to_external_data,
model_saving_options.align_offset,
model_saving_options.allocation_granularity,
Expand Down
4 changes: 2 additions & 2 deletions onnxruntime/test/framework/session_state_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ void PrepackedForSerialization::Subgraph::TestHarness<InspectLoadedSharedPrepack

// We are expecting to load only one shared pre-packed weight
// Saving is off, so we should not have any pre-packed weights for writing
const size_t expected_prepacks_for_writing = 0U;
constexpr const size_t expected_prepacks_for_writing = 0U;
ASSERT_EQ(expected_prepacks_for_writing, sub.GetNumberOfWeightsForWriting());

const size_t expected_blobs_for_writing = 0U;
constexpr const size_t expected_blobs_for_writing = 0U;
ASSERT_EQ(expected_blobs_for_writing, sub.GetNumberOfKeyedBlobsForWriting());

ASSERT_EQ(0U, key_to_blobs_.size());
Expand Down
8 changes: 4 additions & 4 deletions onnxruntime/test/framework/tensorutils_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ namespace test {
TEST(TensorProtoUtilsTest, SetExternalDataInformation) {
ONNX_NAMESPACE::TensorProto tensor_proto;
const std::filesystem::path kExternalDataPath("test.bin");
const int64_t init_offset = 100;
const size_t init_length = 200;
constexpr const int64_t init_offset = 100;
constexpr const size_t init_length = 200;

ExternalDataInfo::SetExternalLocationToProto(kExternalDataPath, init_offset, init_length, tensor_proto);

Expand All @@ -43,11 +43,11 @@ TEST(TensorProtoUtilsTest, SetExternalDataInformation) {
PrepackedForSerialization prepacked_for_serialization;
prepacked_for_serialization.SetSaveMode(true);
PrePackedWeights prepacked_weights;
constexpr size_t buffer_size = 100;
const std::string init_name = "test_initializer";
const std::string blob_key = "test_key";

std::array<float, 2> kData = {1.2345f, 2.4690f};
const size_t buffer_size = kData.size() * sizeof(float);

prepacked_weights.buffers_.push_back(BufferUniquePtr(kData.data(), BufferDeleter(nullptr)));
prepacked_weights.buffer_sizes_.push_back(buffer_size);
Expand All @@ -57,7 +57,7 @@ TEST(TensorProtoUtilsTest, SetExternalDataInformation) {

prepacked_for_serialization.MainGraph().WritePacked(init_name, blob_key, std::move(prepacked_weights));

const int64_t starting_offset = 300;
constexpr const int64_t starting_offset = 300;
int64_t external_offset = starting_offset;
std::stringstream ss;
const auto* blobs_for_weight = prepacked_for_serialization.MainGraph().GetBlobsForWeight(init_name);
Expand Down
1 change: 1 addition & 0 deletions orttraining/orttraining/training_api/module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "core/session/inference_session.h"
#include "core/session/environment.h"
#include "core/session/onnxruntime_session_options_config_keys.h"
#include "core/graph/model_saving_options.h"
#include "core/graph/graph_utils.h"

#include "orttraining/training_api/checkpoint.h"
Expand Down

0 comments on commit fab27a7

Please sign in to comment.