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

Function TEST_F

tensorflow/core/common_runtime/constant_folding_test.cc:114–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112};
113
114TEST_F(ConstantFoldingTest, Basic) {
115 Scope s = Scope::NewRootScope();
116 BuildSimpleGraph(&s);
117 Graph g(OpRegistry::Global());
118 TF_ASSERT_OK(s.ToGraph(&g));
119
120 bool was_mutated;
121 TF_ASSERT_OK(ConstantFold(ConstantFoldingOptions{}, nullptr, Env::Default(),
122 nullptr, &g, &was_mutated));
123 EXPECT_TRUE(was_mutated);
124
125 std::unordered_map<string, Node*> index = g.BuildNodeNameIndex();
126 Node* s1 = index.at("s1");
127 Node* s2 = index.at("s2");
128 // Nodes s1 and s2 now should now have a constant input
129 EXPECT_EQ(1, s1->num_inputs());
130 ExpectNodeClose<float>(*(s1->in_nodes().begin()), {1.0, 2.0, 3.0, 4.0},
131 {2, 2});
132 EXPECT_EQ(1, s2->num_inputs());
133 ExpectNodeClose<float>(*(s2->in_nodes().begin()), {2.0, 1.0, 4.0, 3.0},
134 {2, 2});
135}
136
137// Tests that different node creation ordering creates same graph after constant
138// folding.

Callers

nothing calls this directly

Calls 15

BuildSimpleGraphFunction · 0.85
ConstantFoldFunction · 0.85
DefaultFunction · 0.85
BroadcastGradientArgsFunction · 0.85
XTimesTwoFunction · 0.85
NodeDefBuilderClass · 0.85
ShapeNFunction · 0.85
ImmutableConstFunction · 0.85
ToGraphMethod · 0.80
BuildNodeNameIndexMethod · 0.80
WithOpNameMethod · 0.80
DoShapeInferenceMethod · 0.80

Tested by

no test coverage detected