| 25 | namespace { |
| 26 | |
| 27 | TEST(LiteralUtil, LiteralToHostTensor) { |
| 28 | // int64 literal can only be converted to an int64 host tensor. |
| 29 | std::vector<int64> int64_values = {1, 2, 3}; |
| 30 | xla::Literal int64_values_literal = |
| 31 | xla::LiteralUtil::CreateR1(absl::Span<const int64>(int64_values)); |
| 32 | Tensor host_tensor; |
| 33 | EXPECT_EQ("Cannot convert literal of type S64 to tensor of type int32", |
| 34 | LiteralToHostTensor(int64_values_literal, DT_INT32, &host_tensor) |
| 35 | .error_message()); |
| 36 | EXPECT_EQ("Cannot convert literal of type S64 to tensor of type qint32", |
| 37 | LiteralToHostTensor(int64_values_literal, DT_QINT32, &host_tensor) |
| 38 | .error_message()); |
| 39 | EXPECT_TRUE( |
| 40 | LiteralToHostTensor(int64_values_literal, DT_INT64, &host_tensor).ok()); |
| 41 | test::ExpectTensorEqual<int64>(host_tensor, |
| 42 | test::AsTensor<int64>(int64_values)); |
| 43 | } |
| 44 | |
| 45 | template <class T> |
| 46 | using LiteralUtilTest = ::testing::Test; |
nothing calls this directly
no test coverage detected