| 154 | }; |
| 155 | |
| 156 | LowerWhileHelper::LowerWhileHelper(Node* while_op, const NameAttrList& cond_fn, |
| 157 | const NameAttrList& body_fn, |
| 158 | int parallel_iterations, Graph* graph, |
| 159 | bool keep_node_fetchable) |
| 160 | : while_op_(while_op), |
| 161 | graph_(graph), |
| 162 | name_(while_op->name()), |
| 163 | parallel_iterations_(parallel_iterations), |
| 164 | keep_node_fetchable_(keep_node_fetchable), |
| 165 | debug_info_(*while_op_), |
| 166 | cond_call_builder_(NewName("cond"), cond_fn.name(), graph->op_registry(), |
| 167 | &debug_info_), |
| 168 | body_call_builder_(NewName("body"), body_fn.name(), graph->op_registry(), |
| 169 | &debug_info_), |
| 170 | num_loop_inputs_(while_op_->num_inputs()) { |
| 171 | cond_call_builder_.Attr(kLowerAsMultiDeviceFunctionAttr, true); |
| 172 | for (const auto& i : cond_fn.attr()) { |
| 173 | cond_call_builder_.Attr(i.first, i.second); |
| 174 | } |
| 175 | body_call_builder_.Attr(kLowerAsMultiDeviceFunctionAttr, true); |
| 176 | for (const auto& i : body_fn.attr()) { |
| 177 | body_call_builder_.Attr(i.first, i.second); |
| 178 | } |
| 179 | // We intentionally `resize` instead of `reserve` space in `enter_nodes_` |
| 180 | // because we need to set it's elements out of order in `CreateEnterNodes`. |
| 181 | enter_nodes_.resize(num_loop_inputs_); |
| 182 | merge_nodes_.reserve(num_loop_inputs_); |
| 183 | switch_nodes_.reserve(num_loop_inputs_); |
| 184 | exit_nodes_.reserve(num_loop_inputs_); |
| 185 | next_iterations_nodes_.reserve(num_loop_inputs_); |
| 186 | } |
| 187 | |
| 188 | Status LowerWhileHelper::RunInternal() { |
| 189 | TF_RETURN_IF_ERROR(CreateEnterNodes()); |
nothing calls this directly
no test coverage detected