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

Function TEST

tensorflow/core/grappler/optimizers/data/fusion_utils_test.cc:54–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52}
53
54TEST(FusionUtilsTest, FuseFunctionsByComposition) {
55 GraphDef graph;
56 auto *parent_function = graph.mutable_library()->add_function();
57 *parent_function = test::function::XTimesTwo();
58 auto *function = graph.mutable_library()->add_function();
59 *function = test::function::XTimesTwo();
60
61 auto *fused_function = FuseFunctions(
62 *parent_function, *function, "fused_maps", fusion_utils::ComposeSignature,
63 fusion_utils::ComposeInput, fusion_utils::ComposeOutput,
64 fusion_utils::MergeNodes, graph.mutable_library());
65
66 EXPECT_EQ(fused_function->signature().name(), "fused_maps");
67 EXPECT_EQ(fused_function->signature().input_arg_size(), 1);
68 EXPECT_EQ(fused_function->signature().output_arg_size(), 1);
69 EXPECT_EQ(fused_function->ret_size(), 1);
70 std::cerr << fused_function->DebugString();
71 CheckUniqueNames(*fused_function);
72
73 const NodeDef *parent_mul = nullptr, *output_mul = nullptr;
74 for (const auto &fused_node : fused_function->node_def()) {
75 if (fused_node.op() == "Mul") {
76 if (fused_node.name() == "y")
77 parent_mul = &fused_node;
78 else
79 output_mul = &fused_node;
80 }
81 }
82 ASSERT_NE(parent_mul, nullptr);
83 ASSERT_NE(output_mul, nullptr);
84 EXPECT_EQ(ParseNodeConnection(output_mul->input(0)), parent_mul->name());
85
86 auto output_value = fused_function->ret().at(
87 fused_function->signature().output_arg(0).name());
88
89 EXPECT_EQ(ParseNodeConnection(output_value), output_mul->name());
90}
91
92TEST(FusionUtilsTest, FuseFunctionWithPredicate) {
93 GraphDef graph;

Callers

nothing calls this directly

Calls 15

XTimesTwoFunction · 0.85
FuseFunctionsFunction · 0.85
CheckUniqueNamesFunction · 0.85
FindFunctionNodeWithOpFunction · 0.85
signatureMethod · 0.80
ParseNodeConnectionFunction · 0.70
nameMethod · 0.65
IsZeroFunction · 0.50
add_functionMethod · 0.45
DebugStringMethod · 0.45
node_defMethod · 0.45

Tested by

no test coverage detected