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

Function TEST_F

tensorflow/core/grappler/graph_topology_view_test.cc:49–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47};
48
49TEST_F(GraphTopologyViewTest, SimpleGraph) {
50 const GraphDef graph = CreateGraph({
51 {"a", {}}, // idx: 0
52 {"b", {}}, // idx: 1
53 {"c", {"a", "b"}}, // idx: 2
54 {"d", {"a", "c"}}, // idx: 3
55 });
56
57 GraphTopologyView graph_view;
58 TF_CHECK_OK(graph_view.InitializeFromGraph(graph));
59
60 EXPECT_TRUE(graph_view.is_initialized());
61
62 const NodeDef* a_by_name = graph_view.GetNode("a");
63 const NodeDef* a_by_idx = graph_view.GetNode(0);
64 ASSERT_TRUE(a_by_name);
65 ASSERT_TRUE(a_by_idx);
66 EXPECT_EQ(a_by_name, a_by_idx);
67
68 const NodeDef* b_by_name = graph_view.GetNode("b");
69 const NodeDef* b_by_idx = graph_view.GetNode(1);
70 ASSERT_TRUE(b_by_name);
71 ASSERT_TRUE(b_by_idx);
72 EXPECT_EQ(b_by_name, b_by_idx);
73
74 const absl::optional<int> b_idx = graph_view.GetNodeIndex(*b_by_name);
75 ASSERT_TRUE(b_idx.has_value());
76 EXPECT_EQ(b_idx.value(), 1);
77
78 const absl::optional<int> c_idx = graph_view.GetNodeIndex("c");
79 ASSERT_TRUE(c_idx.has_value());
80 EXPECT_EQ(c_idx.value(), 2);
81
82 using Fanin = absl::InlinedVector<int, 4>;
83 EXPECT_EQ(graph_view.GetFanin(0), Fanin());
84 EXPECT_EQ(graph_view.GetFanin(1), Fanin());
85 EXPECT_EQ(graph_view.GetFanin(2), Fanin({0, 1}));
86 EXPECT_EQ(graph_view.GetFanin(3), Fanin({0, 2}));
87
88 using Fanout = absl::InlinedVector<int, 2>;
89 EXPECT_EQ(graph_view.GetFanout(0), Fanout({2, 3}));
90 EXPECT_EQ(graph_view.GetFanout(1), Fanout({2}));
91 EXPECT_EQ(graph_view.GetFanout(2), Fanout({3}));
92 EXPECT_EQ(graph_view.GetFanout(3), Fanout());
93}
94
95TEST_F(GraphTopologyViewTest, GraphWithALoop) {
96 const GraphDef graph = CreateGraph({

Callers

nothing calls this directly

Calls 7

InitializeFromGraphMethod · 0.45
is_initializedMethod · 0.45
GetNodeMethod · 0.45
GetNodeIndexMethod · 0.45
has_valueMethod · 0.45
valueMethod · 0.45
GetFaninMethod · 0.45

Tested by

no test coverage detected