| 298 | } |
| 299 | |
| 300 | TEST(RawApiTest, AllocFromTensor) { |
| 301 | xla::Literal literal = |
| 302 | xla::LiteralUtil::CreateR2<float>({{4.0f, 5.0f}, {6.0f, 7.0f}}); |
| 303 | Tensor tensor; |
| 304 | TF_ASSERT_OK(LiteralToHostTensor(literal, DT_FLOAT, &tensor)); |
| 305 | |
| 306 | Scope root = Scope::NewRootScope().WithDevice(DeviceFromFlag()); |
| 307 | std::vector<int> layout = |
| 308 | GetAttrLayout(literal.shape().layout().minor_to_major()); |
| 309 | ops::XRTAllocateFromTensor::Attrs alloc_attrs = |
| 310 | ops::XRTAllocateFromTensor::Layouts(layout); |
| 311 | auto handle = |
| 312 | ops::XRTAllocateFromTensor(root, {tensor}, {tensor.shape()}, alloc_attrs); |
| 313 | auto read_back = ops::XRTReadLiteralAndRelease(root, handle); |
| 314 | TF_ASSERT_OK(root.status()); |
| 315 | |
| 316 | XrtClientSession session(root); |
| 317 | std::vector<Tensor> outputs; |
| 318 | TF_EXPECT_OK(session.Run({read_back}, &outputs)); |
| 319 | EXPECT_EQ(outputs.size(), 1); |
| 320 | |
| 321 | xla::LiteralProto response; |
| 322 | EXPECT_TRUE(response.ParseFromString(outputs[0].scalar<tstring>()())); |
| 323 | EXPECT_TRUE(CompareLiteralToLiteralProto(literal, response)); |
| 324 | } |
| 325 | |
| 326 | TEST(RawApiTest, AllocUninitialized) { |
| 327 | xla::Literal literal = |
nothing calls this directly
no test coverage detected