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

Function TEST_F

tensorflow/core/grappler/optimizers/constant_folding_test.cc:224–254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222};
223
224TEST_F(ConstantFoldingTest, SimpleFolding) {
225 // Build a simple graph with a few trivially prunable ops.
226 tensorflow::Scope s = tensorflow::Scope::NewRootScope();
227
228 Output a = ops::Const(s.WithOpName("a"), 1.0f, {1});
229 Output b = ops::Const(s.WithOpName("b"), 2.0f, {1});
230 Output c = ops::AddN(s.WithOpName("c").WithDevice("/CPU:0"), {a, b});
231 Output d = ops::AddN(s.WithOpName("d"), {b, c});
232
233 GrapplerItem item;
234 item.fetch.push_back("d");
235 TF_CHECK_OK(s.ToGraphDef(&item.graph));
236
237 ConstantFolding optimizer(/*cpu_device=*/nullptr);
238 GraphDef output;
239 Status status = optimizer.Optimize(/*cluster=*/nullptr, item, &output);
240 TF_EXPECT_OK(status);
241
242 EXPECT_EQ(1, output.node_size());
243
244 const NodeDef& node_d = output.node(0);
245 EXPECT_EQ("d", node_d.name());
246 EXPECT_EQ("Const", node_d.op());
247
248 std::vector<string> fetch = {"d"};
249 auto tensors_expected = EvaluateNodes(item.graph, fetch);
250 auto tensors = EvaluateNodes(output, fetch);
251 EXPECT_EQ(1, tensors_expected.size());
252 EXPECT_EQ(1, tensors.size());
253 test::ExpectTensorEqual<float>(tensors_expected[0], tensors[0]);
254}
255
256TEST_F(ConstantFoldingTest, AddTree) {
257 tensorflow::Scope s = tensorflow::Scope::NewRootScope();

Callers

nothing calls this directly

Calls 15

OnesLikeFunction · 0.85
MulNoNanFunction · 0.85
StackClass · 0.85
RealDivFunction · 0.85
PartialTensorShapeClass · 0.85
IsControlInputFunction · 0.85
PlaceholderWithDefaultFunction · 0.85
NodeDefBuilderClass · 0.85
ShapeNFunction · 0.85
AddPrefixToNodeNameFunction · 0.85
IdentityNFunction · 0.85
AsControlDependencyFunction · 0.85

Tested by

no test coverage detected