| 60 | } |
| 61 | |
| 62 | Status CondConstInputIndices( |
| 63 | absl::Span<const FunctionBody* const> branch_bodies, |
| 64 | std::vector<int>* const_input_idxs, FunctionLibraryRuntime* flib_runtime) { |
| 65 | TF_RET_CHECK(!branch_bodies.empty()); |
| 66 | TF_RET_CHECK(branch_bodies[0] != nullptr); |
| 67 | int num_inputs = branch_bodies[0]->fdef.signature().input_arg_size(); |
| 68 | // Stores indices of the "branch function" inputs that are expected to be |
| 69 | // compile time constants. |
| 70 | std::vector<bool> compile_time_const_arg_indices(num_inputs); |
| 71 | for (auto fbody : branch_bodies) { |
| 72 | TF_RET_CHECK(fbody != nullptr); |
| 73 | TF_RETURN_IF_ERROR(BackwardsConstAnalysis( |
| 74 | *(fbody->graph), &compile_time_const_arg_indices, |
| 75 | /*compile_time_const_nodes=*/nullptr, flib_runtime)); |
| 76 | } |
| 77 | for (int i = 0; i < compile_time_const_arg_indices.size(); i++) { |
| 78 | if (compile_time_const_arg_indices[i]) { |
| 79 | // The 0th input is the pred or branch index, which is not passed to the |
| 80 | // branches. So the i'th input of a branch function corresponds to the |
| 81 | // i + 1'th input of the If/Case op. |
| 82 | const_input_idxs->push_back(i + 1); |
| 83 | } |
| 84 | } |
| 85 | return Status::OK(); |
| 86 | } |
| 87 | |
| 88 | Status GetCompileTimeConstInputs(const NodeDef& node, const OpKernel* op_kernel, |
| 89 | const OpDef* op_def, |
no test coverage detected