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

Method ComputeAsync

tensorflow/core/kernels/functional_ops.cc:138–158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136 ~IfOp() override {}
137
138 void ComputeAsync(OpKernelContext* ctx, DoneCallback done) override {
139 auto lib = ctx->function_library();
140 OP_REQUIRES_ASYNC(ctx, lib != nullptr,
141 errors::Internal("No function library"), done);
142
143 // TODO(b/37549631): Because this op has `SetIsStateful()` in its op
144 // registration, this kernel may be shared by multiple subgraphs, which have
145 // different associated `FunctionLibraryRuntime` objects and hence different
146 // `FHandle` namespaces. So we must call Instantiate() to make sure we get
147 // the correct function handles with respect to `lib`. Note the underlying
148 // `lib->Instantiate()` caches the created function handles, so calling
149 // `Instantiate()` repeatedly on the same `lib` and function is cheap.
150 FHandle then_handle;
151 FHandle else_handle;
152 OP_REQUIRES_OK_ASYNC(ctx, Instantiate(lib, then_func_, &then_handle), done);
153 OP_REQUIRES_OK_ASYNC(ctx, Instantiate(lib, else_func_, &else_handle), done);
154
155 bool cond;
156 OP_REQUIRES_OK(ctx, ToBool({ctx->input(0)}, &cond));
157 (new State(this, ctx, cond, then_handle, else_handle, done))->Start();
158 }
159
160 private:
161 NameAttrList then_func_;

Callers

nothing calls this directly

Calls 6

InternalFunction · 0.85
InstantiateFunction · 0.85
ToBoolFunction · 0.85
function_libraryMethod · 0.45
inputMethod · 0.45
StartMethod · 0.45

Tested by

no test coverage detected