tensorflow/compiler/xla/tests/tuple_test.cc
// Cascaded selects between tuple types.
Cascaded selects between tuple types.
Cascaded selects between tuple types .
XLA_TEST_F(TupleTest, DISABLED_ON_GPU(SelectBetweenTuplesCascaded)) {
                         vec1     vec2   vec2     vec1
                          |        |      |        |
                          |        |      |        |
                          (tuple 12)      (tuple 21)
                                 \            /
                                  \          /
                                   \        /
    true  --            --(GTE 0)--(select 1)
            \          /             |
         (pred tuple)--              |          --(GTE 0)--
            /          \             V         /           \
    false --            --(GTE 1)--(select 2)--             --(add)
                                   /           \           /
                                  /             --(GTE 1)--
                                 /
                            (tuple 21)
  XlaBuilder builder(TestName());
  std::initializer_list<float> vec1 = {1.f, 2.f, 3.f};
  std::initializer_list<float> vec2 = {2.f, 4.f, 6.f};
  auto pred_tuple = Tuple(&builder, {ConstantR0<bool>(&builder, true),
                                     ConstantR0<bool>(&builder, false)});
  auto tuple12 = Tuple(&builder, {ConstantR1<float>(&builder, vec1),
                                  ConstantR1<float>(&builder, vec2)});
  auto tuple21 = Tuple(&builder, {ConstantR1<float>(&builder, vec2),
                                  ConstantR1<float>(&builder, vec1)});
  auto select1 = Select(GetTupleElement(pred_tuple, 0), tuple12, tuple21);
  auto select2 = Select(GetTupleElement(pred_tuple, 1), tuple21, select1);
  Add(GetTupleElement(select2, 0), GetTupleElement(select2, 1));
  ComputeAndCompareR1<float>(&builder, {3.f, 6.f, 9.f}, {}, error_spec_);
}
XLA_TEST_F ( TupleTest , DISABLED_ON_GPU ( SelectBetweenTuplesCascaded ) ) { XlaBuilder builder ( TestName ( ) ) ; std :: initializer_list < float > vec1 = { 1.f , 2.f , 3.f } ; std :: initializer_list < float > vec2 = { 2.f , 4.f , 6.f } ; auto pred_tuple = Tuple ( & builder , { ConstantR0 < bool > ( & builder , true ) , ConstantR0 < bool > ( & builder , false ) } ) ; auto tuple12 = Tuple ( & builder , { ConstantR1 < float > ( & builder , vec1 ) , ConstantR1 < float > ( & builder , vec2 ) } ) ; auto tuple21 = Tuple ( & builder , { ConstantR1 < float > ( & builder , vec2 ) , ConstantR1 < float > ( & builder , vec1 ) } ) ; auto select1 = Select ( GetTupleElement ( pred_tuple , 0 ) , tuple12 , tuple21 ) ; auto select2 = Select ( GetTupleElement ( pred_tuple , 1 ) , tuple21 , select1 ) ; Add ( GetTupleElement ( select2 , 0 ) , GetTupleElement ( select2 , 1 ) ) ; ComputeAndCompareR1 < float > ( & builder , { 3.f , 6.f , 9.f } , { } , error_spec_ ) ; }
Cascaded selects between tuple types.
Cascaded selects between tuple types .
// //                       vec1     vec2   vec2     vec1 //                        |        |      |        | //                        |        |      |        | //                        (tuple 12)      (tuple 21) //                               \            / //                                \          / //                                 \        / //  true  --            --(GTE 0)--(select 1) //          \          /             | //       (pred tuple)--              |          --(GTE 0)-- //          /          \             V         /           \
  //  false --            --(GTE 1)--(select 2)--             --(add) //                                 /           \           / //                                /             --(GTE 1)-- //                               / //                          (tuple 21)