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

Method MakeTensorFromProto

tensorflow/compiler/jit/xla_device.cc:488–518  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

486}
487
488Status XlaDevice::MakeTensorFromProto(XlaDeviceContext* device_context,
489 const TensorProto& tensor_proto,
490 const AllocatorAttributes alloc_attrs,
491 Tensor* tensor) {
492 Tensor parsed(tensor_proto.dtype());
493 if (!parsed.FromProto(cpu_allocator(), tensor_proto)) {
494 return errors::InvalidArgument("Cannot parse tensor from proto: ",
495 tensor_proto.DebugString());
496 }
497
498 Status status;
499 if (alloc_attrs.on_host()) {
500 *tensor = parsed;
501 } else {
502 mutex_lock lock(mu_);
503 Allocator* allocator = GetAllocatorLocked(alloc_attrs);
504 Tensor copy(allocator, parsed.dtype(), parsed.shape());
505 Notification n;
506 device_context->CopyCPUTensorToDevice(
507 &parsed, this, &copy,
508 [&n, &status](const Status& s) {
509 status = s;
510 n.Notify();
511 },
512 true /*sync_dst_compute*/);
513 n.WaitForNotification();
514 *tensor = copy;
515 }
516 VLOG(2) << "Allocated tensor at " << DMAHelper::base(tensor);
517 return status;
518}
519
520Status XlaDevice::MakeTensorFromProto(const TensorProto& tensor_proto,
521 const AllocatorAttributes alloc_attrs,

Callers 4

RecvFromRemoteAsyncMethod · 0.45
InitStarClientTagFunction · 0.45
InitStarServerTagFunction · 0.45
RecvTensorContentMethod · 0.45

Calls 13

cpu_allocatorFunction · 0.85
InvalidArgumentFunction · 0.85
baseClass · 0.85
MakeTensorFromProtoFunction · 0.85
TF_ASSIGN_OR_RETURNFunction · 0.50
dtypeMethod · 0.45
FromProtoMethod · 0.45
DebugStringMethod · 0.45
on_hostMethod · 0.45
shapeMethod · 0.45
CopyCPUTensorToDeviceMethod · 0.45
NotifyMethod · 0.45

Tested by

no test coverage detected