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

Function TEST

tensorflow/core/framework/function_test.cc:66–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64)doc");
65
66TEST(TFunc, SquarePlusOne) {
67 auto fdef = FDH::Create(
68 // Name
69 "SquarePlusOne",
70 // Inputs
71 {"x: T"},
72 // Outputs
73 {"y: T"},
74 // Attrs
75 {"T: {float, double, int32, int64}"},
76 // Nodes
77 {// a = Square<T>(x)
78 {{"a"}, "Square", {"x"}, {{"T", "$T"}}},
79 // o = One<T>()
80 // NOTE: We can also have a Cast<Tin, Tout>(x) instead.
81 {{"o"}, "One", {}, {{"T", "$T"}}},
82 // y = Add<T>(a, o)
83 {{"y"}, "Add", {"a:y", "o:y"}, {{"T", "$T"}}}},
84 // Returns
85 {{"y", "y:z:0"}});
86
87 const char* e = R"P(
88SquarePlusOne[T:{float, double, int32, int64}](x:T) -> (y:T) {
89 a = Square[T=$T](x)
90 o = One[T=$T]()
91 y = Add[T=$T](a:y, o:y)
92 return y = y:z:0
93}
94)P";
95 EXPECT_EQ(DebugString(fdef), e);
96
97 // Instantiate one with T=float
98 InstantiationResult result;
99 TF_ASSERT_OK(
100 InstantiateFunction(fdef, Attrs({{"T", DT_FLOAT}}), GetOpSig, &result));
101 const char* e2 = R"P(
102(x:float) -> (y:float) {
103 a = Square[T=float](x)
104 o = One[T=float]()
105 y = Add[T=float](a, o)
106}
107)P";
108 EXPECT_EQ(result.arg_types, DataTypeVector({DT_FLOAT}));
109 EXPECT_EQ(result.ret_types, DataTypeVector({DT_FLOAT}));
110 EXPECT_EQ(DebugString(result.nodes), e2);
111}
112
113TEST(TFunc, ControlDep) {
114 auto fdef = FDH::Create(

Callers

nothing calls this directly

Calls 15

InstantiateFunctionFunction · 0.85
AttrSliceClass · 0.85
XTimesTwoFunction · 0.85
WXPlusBFunction · 0.85
XTimesTwoInt32Function · 0.85
XTimesFourFunction · 0.85
XTimes16Function · 0.85
MakeGradDefFunction · 0.85
GDefFunction · 0.85
NDefFunction · 0.85
FunctionDefHashFunction · 0.85
FunctionDefsEqualFunction · 0.85

Tested by

no test coverage detected