Skip to content

Commit

Permalink
changes to make the memory planner debug output easier to interpret
Browse files Browse the repository at this point in the history
  • Loading branch information
ddavis-2015 committed Nov 11, 2024
1 parent f651c88 commit 5e1a1c9
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions tensorflow/lite/micro/memory_planner/greedy_memory_planner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ char GetOrdinalCharacter(int i) {
} else if (i < 62) {
return 'A' + (i - 36);
}
return '*';
return GetOrdinalCharacter(i % 62);
}

} // namespace
Expand Down Expand Up @@ -335,9 +335,13 @@ void GreedyMemoryPlanner::PrintMemoryPlan() {
CalculateOffsetsIfNeeded();

for (int i = 0; i < buffer_count_; ++i) {
MicroPrintf("%c (id=%d): size=%d, offset=%d, first_used=%d last_used=%d",
GetOrdinalCharacter(i), i, requirements_[i].size,
buffer_offsets_[i], requirements_[i].first_time_used,
char c = '*';
if (requirements_[i].first_time_used != requirements_[i].last_time_used) {
c = GetOrdinalCharacter(i);
}
MicroPrintf("%c (id=%d): size=%d, offset=%d, first_used=%d last_used=%d", c,
i, requirements_[i].size, buffer_offsets_[i],
requirements_[i].first_time_used,
requirements_[i].last_time_used);
}

Expand Down Expand Up @@ -379,7 +383,11 @@ void GreedyMemoryPlanner::PrintMemoryPlan() {
const int line_end = ((offset + size) * kLineWidth) / max_size;
for (int n = line_start; n < line_end; ++n) {
if (line[n] == '.') {
line[n] = GetOrdinalCharacter(i);
if (requirements->first_time_used == requirements->last_time_used) {
line[n] = '*';
} else {
line[n] = GetOrdinalCharacter(i);
}
} else {
line[n] = '!';
}
Expand Down

0 comments on commit 5e1a1c9

Please sign in to comment.