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

Function TEST

tensorflow/compiler/jit/rearrange_function_argument_pass_test.cc:39–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37namespace tensorflow {
38
39TEST(RearrangeFunctionArgumentForFunctionTest, Basic) {
40 FunctionDefLibrary fdl;
41 {
42 // Function for StatefulPartitionedCall's "f", If's
43 // "then_branch"/"else_branch".
44 // "arg0" (T=DT_RESOURCE), "arg1" (T=DT_BOOL)
45 // "ret0" = "arg1"
46 // "ret1" = "arg0"
47 tensorflow::Scope s = tensorflow::Scope::NewRootScope();
48 Output arg0 = ops::_Arg(s.WithOpName("arg0"), DT_RESOURCE, 0);
49 Output arg1 = ops::_Arg(s.WithOpName("arg1"), DT_BOOL, 1);
50 auto ret0 = ops::_Retval(s.WithOpName("ret0"), arg1, 0);
51 auto ret1 = ops::_Retval(s.WithOpName("ret1"), arg0, 1);
52 std::unique_ptr<Graph> g(new Graph(OpRegistry::Global()));
53 TF_CHECK_OK(s.ToGraph(g.get()));
54 FunctionDef *xla_fdef = fdl.add_function();
55 TF_CHECK_OK(GraphToFunctionDef(*g, "f1", xla_fdef));
56 }
57 {
58 // Function for While's "body".
59 // "arg0" (T=DT_RESOURCE), "arg1" (T=DT_BOOL)
60 // "ret0" = "arg0"
61 // "ret1" = "arg1"
62 tensorflow::Scope s = tensorflow::Scope::NewRootScope();
63 Output arg0 = ops::_Arg(s.WithOpName("arg0"), DT_RESOURCE, 0);
64 Output arg1 = ops::_Arg(s.WithOpName("arg1"), DT_BOOL, 1);
65 auto ret0 = ops::_Retval(s.WithOpName("ret0"), arg0, 0);
66 auto ret1 = ops::_Retval(s.WithOpName("ret1"), arg1, 0);
67 std::unique_ptr<Graph> g(new Graph(OpRegistry::Global()));
68 TF_CHECK_OK(s.ToGraph(g.get()));
69 FunctionDef *xla_fdef = fdl.add_function();
70 TF_CHECK_OK(GraphToFunctionDef(*g, "f2", xla_fdef));
71 }
72 {
73 // Function for While's "cond".
74 // "arg0" (T=DT_RESOURCE), "arg1" (T=DT_BOOL)
75 // "ret0" = "arg1"
76 tensorflow::Scope s = tensorflow::Scope::NewRootScope();
77 Output arg0 = ops::_Arg(s.WithOpName("arg0"), DT_RESOURCE, 0);
78 Output arg1 = ops::_Arg(s.WithOpName("arg1"), DT_BOOL, 1);
79 auto ret0 = ops::_Retval(s.WithOpName("ret0"), arg1, 0);
80 std::unique_ptr<Graph> g(new Graph(OpRegistry::Global()));
81 TF_CHECK_OK(s.ToGraph(g.get()));
82 FunctionDef *xla_fdef = fdl.add_function();
83 TF_CHECK_OK(GraphToFunctionDef(*g, "f3", xla_fdef));
84 }
85 FunctionLibraryDefinition fld(OpRegistry::Global(), fdl);
86
87 // Build the XLA computation graph.
88 // "arg0" (T=DT_RESOURCE), "arg1" (T=DT_INT32)
89 // "arg0", "arg1" -> "if" (If) -> "ret0", "ret1"
90 // "arg0", "arg1" -> "while" (While) -> "ret2", "ret3"
91 tensorflow::Scope s = tensorflow::Scope::NewRootScope();
92 Output arg0 = ops::_Arg(s.WithOpName("arg0"), DT_RESOURCE, 0);
93 Output arg1 = ops::_Arg(s.WithOpName("arg1"), DT_BOOL, 1);
94 NameAttrList f;
95 f.set_name("f1");
96 auto if_op = ops::If(s.WithOpName("if"), arg1,

Callers

nothing calls this directly

Calls 15

IfFunction · 0.85
FunctionDefToBodyHelperFunction · 0.85
AttrSliceClass · 0.85
WithOpNameMethod · 0.80
ToGraphMethod · 0.80
attrMethod · 0.80
signatureMethod · 0.80
BuildNodeNameIndexMethod · 0.80
input_nodeMethod · 0.80
ConstFunction · 0.70
nameMethod · 0.65

Tested by

no test coverage detected