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

Method ComputeAsync

tensorflow/core/kernels/function_ops.cc:242–287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

240 ~SymbolicGradientOp() override {}
241
242 void ComputeAsync(OpKernelContext* ctx, DoneCallback done) override {
243 FunctionLibraryRuntime* lib = ctx->function_library();
244 OP_REQUIRES_ASYNC(ctx, lib != nullptr,
245 errors::Internal("No function library is provided."),
246 done);
247
248 FunctionLibraryRuntime::Handle handle;
249 OP_REQUIRES_OK_ASYNC(
250 ctx, lib->Instantiate(kGradientOp, AttrSlice(def()), &handle), done);
251
252 FunctionLibraryRuntime::Options opts;
253 opts.rendezvous = ctx->rendezvous();
254 opts.cancellation_manager = ctx->cancellation_manager();
255 opts.runner = ctx->runner();
256 opts.stats_collector = ctx->stats_collector();
257 opts.step_container = ctx->step_container();
258 opts.collective_executor = ctx->collective_executor();
259 std::vector<Tensor> args;
260 args.reserve(ctx->num_inputs());
261 for (int i = 0; i < ctx->num_inputs(); ++i) {
262 args.push_back(ctx->input(i));
263 }
264 std::vector<Tensor>* rets = new std::vector<Tensor>;
265 profiler::TraceMe trace_me(
266 [&] {
267 return absl::StrCat(
268 "SymbolicGradientOp #parent_step_id=", ctx->step_id(),
269 ",function_step_id=", opts.step_id, "#");
270 },
271 /*level=*/2);
272 lib->Run(opts, handle, args, rets, [ctx, done, rets](const Status& status) {
273 if (!status.ok()) {
274 ctx->SetStatus(status);
275 } else if (rets->size() != ctx->num_outputs()) {
276 ctx->SetStatus(errors::InvalidArgument(
277 "SymGrad expects to return ", ctx->num_outputs(),
278 " tensor(s), but get ", rets->size(), " tensor(s) instead."));
279 } else {
280 for (size_t i = 0; i < rets->size(); ++i) {
281 ctx->set_output(i, (*rets)[i]);
282 }
283 }
284 delete rets;
285 done();
286 });
287 }
288
289 private:
290 TF_DISALLOW_COPY_AND_ASSIGN(SymbolicGradientOp);

Callers

nothing calls this directly

Calls 15

InternalFunction · 0.85
AttrSliceClass · 0.85
InvalidArgumentFunction · 0.85
rendezvousMethod · 0.80
stats_collectorMethod · 0.80
step_containerMethod · 0.80
collective_executorMethod · 0.80
StrCatFunction · 0.50
function_libraryMethod · 0.45
InstantiateMethod · 0.45
cancellation_managerMethod · 0.45
runnerMethod · 0.45

Tested by

no test coverage detected