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

Method SendFileSlice

tensorflow/core/kernels/file_slice_sendrecv_ops.cc:179–221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177}
178
179Status FileSliceSendOp::SendFileSlice(OpKernelContext* ctx,
180 const FrameAndIter& frame_iter,
181 const Tensor& file_path_t,
182 const uint64 element_bytes) {
183 Rendezvous::Args args;
184 args.device_context = ctx->op_device_context();
185 args.alloc_attrs = AllocatorAttributes();
186 Rendezvous::ParsedKey parsed_key;
187
188 std::unique_ptr<RandomAccessFile> file;
189 Env* env = Env::Default();
190 const string& file_path = file_path_t.scalar<tstring>()();
191 TF_RETURN_IF_ERROR(env->NewRandomAccessFile(file_path, &file));
192
193 // Slice Send.
194 int64 slice_num = element_bytes / slice_size_;
195 if (element_bytes % slice_size_ != 0) {
196 slice_num += 1;
197 }
198 Tensor data_t;
199 for (int64 i = 0; i < slice_num; i++) {
200 TF_RETURN_IF_ERROR(ctx->allocate_temp(DT_STRING, TensorShape({}), &data_t));
201 uint64 start = i * slice_size_;
202 uint64 copy_size = slice_size_;
203 if (start > element_bytes - slice_size_) {
204 copy_size = element_bytes - start;
205 }
206 TF_RETURN_IF_ERROR(ReadFileSlice(file, start, copy_size, data_t));
207 std::string tensor_name_suffix = \
208 strings::StrCat("_slice_transfer_data_", std::to_string(0), "_",
209 std::to_string(i));
210 slice_sendrecv::GetSliceRendezvousKey(key_prefix_, tensor_name_suffix,
211 frame_iter, &parsed_key.buf_);
212 VLOG(2) << "FileSliceSend " << parsed_key.buf_;
213 TF_RETURN_IF_ERROR(Rendezvous::ParseKey(parsed_key.buf_, &parsed_key));
214 TF_RETURN_IF_ERROR(
215 ctx->rendezvous()->FlowControlSend(tensor_name_, parsed_key, args, data_t,
216 ctx->is_input_dead()));
217 }
218
219
220 return Status::OK();
221}
222
223Status FileSliceSendOp::ReadFileSlice(
224 const std::unique_ptr<RandomAccessFile>& file,

Callers

nothing calls this directly

Calls 12

AllocatorAttributesClass · 0.85
DefaultFunction · 0.85
to_stringFunction · 0.85
GetSliceRendezvousKeyFunction · 0.85
rendezvousMethod · 0.80
is_input_deadMethod · 0.80
TensorShapeClass · 0.50
StrCatFunction · 0.50
op_device_contextMethod · 0.45
NewRandomAccessFileMethod · 0.45
allocate_tempMethod · 0.45
FlowControlSendMethod · 0.45

Tested by

no test coverage detected