| 66 | } |
| 67 | |
| 68 | StatusOr<HloScheduleProto> HloSchedule::ToProto() const { |
| 69 | TF_RETURN_IF_ERROR(Verify()); |
| 70 | HloScheduleProto proto; |
| 71 | for (const auto& id_sequence : sequences_) { |
| 72 | int64 computation_id = id_sequence.first; |
| 73 | const HloInstructionSequence& sequence = id_sequence.second; |
| 74 | HloScheduleProto::InstructionSequence& proto_sequence = |
| 75 | (*proto.mutable_sequences())[computation_id]; |
| 76 | proto_sequence.mutable_instruction_ids()->Reserve(sequence.size()); |
| 77 | for (const int64 id : sequence.ids()) { |
| 78 | proto_sequence.add_instruction_ids(id); |
| 79 | } |
| 80 | } |
| 81 | return std::move(proto); |
| 82 | } |
| 83 | |
| 84 | void HloSchedule::set_sequence(const HloComputation* computation, |
| 85 | absl::Span<HloInstruction* const> sequence) { |