MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / TEST_F

Function TEST_F

tensorflow/core/grappler/costs/graph_memory_test.cc:45–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43};
44
45TEST_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
73TEST_F(GraphMemoryTest, UnknownBatchSize) {
74 TrivialTestGraphInputYielder fake_input(4, 1, -1, false, {"/CPU:0"});

Callers

nothing calls this directly

Calls 15

WithOpNameMethod · 0.80
nameMethod · 0.65
StrCatFunction · 0.50
ConstFunction · 0.50
VariableClass · 0.50
AssignFunction · 0.50
NextItemMethod · 0.45
clearMethod · 0.45
InferStaticallyMethod · 0.45
GetPeakMemoryUsageMethod · 0.45
insertMethod · 0.45
WithDeviceMethod · 0.45

Tested by

no test coverage detected