tensorflow/core/grappler/optimizers/data/split_utils_test.cc
// Tests case where two nodes in the second function have the same input tensor,
// where the input tensor is from the first function.
Tests case where two nodes in the second function have the same input tensor,
where the input tensor is from the first function.
Tests case where two nodes in the second function have the same input tensor where the input tensor is from the first function .
TEST(SplitUtilsTest, MultipleNodesHaveSameInput) {
  using test::function::NDef;
  FunctionLibraryDefinition function_library(OpRegistry::Global());
  FunctionDef orig = FunctionDefHelper::Create(
      "MyFunction",                
      {"a1: float", "a2: float"},  
      {"o1: float", "o2: float"},  
      {},                          
      {
          {{"i1"}, "Identity", {"a1"}, {{"T", DT_FLOAT}}},
          {{"add"}, "AddV2", {"i1:output", "a2"}, {{"T", DT_FLOAT}}},
          {{"mul"}, "Mul", {"i1:output", "a2"}, {{"T", DT_FLOAT}}},
      },
      {{"o1", "add:z"}, {"o2", "mul:z"}});
  SplitResults results =
      SplitFunction(orig, {"i1"}, 0, function_library)
          .ValueOrDie();
  FunctionDef first = results.first_function;
  FunctionDef second = results.second_function;
  ASSERT_THAT(GetNodeNames(first), UnorderedElementsAre("i1"));
  ASSERT_THAT(GetNodeNames(second), UnorderedElementsAre("add", "mul"));
  const NodeDef& add_node = GetNode("add", second);
  const NodeDef& mul_node = GetNode("mul", second);
  ASSERT_THAT(add_node.input(), ElementsAreArray(mul_node.input()));
  CheckSplitFunctions(orig, first, second,
                      {test::AsScalar<float>(1.0), test::AsScalar<float>(2.0)});
}
TEST ( SplitUtilsTest , MultipleNodesHaveSameInput ) { using test :: function :: NDef ; FunctionLibraryDefinition function_library ( OpRegistry :: Global ( ) ) ; FunctionDef orig = FunctionDefHelper :: Create ( " " , { " " , " " } , { " " , " " } , { } , { { { " " } , " " , { " " } , { { " " , DT_FLOAT } } } , { { " " } , " " , { " " , " " } , { { " " , DT_FLOAT } } } , { { " " } , " " , { " " , " " } , { { " " , DT_FLOAT } } } , } , { { " " , " " } , { " " , " " } } ) ; SplitResults results = SplitFunction ( orig , { " " } , 0 , function_library ) . ValueOrDie ( ) ; FunctionDef first = results . first_function ; FunctionDef second = results . second_function ; ASSERT_THAT ( GetNodeNames ( first ) , UnorderedElementsAre ( " " ) ) ; ASSERT_THAT ( GetNodeNames ( second ) , UnorderedElementsAre ( " " , " " ) ) ; const NodeDef & add_node = GetNode ( " " , second ) ; const NodeDef & mul_node = GetNode ( " " , second ) ; ASSERT_THAT ( add_node . input ( ) , ElementsAreArray ( mul_node . input ( ) ) ) ; CheckSplitFunctions ( orig , first , second , { test :: AsScalar < float > ( 1.0 ) , test :: AsScalar < float > ( 2.0 ) } ) ; }
Tests case where two nodes in the second function have the same input tensor,
where the input tensor is from the first function.
Tests case where two nodes in the second function have the same input tensor where the input tensor is from the first function .
// function_name // in_def // out_def // attr_def // node_def // ret_def /*num_captured_inputs=*/