MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / TEST

Function TEST

tensorflow/compiler/tf2xla/literal_util_test.cc:27–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25namespace {
26
27TEST(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
45template <class T>
46using LiteralUtilTest = ::testing::Test;

Callers

nothing calls this directly

Calls 2

LiteralToHostTensorFunction · 0.85
okMethod · 0.45

Tested by

no test coverage detected