tensorflow/core/grappler/optimizers/data/noop_elimination_test.cc
// This test checks whether the no-op elimination correctly removes
// multiple noop nodes.
This test checks whether the no-op elimination correctly removes
multiple noop nodes.
This test checks whether the no - op elimination correctly removes multiple noop nodes .
TEST_P(NoOpMultipleEliminationTest, EliminateMultipleNoOpNode) {
  GrapplerItem item;
  MutableGraphView graph(&item.graph);
  static_assert(std::tuple_size<NodesTypes>::value == 2,
                "Make sure to include everything in the test");
  const std::vector<std::pair<string, std::vector<int>>> noop_nodes = {
      std::get<0>(GetParam()), std::get<1>(GetParam())};
  NodeDef *range_node = MakeRangeNode(&graph);
  NodeDef *previous = range_node;
  std::vector<string> nodes_to_remove;
  nodes_to_remove.reserve(noop_nodes.size());
  for (const auto &noop_node : noop_nodes) {
    NodeDef *node =
        MakeNode(noop_node.first, noop_node.second, previous->name(), &graph);
    nodes_to_remove.push_back(node->name());
    previous = node;
  }
  NodeDef *cache_node = MakeCacheNode(previous->name(), &graph);
  NoOpElimination optimizer;
  GraphDef output;
  TF_ASSERT_OK(optimizer.Optimize(nullptr, item, &output));
  for (const auto &noop_node_name : nodes_to_remove)
    EXPECT_FALSE(
        graph_utils::ContainsGraphNodeWithName(noop_node_name, output));
  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);
  EXPECT_EQ(cache_node_out.input(0), range_node->name());
}
TEST_P ( NoOpMultipleEliminationTest , EliminateMultipleNoOpNode ) { GrapplerItem item ; MutableGraphView graph ( & item . graph ) ; static_assert ( std :: tuple_size < NodesTypes > :: value == 2 , " " ) ; const std :: vector < std :: pair < string , std :: vector < int > > > noop_nodes = { std :: get < 0 > ( GetParam ( ) ) , std :: get < 1 > ( GetParam ( ) ) } ; NodeDef * range_node = MakeRangeNode ( & graph ) ; NodeDef * previous = range_node ; std :: vector < string > nodes_to_remove ; nodes_to_remove . reserve ( noop_nodes . size ( ) ) ; for ( const auto & noop_node : noop_nodes ) { NodeDef * node = MakeNode ( noop_node . first , noop_node . second , previous -> name ( ) , & graph ) ; nodes_to_remove . push_back ( node -> name ( ) ) ; previous = node ; } NodeDef * cache_node = MakeCacheNode ( previous -> name ( ) , & graph ) ; NoOpElimination optimizer ; GraphDef output ; TF_ASSERT_OK ( optimizer . Optimize ( nullptr , item , & output ) ) ; for ( const auto & noop_node_name : nodes_to_remove ) EXPECT_FALSE ( graph_utils :: ContainsGraphNodeWithName ( noop_node_name , output ) ) ; 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 ) ; EXPECT_EQ ( cache_node_out . input ( 0 ) , range_node -> name ( ) ) ; }
This test checks whether the no-op elimination correctly removes
multiple noop nodes.
This test checks whether the no - op elimination correctly removes multiple noop nodes .