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

Function make_recv_callback

tensorflow/compiler/jit/kernels/async_io_ops.cc:30–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28
29namespace {
30AsyncIoRendezvous::DoneCallback make_recv_callback(
31 OpKernelContext* ctx, AsyncOpKernel::DoneCallback done) {
32 using namespace std::placeholders;
33 return std::bind(
34 [ctx](AsyncOpKernel::DoneCallback done,
35 // Begin unbound arguments.
36 const Status& s, const AsyncIoRendezvous::TensorPayload& val) {
37 Tensor tensor;
38 if (val.addr.is_null()) {
39 VLOG(2) << "AsyncIoRendezvous::DoneCallback with Tensor size "
40 << val.tensor.TotalBytes();
41 tensor = val.tensor;
42 } else {
43 VLOG(2) << "AsyncIoRendezvous::DoneCallback with payload size "
44 << val.addr.size() << " @" << val.addr.opaque();
45 TensorShape tensor_shape;
46 XLAShapeToTensorShape(val.shape, &tensor_shape);
47 auto data_type =
48 EncodePrimitiveTypeAsDataType(val.shape.element_type())
49 .ValueOrDie();
50 tensor =
51 XlaTensorBuffer::MakeTensor(data_type, tensor_shape, val.addr,
52 ctx->device()->GetAllocator({}));
53 }
54
55 ctx->SetStatus(s);
56 if (s.ok()) {
57 // 'ctx' allocates the output tensor of the expected type.
58 // The runtime checks whether the tensor received here is
59 // the same type.
60 ctx->set_output(0, tensor);
61 }
62 done();
63 },
64 std::move(done), _1, _2);
65}
66} // anonymous
67
68XlaAsyncOutSendOp::XlaAsyncOutSendOp(OpKernelConstruction* ctx)

Callers 1

ComputeAsyncMethod · 0.70

Calls 13

XLAShapeToTensorShapeFunction · 0.85
opaqueMethod · 0.80
MakeTensorFunction · 0.50
is_nullMethod · 0.45
TotalBytesMethod · 0.45
sizeMethod · 0.45
element_typeMethod · 0.45
GetAllocatorMethod · 0.45
deviceMethod · 0.45
SetStatusMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected