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

Function TEST

tensorflow/compiler/xrt/tests/raw_api_test.cc:300–324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

298}
299
300TEST(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
326TEST(RawApiTest, AllocUninitialized) {
327 xla::Literal literal =

Callers

nothing calls this directly

Calls 15

LiteralToHostTensorFunction · 0.85
DeviceFromFlagFunction · 0.85
GetAttrLayoutFunction · 0.85
CompareLiteralProtosFunction · 0.85
GetShapeLayoutVectorFunction · 0.85
MakeShapeFunction · 0.85
StoreComputationSnapshotFunction · 0.85
AddAndScaleFunction · 0.85
AddAndTupleFunction · 0.85
TwoElementTupleFunction · 0.85
NestedTupleFunction · 0.85

Tested by

no test coverage detected