Add operator less to TensorUsageRecord; Small fix in tests.

PiperOrigin-RevId: 248616927
This commit is contained in:
A. Unique TensorFlower 2019-05-16 15:53:42 -07:00 committed by TensorFlower Gardener
parent bb15fff6b9
commit bd0dbb9b54
2 changed files with 11 additions and 6 deletions
tensorflow/lite/delegates/gpu/common

View File

@ -40,6 +40,11 @@ struct TensorUsageRecord {
TensorUsageRecord(uint32_t size, TaskId first, TaskId last) TensorUsageRecord(uint32_t size, TaskId first, TaskId last)
: tensor_size(size), first_task(first), last_task(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 // Information about assignment of tensors to shared objects

View File

@ -28,17 +28,17 @@ TEST(Model, EmptyRecords) {
ObjectsAssignment assignment; ObjectsAssignment assignment;
ASSERT_TRUE( ASSERT_TRUE(
AssignObjectsToTensors({}, MemoryStrategy::NAIVE, &assignment).ok()); AssignObjectsToTensors({}, MemoryStrategy::NAIVE, &assignment).ok());
ASSERT_TRUE(assignment.object_ids.empty()); EXPECT_TRUE(assignment.object_ids.empty());
ASSERT_TRUE(assignment.object_sizes.empty()); EXPECT_TRUE(assignment.object_sizes.empty());
ASSERT_TRUE( ASSERT_TRUE(
AssignObjectsToTensors({}, MemoryStrategy::GREEDY, &assignment).ok()); AssignObjectsToTensors({}, MemoryStrategy::GREEDY, &assignment).ok());
ASSERT_TRUE(assignment.object_ids.empty()); EXPECT_TRUE(assignment.object_ids.empty());
ASSERT_TRUE(assignment.object_sizes.empty()); EXPECT_TRUE(assignment.object_sizes.empty());
ASSERT_TRUE( ASSERT_TRUE(
AssignObjectsToTensors({}, MemoryStrategy::MINCOSTFLOW, &assignment) AssignObjectsToTensors({}, MemoryStrategy::MINCOSTFLOW, &assignment)
.ok()); .ok());
ASSERT_TRUE(assignment.object_ids.empty()); EXPECT_TRUE(assignment.object_ids.empty());
ASSERT_TRUE(assignment.object_sizes.empty()); EXPECT_TRUE(assignment.object_sizes.empty());
} }
TEST(Model, OneRecord) { TEST(Model, OneRecord) {