| 43 | }; |
| 44 | |
| 45 | TEST_F(GraphMemoryTest, Basic) { |
| 46 | TrivialTestGraphInputYielder fake_input(4, 1, 10, false, {"/CPU:0"}); |
| 47 | GrapplerItem item; |
| 48 | CHECK(fake_input.NextItem(&item)); |
| 49 | item.feed.clear(); |
| 50 | |
| 51 | GraphMemory memory(item); |
| 52 | Status s = memory.InferStatically(devices_); |
| 53 | TF_CHECK_OK(s); |
| 54 | const GraphMemory::MemoryUsage& mem_usage = |
| 55 | memory.GetPeakMemoryUsage("/CPU:0"); |
| 56 | EXPECT_EQ(120, mem_usage.used_memory); |
| 57 | |
| 58 | std::set<string> tensors; |
| 59 | for (const auto& t : mem_usage.live_tensors) { |
| 60 | tensors.insert(strings::StrCat(t.node, ":", t.output_id)); |
| 61 | } |
| 62 | // When the execution of the 'Square' node completes, TF can start executing |
| 63 | // 'Square_1' and release the memory used by 'x'. Since we can't be sure of |
| 64 | // the order in which this takes place, in the worst case the 3 tensors are in |
| 65 | // memory. |
| 66 | std::set<string> expected; |
| 67 | expected.insert("Square:0"); |
| 68 | expected.insert("Square_1:0"); |
| 69 | expected.insert("x:0"); |
| 70 | EXPECT_EQ(expected, tensors); |
| 71 | } |
| 72 | |
| 73 | TEST_F(GraphMemoryTest, UnknownBatchSize) { |
| 74 | TrivialTestGraphInputYielder fake_input(4, 1, -1, false, {"/CPU:0"}); |
nothing calls this directly
no test coverage detected