mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-29 23:06:41 +00:00
Turn off peak memory logging and fix memory pattern generation bug. (#5676)
* Turn off peak memory log lines and fix memory pattern generation bug. * Turn off peak memory log lines and fix memory pattern generation bug. Co-authored-by: Ubuntu <OrtTrainingDev3@OrtTrainingDev3.af05slrtruoetgaxwwjv5nsq5e.px.internal.cloudapp.net>
This commit is contained in:
parent
5d66cf017c
commit
9b010963b7
3 changed files with 24 additions and 13 deletions
|
|
@ -787,7 +787,7 @@ class PlannerImpl {
|
|||
for (size_t index = 0; index < current_plan.program_counter_start.size(); index += 1) {
|
||||
ORT_ENFORCE((current_plan.program_counter_start[index] > start) || (start == 0));
|
||||
ORT_ENFORCE(current_plan.program_counter_start[index] <= current_plan.program_counter_end[index]);
|
||||
ORT_ENFORCE((current_plan.program_counter_start[index] < SIZE_MAX) || (index == 0));
|
||||
ORT_ENFORCE(current_plan.program_counter_start[index] < SIZE_MAX);
|
||||
ORT_ENFORCE((current_plan.program_counter_end[index] > 0) || (index == 0));
|
||||
|
||||
start = current_plan.program_counter_start[index];
|
||||
|
|
|
|||
|
|
@ -292,7 +292,7 @@ ExecutionFrame::ExecutionFrame(const std::vector<int>& feed_mlvalue_idxs, const
|
|||
}
|
||||
|
||||
// log size of activation. Keep it commented out for now to avoid log flooding.
|
||||
VLOGS(session_state_.Logger(), 1) << "**** Allocated memory for activations, size: " <<mem_patterns_->patterns[i].PeakSize();
|
||||
// VLOGS(session_state_.Logger(), 1) << "**** Allocated memory for activations, size: " <<mem_patterns_->patterns[i].PeakSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,11 +70,7 @@ class MemPatternPlanner {
|
|||
size_t current = 0;
|
||||
size_t waste_bytes = std::numeric_limits<size_t>::max();
|
||||
size_t best_offset = 0;
|
||||
if (!blocks_.empty()) {
|
||||
auto last_block = allocs_[*blocks_.rbegin()];
|
||||
best_offset = last_block.block_.offset_ + last_block.block_.size_;
|
||||
}
|
||||
|
||||
bool best_offset_found = false;
|
||||
for (auto it = blocks_.begin(); it != blocks_.end(); it++) {
|
||||
// Memory block can be re-used as long as there is no overlap between their time schedules.
|
||||
if (allocs_[*it].reuse_ && !OverlappingTimeSchedules(program_counter_start, program_counter_end,
|
||||
|
|
@ -87,16 +83,25 @@ class MemPatternPlanner {
|
|||
if (gap >= size && (gap - size) < waste_bytes) {
|
||||
waste_bytes = gap - size;
|
||||
best_offset = current;
|
||||
best_offset_found = true;
|
||||
}
|
||||
}
|
||||
|
||||
current = std::max(current, allocs_[*it].block_.offset_ + allocs_[*it].block_.size_);
|
||||
}
|
||||
|
||||
ORT_ENFORCE(current <= buffer_size_);
|
||||
|
||||
if (current < buffer_size_) {
|
||||
auto gap = buffer_size_ - current;
|
||||
if ((gap >= size) && ((gap - size) < waste_bytes))
|
||||
if ((gap >= size) && ((gap - size) < waste_bytes)) {
|
||||
best_offset = current;
|
||||
best_offset_found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!best_offset_found) {
|
||||
best_offset = current;
|
||||
}
|
||||
|
||||
// we only need to bounds check the addition of size to best_offset as that is the only time we extend
|
||||
|
|
@ -128,10 +133,7 @@ class MemPatternPlanner {
|
|||
size_t current = 0;
|
||||
size_t waste_bytes = std::numeric_limits<size_t>::max();
|
||||
size_t best_offset = 0;
|
||||
if (!blocks_.empty()) {
|
||||
auto last_block = allocs_[*blocks_.rbegin()];
|
||||
best_offset = last_block.block_.offset_ + last_block.block_.size_;
|
||||
}
|
||||
bool best_offset_found = false;
|
||||
|
||||
for (auto it = blocks_.begin(); it != blocks_.end(); it++) {
|
||||
if (allocs_[*it].block_.offset_ >= current) {
|
||||
|
|
@ -139,15 +141,24 @@ class MemPatternPlanner {
|
|||
if (gap >= size && (gap - size) < waste_bytes) {
|
||||
waste_bytes = gap - size;
|
||||
best_offset = current;
|
||||
best_offset_found = true;
|
||||
}
|
||||
}
|
||||
current = std::max(current, allocs_[*it].block_.offset_ + allocs_[*it].block_.size_);
|
||||
}
|
||||
|
||||
ORT_ENFORCE(current <= buffer_size_);
|
||||
|
||||
if (current < buffer_size_) {
|
||||
auto gap = buffer_size_ - current;
|
||||
if ((gap >= size) && ((gap - size) < waste_bytes))
|
||||
if ((gap >= size) && ((gap - size) < waste_bytes)) {
|
||||
best_offset = current;
|
||||
best_offset_found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!best_offset_found) {
|
||||
best_offset = current;
|
||||
}
|
||||
|
||||
// we only need to bounds check the addition of size to best_offset as that is the only time we extend
|
||||
|
|
|
|||
Loading…
Reference in a new issue