| 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_; |
nothing calls this directly
no test coverage detected