tensorflow/compiler/xla/tests/tuple_test.cc
// Extracts both elements from a tuple and then puts them into a new tuple in
// the opposite order.
Extracts both elements from a tuple and then puts them into a new tuple in
the opposite order.
Extracts both elements from a tuple and then puts them into a new tuple in the opposite order .
XLA_TEST_F(TupleTest, TupleGTEToTuple) {
  XlaBuilder builder(TestName());
  std::initializer_list<float> constant_vector = {1.f, 2.f, 3.f};
  std::initializer_list<std::initializer_list<float>> constant_matrix = {
      {1.f, 2.f, 3.f},  
      {4.f, 5.f, 6.f},  
  };
  auto tuple_data =
      Tuple(&builder, {ConstantR1<float>(&builder, constant_vector),
                       ConstantR2<float>(&builder, constant_matrix)});
  Tuple(&builder,
        {GetTupleElement(tuple_data, 1), GetTupleElement(tuple_data, 0)});
  auto expected = LiteralUtil::MakeTupleFromSlices(
      {LiteralUtil::CreateR2<float>(constant_matrix),
       LiteralUtil::CreateR1<float>(constant_vector)});
  ComputeAndCompareTuple(&builder, expected, {}, error_spec_);
}
XLA_TEST_F ( TupleTest , TupleGTEToTuple ) { XlaBuilder builder ( TestName ( ) ) ; std :: initializer_list < float > constant_vector = { 1.f , 2.f , 3.f } ; std :: initializer_list < std :: initializer_list < float > > constant_matrix = { { 1.f , 2.f , 3.f } , { 4.f , 5.f , 6.f } , } ; auto tuple_data = Tuple ( & builder , { ConstantR1 < float > ( & builder , constant_vector ) , ConstantR2 < float > ( & builder , constant_matrix ) } ) ; Tuple ( & builder , { GetTupleElement ( tuple_data , 1 ) , GetTupleElement ( tuple_data , 0 ) } ) ; auto expected = LiteralUtil :: MakeTupleFromSlices ( { LiteralUtil :: CreateR2 < float > ( constant_matrix ) , LiteralUtil :: CreateR1 < float > ( constant_vector ) } ) ; ComputeAndCompareTuple ( & builder , expected , { } , error_spec_ ) ; }
Extracts both elements from a tuple and then puts them into a new tuple in
the opposite order.
Extracts both elements from a tuple and then puts them into a new tuple in the opposite order .
// row 0 // row 1