| 28 | |
| 29 | namespace { |
| 30 | AsyncIoRendezvous::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 | |
| 68 | XlaAsyncOutSendOp::XlaAsyncOutSendOp(OpKernelConstruction* ctx) |
no test coverage detected