Tests a tuple-shaped constant.
| 43 | |
| 44 | // Tests a tuple-shaped constant. |
| 45 | XLA_TEST_F(TupleTest, TupleConstant) { |
| 46 | XlaBuilder builder(TestName()); |
| 47 | |
| 48 | const float constant_scalar = 7.3f; |
| 49 | std::initializer_list<float> constant_vector = {1.1f, 2.0f, 3.3f}; |
| 50 | std::initializer_list<std::initializer_list<float>> constant_matrix = { |
| 51 | {1.1f, 2.2f, 3.5f}, // row 0 |
| 52 | {4.8f, 5.0f, 6.7f}, // row 1 |
| 53 | }; |
| 54 | auto value = LiteralUtil::MakeTupleFromSlices( |
| 55 | {LiteralUtil::CreateR0<float>(constant_scalar), |
| 56 | LiteralUtil::CreateR1<float>(constant_vector), |
| 57 | LiteralUtil::CreateR2<float>(constant_matrix)}); |
| 58 | |
| 59 | ConstantLiteral(&builder, value); |
| 60 | ComputeAndCompareTuple(&builder, value, {}, error_spec_); |
| 61 | } |
| 62 | |
| 63 | // Tests a tuple made of scalar constants. |
| 64 | XLA_TEST_F(TupleTest, TupleScalarConstant) { |
nothing calls this directly
no test coverage detected