| 75 | } |
| 76 | |
| 77 | void SendOp::Compute(OpKernelContext* ctx) { |
| 78 | OP_REQUIRES( |
| 79 | ctx, ctx->rendezvous() != nullptr, |
| 80 | errors::Internal("Op kernel context needs to provide a rendezvous.")); |
| 81 | |
| 82 | // The device context may be passed between the Send/Recv |
| 83 | // boundary, so that the device context used to produce the Tensor |
| 84 | // is used when performing the copy on the recv side (which may be |
| 85 | // a different device). |
| 86 | Rendezvous::Args args; |
| 87 | args.device_context = ctx->op_device_context(); |
| 88 | args.alloc_attrs = ctx->input_alloc_attr(0); |
| 89 | |
| 90 | FrameAndIter frame_iter = GetFrameAndIter(ctx, hostmem_sendrecv_); |
| 91 | if (frame_iter == FrameAndIter(0, 0)) { |
| 92 | // Use the cached rendezvous key. |
| 93 | VLOG(2) << "Send " << parsed_key_.buf_; |
| 94 | ctx->SetStatus(ctx->rendezvous()->Send(parsed_key_, args, ctx->input(0), |
| 95 | ctx->is_input_dead())); |
| 96 | return; |
| 97 | } else { |
| 98 | Rendezvous::ParsedKey in_loop_parsed; |
| 99 | GetRendezvousKey(key_prefix_, frame_iter, &in_loop_parsed.buf_); |
| 100 | VLOG(2) << "Send " << in_loop_parsed.buf_; |
| 101 | OP_REQUIRES_OK(ctx, |
| 102 | Rendezvous::ParseKey(in_loop_parsed.buf_, &in_loop_parsed)); |
| 103 | |
| 104 | ctx->SetStatus(ctx->rendezvous()->Send(in_loop_parsed, args, ctx->input(0), |
| 105 | ctx->is_input_dead())); |
| 106 | return; |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | REGISTER_KERNEL_BUILDER(Name("_Send").Device(DEVICE_CPU), SendOp); |
| 111 | REGISTER_KERNEL_BUILDER(Name("_Send").Device(DEVICE_DEFAULT), SendOp); |
nothing calls this directly
no test coverage detected