| 269 | } // namespace |
| 270 | |
| 271 | Status RewriteIfNode(Node* n, Graph* g, bool keep_node_fetchable) { |
| 272 | VLOG(2) << "Lower If node (keep_node_fetchable=" << keep_node_fetchable |
| 273 | << "): " << SummarizeNode(*n); |
| 274 | |
| 275 | const AttrValue* then_attr = n->attrs().Find("then_branch"); |
| 276 | if (then_attr == nullptr) { |
| 277 | return errors::InvalidArgument("Then branch function missing"); |
| 278 | } |
| 279 | const AttrValue* else_attr = n->attrs().Find("else_branch"); |
| 280 | if (else_attr == nullptr) { |
| 281 | return errors::InvalidArgument("Else branch function missing"); |
| 282 | } |
| 283 | |
| 284 | CondBuilder cb(n, then_attr->func(), else_attr->func(), keep_node_fetchable, |
| 285 | g); |
| 286 | TF_RETURN_IF_ERROR(cb.CreatePivotNodes()); |
| 287 | TF_RETURN_IF_ERROR(cb.AddInputs()); |
| 288 | TF_RETURN_IF_ERROR(cb.AddOutputs()); |
| 289 | g->RemoveNode(n); |
| 290 | |
| 291 | return Status::OK(); |
| 292 | } |
| 293 | |
| 294 | } // namespace tensorflow |
no test coverage detected