From bd0dbb9b542e240506ef69b692bab2f003922e83 Mon Sep 17 00:00:00 2001
From: "A. Unique TensorFlower" <gardener@tensorflow.org>
Date: Thu, 16 May 2019 15:53:42 -0700
Subject: [PATCH] Add operator less to TensorUsageRecord; Small fix in tests.

PiperOrigin-RevId: 248616927
---
 .../lite/delegates/gpu/common/memory_management.h    |  5 +++++
 .../delegates/gpu/common/memory_management_test.cc   | 12 ++++++------
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/tensorflow/lite/delegates/gpu/common/memory_management.h b/tensorflow/lite/delegates/gpu/common/memory_management.h
index 147826134fa..4b8023b8d54 100644
--- a/tensorflow/lite/delegates/gpu/common/memory_management.h
+++ b/tensorflow/lite/delegates/gpu/common/memory_management.h
@@ -40,6 +40,11 @@ struct TensorUsageRecord {
 
   TensorUsageRecord(uint32_t size, TaskId first, TaskId last)
       : tensor_size(size), first_task(first), last_task(last) {}
+
+  // Default order of tensor usage records is increasing order of first_task.
+  bool operator<(const TensorUsageRecord& other) const {
+    return first_task < other.first_task;
+  }
 };
 
 // Information about assignment of tensors to shared objects
diff --git a/tensorflow/lite/delegates/gpu/common/memory_management_test.cc b/tensorflow/lite/delegates/gpu/common/memory_management_test.cc
index 6fd8b217b67..a1484cd0e55 100644
--- a/tensorflow/lite/delegates/gpu/common/memory_management_test.cc
+++ b/tensorflow/lite/delegates/gpu/common/memory_management_test.cc
@@ -28,17 +28,17 @@ TEST(Model, EmptyRecords) {
   ObjectsAssignment assignment;
   ASSERT_TRUE(
       AssignObjectsToTensors({}, MemoryStrategy::NAIVE, &assignment).ok());
-  ASSERT_TRUE(assignment.object_ids.empty());
-  ASSERT_TRUE(assignment.object_sizes.empty());
+  EXPECT_TRUE(assignment.object_ids.empty());
+  EXPECT_TRUE(assignment.object_sizes.empty());
   ASSERT_TRUE(
       AssignObjectsToTensors({}, MemoryStrategy::GREEDY, &assignment).ok());
-  ASSERT_TRUE(assignment.object_ids.empty());
-  ASSERT_TRUE(assignment.object_sizes.empty());
+  EXPECT_TRUE(assignment.object_ids.empty());
+  EXPECT_TRUE(assignment.object_sizes.empty());
   ASSERT_TRUE(
       AssignObjectsToTensors({}, MemoryStrategy::MINCOSTFLOW, &assignment)
           .ok());
-  ASSERT_TRUE(assignment.object_ids.empty());
-  ASSERT_TRUE(assignment.object_sizes.empty());
+  EXPECT_TRUE(assignment.object_ids.empty());
+  EXPECT_TRUE(assignment.object_sizes.empty());
 }
 
 TEST(Model, OneRecord) {