| 264 | } |
| 265 | |
| 266 | BufferAllocationProto BufferAllocation::ToProto() const { |
| 267 | BufferAllocationProto proto; |
| 268 | proto.set_index(index_); |
| 269 | proto.set_size(size_); |
| 270 | proto.set_is_thread_local(is_thread_local_); |
| 271 | proto.set_is_tuple(is_tuple_); |
| 272 | proto.set_color(color_.value()); |
| 273 | if (is_entry_computation_parameter_) { |
| 274 | proto.set_is_entry_computation_parameter(true); |
| 275 | for (int64 idx : param_shape_index()) { |
| 276 | proto.add_parameter_shape_index(idx); |
| 277 | } |
| 278 | proto.set_parameter_number(parameter_number_); |
| 279 | } |
| 280 | proto.set_is_constant(is_constant_); |
| 281 | proto.set_maybe_live_out(maybe_live_out_); |
| 282 | for (const auto& buffer_offset_size : assigned_buffers_) { |
| 283 | BufferAllocationProto::Assigned* proto_assigned = proto.add_assigned(); |
| 284 | proto_assigned->set_logical_buffer_id(buffer_offset_size.first->id()); |
| 285 | proto_assigned->set_offset(buffer_offset_size.second.offset); |
| 286 | proto_assigned->set_size(buffer_offset_size.second.size); |
| 287 | } |
| 288 | absl::c_sort(*proto.mutable_assigned(), |
| 289 | [](const BufferAllocationProto::Assigned& assign1, |
| 290 | const BufferAllocationProto::Assigned& assign2) { |
| 291 | return assign1.logical_buffer_id() < |
| 292 | assign2.logical_buffer_id(); |
| 293 | }); |
| 294 | return proto; |
| 295 | } |
| 296 | |
| 297 | static bool CompareHloValuesById(const HloValue* a, const HloValue* b) { |
| 298 | return a->id() < b->id(); |
nothing calls this directly
no test coverage detected