static*/
| 1196 | } |
| 1197 | |
| 1198 | /*static*/ StatusOr<std::unique_ptr<PresetAssignments>> |
| 1199 | MemorySpaceAssignment::Run(HloModule* module, |
| 1200 | const HloLiveRange& hlo_live_range, |
| 1201 | const HloAliasAnalysis& alias_analysis, |
| 1202 | const Options& options) { |
| 1203 | CHECK(module->has_schedule()); |
| 1204 | VLOG(4) << "Module before memory space assignment: "; |
| 1205 | XLA_VLOG_LINES(4, module->ToString()); |
| 1206 | VLOG(4) << "Schedule: " << module->schedule().ToString(); |
| 1207 | MemorySpaceAssignment memory_space_assignment(module, options, |
| 1208 | hlo_live_range); |
| 1209 | auto algorithm = absl::make_unique<AlternateMemoryBestFitHeap>( |
| 1210 | &memory_space_assignment.allocation_sequence_list_, options, |
| 1211 | alias_analysis, hlo_live_range); |
| 1212 | |
| 1213 | HeapSimulator::Options heap_simulator_options; |
| 1214 | heap_simulator_options.may_reuse_operand_buffers = false; |
| 1215 | TF_RETURN_IF_ERROR(HeapSimulator::Run(std::move(algorithm), *module, |
| 1216 | module->schedule(), alias_analysis, |
| 1217 | options.size_fn, heap_simulator_options) |
| 1218 | .status()); |
| 1219 | |
| 1220 | TF_RETURN_IF_ERROR(memory_space_assignment.Process()); |
| 1221 | memory_space_assignment.ScheduleAsynchronousCopies(); |
| 1222 | TF_RETURN_IF_ERROR(memory_space_assignment.SimplifyGraph()); |
| 1223 | TF_RETURN_IF_ERROR(memory_space_assignment.FixSchedule()); |
| 1224 | |
| 1225 | VLOG(4) << "Module after memory space assignment: "; |
| 1226 | XLA_VLOG_LINES(4, module->ToString()); |
| 1227 | TF_CHECK_OK(module->schedule().Verify()); |
| 1228 | VLOG(1) << "Maximum number of outstanding async copies: " |
| 1229 | << CountMaximumOutstandingAsyncCopies(*module); |
| 1230 | |
| 1231 | TF_RETURN_IF_ERROR( |
| 1232 | memory_space_assignment.VerifyAndExportHeapSimulatorTrace()); |
| 1233 | |
| 1234 | return std::move(memory_space_assignment.preset_assignments_); |
| 1235 | } |
| 1236 | |
| 1237 | void MemorySpaceAssignment::Allocation::AddUse(HloUse use) { |
| 1238 | HloInstruction* operand = |
nothing calls this directly
no test coverage detected