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

Function TEST_F

tensorflow/core/grappler/optimizers/auto_parallel_test.cc:30–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28class AutoParallelTest : public ::testing::Test {};
29
30TEST_F(AutoParallelTest, SimpleParallel) {
31 tensorflow::Scope s = tensorflow::Scope::DisabledShapeInferenceScope();
32 Output constant_a = ops::Const(s.WithOpName("constant_a"), 1.0f, {1});
33 Output constant_b = ops::Const(s.WithOpName("constant_b"), 1, {1});
34 Output var = ops::Variable(s.WithOpName("var"), {1}, DT_FLOAT);
35 Output assign = ops::Assign(s.WithOpName("assign"), {var}, {constant_a});
36 Output identity = ops::Identity(s.WithOpName("identity"), {var});
37 Output fifo_queue = ops::FIFOQueue(s.WithOpName("fifo_queue"), {DT_FLOAT});
38 auto dequeue = ops::QueueDequeueMany(s.WithOpName("dequeue"), {fifo_queue},
39 {constant_b}, {DT_FLOAT});
40 Output add = ops::AddN(s.WithOpName("add"), {constant_a, dequeue[0]});
41 Output learning_rate = ops::Const(s.WithOpName("learning_rate"), 0.01f, {1});
42 Output apply_gradient = ops::ApplyGradientDescent(
43 s.WithOpName("apply_gradient"), {var}, {learning_rate}, {add});
44
45 GrapplerItem item;
46 item.init_ops.push_back("assign");
47 item.fetch.push_back("apply_gradient");
48 item.init_ops.push_back("assign");
49 TF_CHECK_OK(s.ToGraphDef(&item.graph));
50
51 AutoParallel parallel(2);
52 GraphDef output;
53 Status status = parallel.Optimize(nullptr, item, &output);
54 TF_EXPECT_OK(status);
55 EXPECT_EQ(21, output.node_size());
56
57 const NodeDef& node_assign = output.node(0);
58 EXPECT_EQ("assign", node_assign.name());
59 EXPECT_EQ("AutoParallel-Replica-0/constant_a", node_assign.input(1));
60
61 const NodeDef& node_constant_b = output.node(1);
62 EXPECT_EQ("constant_b", node_constant_b.name());
63
64 const NodeDef& node_fifo_queue = output.node(2);
65 EXPECT_EQ("fifo_queue", node_fifo_queue.name());
66
67 const NodeDef& node_identity = output.node(3);
68 EXPECT_EQ("identity", node_identity.name());
69 EXPECT_EQ("var", node_identity.input(0));
70
71 const NodeDef& node_var = output.node(4);
72 EXPECT_EQ("var", node_var.name());
73
74 const NodeDef& node_div_const0 = output.node(5);
75 EXPECT_EQ("AutoParallel-Replica-0/AutoParallel-Div-Const",
76 node_div_const0.name());
77
78 const NodeDef& node_div0 = output.node(6);
79 EXPECT_EQ("AutoParallel-Replica-0/AutoParallel-Div-apply_gradient",
80 node_div0.name());
81 const NodeDef& node_add0 = output.node(7);
82 EXPECT_EQ("AutoParallel-Replica-0/add", node_add0.name());
83
84 const NodeDef& node_gradient0 = output.node(8);
85 EXPECT_EQ("AutoParallel-Replica-0/apply_gradient", node_gradient0.name());
86
87 const NodeDef& node_constant_a0 = output.node(9);

Callers

nothing calls this directly

Calls 14

WithOpNameMethod · 0.80
nameMethod · 0.65
ConstFunction · 0.50
VariableClass · 0.50
AssignFunction · 0.50
IdentityClass · 0.50
FIFOQueueClass · 0.50
AddNFunction · 0.50
push_backMethod · 0.45
ToGraphDefMethod · 0.45
OptimizeMethod · 0.45

Tested by

no test coverage detected