aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Yunxing Dai <yunxing@google.com>2017-11-06 16:50:02 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-11-06 16:54:46 -0800
commit3532315ae6bb7a7e505c2d19e1cab262b25af420 (patch)
treefeaa9bba2d7ba24e76cf4f7dabb9d04bb04bb4e9
parent149d2cf28f4e81d8d4c0e66352c480254e548f96 (diff)
[BufferAssignment] Sort allocation's "Assigned" objects before converting to a proto.
This makes the buffer assignment's proto dump deterministic. RELNOTES: BufferAssignment's protocol buffer dump is now deterministic. PiperOrigin-RevId: 174783549
-rw-r--r--tensorflow/compiler/xla/service/buffer_assignment.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/tensorflow/compiler/xla/service/buffer_assignment.cc b/tensorflow/compiler/xla/service/buffer_assignment.cc
index 8536429846..b422b22df9 100644
--- a/tensorflow/compiler/xla/service/buffer_assignment.cc
+++ b/tensorflow/compiler/xla/service/buffer_assignment.cc
@@ -101,6 +101,11 @@ BufferAllocationProto BufferAllocation::ToProto() const {
proto_assigned->set_offset(buffer_offset_size.second.offset);
proto_assigned->set_size(buffer_offset_size.second.size);
}
+ std::sort(proto.mutable_assigned()->begin(), proto.mutable_assigned()->end(),
+ [](const BufferAllocationProto::Assigned& assign1,
+ const BufferAllocationProto::Assigned& assign2) {
+ return assign1.logical_buffer_id() < assign2.logical_buffer_id();
+ });
return proto;
}