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

Method ComputeAsync

tensorflow/core/common_runtime/function.cc:518–557  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

516 }
517
518 void ComputeAsync(OpKernelContext* ctx, DoneCallback done) override {
519 FunctionLibraryRuntime* lib = ctx->function_library();
520 OP_REQUIRES_ASYNC(ctx, lib != nullptr,
521 errors::Internal("No function library is provided."),
522 done);
523 FunctionLibraryRuntime::Options opts;
524 opts.rendezvous = ctx->rendezvous();
525 opts.global_rendezvous = ctx->global_rendezvous();
526 opts.cancellation_manager = ctx->cancellation_manager();
527 opts.step_container = ctx->step_container();
528 opts.stats_collector = ctx->stats_collector();
529 opts.runner = ctx->runner();
530 opts.collective_executor = ctx->collective_executor();
531 std::vector<Tensor> args;
532 args.reserve(ctx->num_inputs());
533 for (int i = 0; i < ctx->num_inputs(); ++i) {
534 args.push_back(ctx->input(i));
535 }
536 std::vector<Tensor>* rets = new std::vector<Tensor>;
537 profiler::TraceMe trace_me(
538 [&] {
539 return absl::StrCat("CallOp #parent_step_id=", ctx->step_id(),
540 ",function_step_id=", opts.step_id, "#");
541 },
542 /*level=*/2);
543 lib->Run(opts, handle_, args, rets,
544 [ctx, done, rets](const Status& status) {
545 if (!status.ok()) {
546 ctx->SetStatus(status);
547 } else {
548 const int ret_size = static_cast<int>(rets->size());
549 CHECK_EQ(ret_size, ctx->num_outputs());
550 for (int i = 0; i < ret_size; ++i) {
551 ctx->set_output(i, (*rets)[i]);
552 }
553 }
554 delete rets;
555 done();
556 });
557 }
558
559 private:
560 FunctionLibraryRuntime::Handle handle_;

Callers

nothing calls this directly

Calls 15

InternalFunction · 0.85
rendezvousMethod · 0.80
global_rendezvousMethod · 0.80
step_containerMethod · 0.80
stats_collectorMethod · 0.80
collective_executorMethod · 0.80
StrCatFunction · 0.50
function_libraryMethod · 0.45
cancellation_managerMethod · 0.45
runnerMethod · 0.45
reserveMethod · 0.45
num_inputsMethod · 0.45

Tested by

no test coverage detected