| 1020 | } |
| 1021 | |
| 1022 | string MemoryUsageTracker::ToString() const { |
| 1023 | string output = |
| 1024 | absl::StrCat("MemoryUsageTracker for ", computation_->name(), "\n"); |
| 1025 | absl::StrAppend(&output, |
| 1026 | "Memory usage: ", HumanReadableNumBytes(memory_usage()), " (", |
| 1027 | memory_usage(), " bytes)"); |
| 1028 | for (auto* item = instruction_list_.first(); item != nullptr; |
| 1029 | item = instruction_list_.next(item)) { |
| 1030 | const HloInstruction* instruction = item->instruction; |
| 1031 | string inprogress = item == in_progress_item_ ? " in-progress" : ""; |
| 1032 | string placed = item->placed ? " placed" : ""; |
| 1033 | absl::StrAppend(&output, " ", instruction->name(), inprogress, placed, |
| 1034 | "\n Defines:\n"); |
| 1035 | for (BufferId buffer_id : item->buffers_defined) { |
| 1036 | const Buffer& buffer = buffers_[buffer_id]; |
| 1037 | string live = IsCurrentlyLive(buffer_id) ? " live" : ""; |
| 1038 | absl::StrAppend(&output, " ", buffer.ToString(), live, ", ", |
| 1039 | buffer.unfinished_user_count, " unfinished uses\n"); |
| 1040 | } |
| 1041 | absl::StrAppend(&output, " Uses:\n"); |
| 1042 | for (BufferId buffer_id : item->buffers_used) { |
| 1043 | absl::StrAppend(&output, " ", buffers_[buffer_id].ToString(), "\n"); |
| 1044 | } |
| 1045 | } |
| 1046 | return output; |
| 1047 | } |
| 1048 | |
| 1049 | StatusOr<Shape> MemoryUsageTracker::GetCompactShape(const HloInstruction* hlo) { |
| 1050 | auto it = compact_shape_.find(hlo); |
no test coverage detected