tensorflow/compiler/tf2xla/const_analysis_test.cc
// Regression test for a case where the backward const analysis did
// not visit nodes in topological order.
Regression test for a case where the backward const analysis did
not visit nodes in topological order.
Regression test for a case where the backward const analysis did not visit nodes in topological order .
TEST(ConstAnalysisTest, TopologicalOrder) {
  for (bool order : {false, true}) {
    Scope root = Scope::NewRootScope();
    auto arg0 = ops::_Arg(root.WithOpName("Arg0"), DT_INT32, 0);
    auto arg1 = ops::_Arg(root.WithOpName("Arg1"), DT_INT32, 1);
    auto arg2 = ops::_Arg(root.WithOpName("Arg2"), DT_INT32, 2);
    auto a = ops::Reshape(root, arg0, arg1);
    auto b = ops::Reshape(root, arg2, a);
    if (order) {
      std::swap(a, b);
    }
    auto c = ops::Add(root, a, b);
    Graph graph(OpRegistry::Global());
    TF_ASSERT_OK(root.ToGraph(&graph));
    std::vector<bool> const_args(3, false);
    TF_ASSERT_OK(BackwardsConstAnalysis(graph, &const_args,
                                        nullptr,
                                        nullptr));
    EXPECT_EQ(const_args, std::vector<bool>({true, true, false}));
  }
}
TEST ( ConstAnalysisTest , TopologicalOrder ) { for ( bool order : { false , true } ) { Scope root = Scope :: NewRootScope ( ) ; auto arg0 = ops :: _Arg ( root . WithOpName ( " " ) , DT_INT32 , 0 ) ; auto arg1 = ops :: _Arg ( root . WithOpName ( " " ) , DT_INT32 , 1 ) ; auto arg2 = ops :: _Arg ( root . WithOpName ( " " ) , DT_INT32 , 2 ) ; auto a = ops :: Reshape ( root , arg0 , arg1 ) ; auto b = ops :: Reshape ( root , arg2 , a ) ; if ( order ) { std :: swap ( a , b ) ; } auto c = ops :: Add ( root , a , b ) ; Graph graph ( OpRegistry :: Global ( ) ) ; TF_ASSERT_OK ( root . ToGraph ( & graph ) ) ; std :: vector < bool > const_args ( 3 , false ) ; TF_ASSERT_OK ( BackwardsConstAnalysis ( graph , & const_args , nullptr , nullptr ) ) ; EXPECT_EQ ( const_args , std :: vector < bool > ( { true , true , false } ) ) ; } }
Regression test for a case where the backward const analysis did
not visit nodes in topological order.
Regression test for a case where the backward const analysis did not visit nodes in topological order .
// Consider both orders for arguments to the Sum so we aren't sensitive // to the DFS traversal order. /*compile_time_const_nodes=*/ /*flib_runtime=*/