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

Method Compute

tensorflow/core/kernels/work_queue_ops.cc:340–369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

338 }
339
340 void Compute(OpKernelContext* ctx) override {
341 const Tensor* input_;
342 OP_REQUIRES_OK(ctx, ctx->input("work", &input_));
343 const string& work = input_->scalar<string>()();
344
345 Env* const env = Env::Default();
346 std::vector<string> work_parts = str_util::Split(work, "?");
347
348 OP_REQUIRES(ctx, work_parts.size() == 2,
349 errors::InvalidArgument("Invalid table path format: ", work));
350 OP_REQUIRES_OK(ctx, env->IsDirectory(restore_works_dir_));
351
352 uint64 start_time = env->NowMicros();
353 string range = str_util::StringReplace(work_parts[1], "=", "_", true);
354 range = str_util::StringReplace(range, "&", "_", true);
355 string worker_id = strings::StrCat(job_name_, "_", task_index_);
356 string worker_dir = strings::StrCat(restore_works_dir_, "/", worker_id);
357 if (!env->IsDirectory(worker_dir).ok()) {
358 OP_REQUIRES_OK(ctx, env->CreateDir(worker_dir));
359 }
360 string slice_file = strings::StrCat(worker_dir, "/", range);
361 std::unique_ptr<WritableFile> wfile;
362 OP_REQUIRES_OK(ctx, env->NewWritableFile(slice_file, &wfile));
363 OP_REQUIRES_OK(ctx, wfile->Append(work));
364 OP_REQUIRES_OK(ctx, wfile->Close());
365 uint64 end_time = env->NowMicros();
366 float time_use = (end_time - start_time) / 1000000.0;
367 LOG(INFO) << "Job_name:" << job_name_ << ", time use:" << time_use
368 << ", task_index:" << task_index_ << ", work_range:" << range;
369 }
370
371 private:
372 string job_name_;

Callers

nothing calls this directly

Calls 14

DefaultFunction · 0.85
InvalidArgumentFunction · 0.85
SplitClass · 0.70
StringReplaceFunction · 0.50
StrCatFunction · 0.50
inputMethod · 0.45
sizeMethod · 0.45
IsDirectoryMethod · 0.45
NowMicrosMethod · 0.45
okMethod · 0.45
CreateDirMethod · 0.45
NewWritableFileMethod · 0.45

Tested by

no test coverage detected