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

Method Compute

tensorflow/core/kernels/slice_sendrecv_ops.cc:45–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43}
44
45void SliceSendOp::Compute(OpKernelContext* ctx) {
46 OP_REQUIRES(
47 ctx, ctx->rendezvous() != nullptr,
48 errors::Internal("Op kernel context needs to provide a rendezvous."));
49
50 const Tensor& input_t = ctx->input(0);
51 FrameAndIter frame_iter = \
52 slice_sendrecv::GetFrameAndIter(ctx, hostmem_sendrecv_);
53
54 // send total_bytes.
55 OP_REQUIRES_OK(ctx, SendTotalBytes(ctx, frame_iter, input_t));
56 // if input is dead, only send total_bytes dead tensor.
57 if (ctx->is_input_dead()) {
58 return;
59 }
60
61 // if total bytes is smaller than slice size, send directly.
62 if (input_t.TotalBytes() <= slice_size_) {
63 Rendezvous::Args args;
64 args.device_context = ctx->op_device_context();
65 args.alloc_attrs = ctx->input_alloc_attr(0);
66
67 Rendezvous::ParsedKey parsed_key;
68 slice_sendrecv::GetSliceRendezvousKey(key_prefix_, "_transfer_data",
69 frame_iter, &parsed_key.buf_);
70 VLOG(2) << "SliceSend " << parsed_key.buf_;
71 OP_REQUIRES_OK(ctx, Rendezvous::ParseKey(parsed_key.buf_, &parsed_key));
72 OP_REQUIRES_OK(ctx, ctx->rendezvous()->Send(parsed_key, args, input_t,
73 ctx->is_input_dead()));
74 return;
75 }
76
77 // send shape.
78 OP_REQUIRES_OK(ctx, SendShape(ctx, frame_iter, input_t));
79
80 // send data.
81 if (dtype_ == DT_STRING) {
82 OP_REQUIRES_OK(ctx, SendString(ctx, frame_iter, input_t));
83 } else {
84 OP_REQUIRES_OK(ctx, SendBasicType(ctx, frame_iter, input_t));
85 }
86}
87
88Status SliceSendOp::SendTotalBytes(OpKernelContext* ctx,
89 const FrameAndIter& frame_iter,

Callers

nothing calls this directly

Calls 15

InternalFunction · 0.85
GetSliceRendezvousKeyFunction · 0.85
rendezvousMethod · 0.80
is_input_deadMethod · 0.80
input_alloc_attrMethod · 0.80
output_alloc_attrMethod · 0.80
is_eagerMethod · 0.80
allocate_outputMethod · 0.80
GetFrameAndIterFunction · 0.70
inputMethod · 0.45
TotalBytesMethod · 0.45
op_device_contextMethod · 0.45

Tested by

no test coverage detected