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

Function TEST_F

tensorflow/core/grappler/optimizers/remapper_test.cc:46–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44};
45
46TEST_F(RemapperTest, FusedBatchNorm) {
47 tensorflow::Scope s = tensorflow::Scope::NewRootScope();
48 Output dflt = ops::Const(s.WithOpName("dflt"), {3.14f, 2.7f}, {2, 1, 1, 1});
49 Output x = ops::PlaceholderWithDefault(s.WithOpName("x"), dflt, {2, 1, 1, 1});
50 Output scale = ops::Const(s.WithOpName("scale"), {0.3f}, {1});
51 Output offset = ops::Const(s.WithOpName("offset"), {0.123f}, {1});
52 Output mean = ops::Const(s.WithOpName("mean"), {7.3f}, {1});
53 Output variance = ops::Const(s.WithOpName("variance"), {0.57f}, {1});
54 ops::FusedBatchNorm::Attrs attr;
55 attr = attr.IsTraining(false);
56 ops::FusedBatchNorm bn(s.WithOpName("batch_norm"), x, scale, offset, mean,
57 variance, attr);
58
59 GrapplerItem item;
60 TF_ASSERT_OK(s.ToGraphDef(&item.graph));
61 item.fetch = {"batch_norm"};
62
63 auto tensors_expected = EvaluateNodes(item.graph, item.fetch);
64 ASSERT_EQ(tensors_expected.size(), 1);
65
66 Remapper optimizer(RewriterConfig::ON);
67 GraphDef output;
68 TF_ASSERT_OK(optimizer.Optimize(nullptr, item, &output));
69
70 auto tensors = EvaluateNodes(output, item.fetch);
71 ASSERT_EQ(tensors.size(), 1);
72 test::ExpectTensorNear<float>(tensors[0], tensors_expected[0], 1e-6);
73}
74
75// Fails at optimizer.Optimize() call with error
76// Which is: Invalid argument: Mutation::Apply error: multiple nodes with the name: 'batch_norm/NCHWShapedOffset' exists in Mutation.

Callers

nothing calls this directly

Calls 15

PlaceholderWithDefaultFunction · 0.85
GetNumAvailableGPUsFunction · 0.85
WithOpNameMethod · 0.80
attrMethod · 0.80
listMethod · 0.80
FusedBatchNormClass · 0.70
nameMethod · 0.65
ConstFunction · 0.50
ShapeClass · 0.50
PlaceholderFunction · 0.50
Conv2DFunction · 0.50
BiasAddFunction · 0.50

Tested by

no test coverage detected