tensorflow/core/grappler/optimizers/data/noop_elimination_test.cc
// This test checks whether the no-op elimination correctly handles
// transformations int the middle of the pipeline.
This test checks whether the no-op elimination correctly handles
transformations int the middle of the pipeline.
This test checks whether the no - op elimination correctly handles transformations int the middle of the pipeline .
TEST_P(NoOpMiddleEliminationTest, EliminateMiddleNoOpNode) {
  GrapplerItem item;
  MutableGraphView graph(&item.graph);
  const string &node_type = std::get<0>(GetParam());
  const std::vector<int> node_params = std::get<1>(GetParam());
  const bool should_keep_node = std::get<2>(GetParam());
  NodeDef *range_node = MakeRangeNode(&graph);
  NodeDef *node = MakeNode(node_type, node_params, range_node->name(), &graph);
  NodeDef *cache_node = MakeCacheNode(node->name(), &graph);
  NoOpElimination optimizer;
  GraphDef output;
  TF_ASSERT_OK(optimizer.Optimize(nullptr, item, &output));
  EXPECT_EQ(graph_utils::ContainsGraphNodeWithName(node->name(), output),
            should_keep_node);
  EXPECT_TRUE(
      graph_utils::ContainsGraphNodeWithName(cache_node->name(), output));
  NodeDef cache_node_out = output.node(
      graph_utils::FindGraphNodeWithName(cache_node->name(), output));
  EXPECT_EQ(cache_node_out.input_size(), 2);
  auto last_node_input = (should_keep_node ? node : range_node)->name();
  EXPECT_EQ(cache_node_out.input(0), last_node_input);
}
TEST_P ( NoOpMiddleEliminationTest , EliminateMiddleNoOpNode ) { GrapplerItem item ; MutableGraphView graph ( & item . graph ) ; const string & node_type = std :: get < 0 > ( GetParam ( ) ) ; const std :: vector < int > node_params = std :: get < 1 > ( GetParam ( ) ) ; const bool should_keep_node = std :: get < 2 > ( GetParam ( ) ) ; NodeDef * range_node = MakeRangeNode ( & graph ) ; NodeDef * node = MakeNode ( node_type , node_params , range_node -> name ( ) , & graph ) ; NodeDef * cache_node = MakeCacheNode ( node -> name ( ) , & graph ) ; NoOpElimination optimizer ; GraphDef output ; TF_ASSERT_OK ( optimizer . Optimize ( nullptr , item , & output ) ) ; EXPECT_EQ ( graph_utils :: ContainsGraphNodeWithName ( node -> name ( ) , output ) , should_keep_node ) ; EXPECT_TRUE ( graph_utils :: ContainsGraphNodeWithName ( cache_node -> name ( ) , output ) ) ; NodeDef cache_node_out = output . node ( graph_utils :: FindGraphNodeWithName ( cache_node -> name ( ) , output ) ) ; EXPECT_EQ ( cache_node_out . input_size ( ) , 2 ) ; auto last_node_input = ( should_keep_node ? node : range_node ) -> name ( ) ; EXPECT_EQ ( cache_node_out . input ( 0 ) , last_node_input ) ; }
This test checks whether the no-op elimination correctly handles
transformations int the middle of the pipeline.
This test checks whether the no - op elimination correctly handles transformations int the middle of the pipeline .