| 412 | } // namespace |
| 413 | |
| 414 | Status RewriteWhileNode(Node* n, Graph* g, |
| 415 | bool keep_node_fetchable) { |
| 416 | VLOG(2) << "Lower While node (keep_node_fetchable=" << keep_node_fetchable |
| 417 | << "): " << SummarizeNode(*n); |
| 418 | |
| 419 | const AttrValue* cond_attr = n->attrs().Find("cond"); |
| 420 | if (cond_attr == nullptr) { |
| 421 | return errors::InvalidArgument("While cond function missing"); |
| 422 | } |
| 423 | const AttrValue* body_attr = n->attrs().Find("body"); |
| 424 | if (body_attr == nullptr) { |
| 425 | return errors::InvalidArgument("While body function missing"); |
| 426 | } |
| 427 | const AttrValue* parallel_iterations_attr = |
| 428 | n->attrs().Find("parallel_iterations"); |
| 429 | if (parallel_iterations_attr == nullptr) { |
| 430 | return errors::InvalidArgument("parallel_iterations attr missing"); |
| 431 | } |
| 432 | |
| 433 | TF_RETURN_IF_ERROR(LowerWhileHelper::Run( |
| 434 | n, cond_attr->func(), body_attr->func(), parallel_iterations_attr->i(), g, |
| 435 | keep_node_fetchable)); |
| 436 | g->RemoveNode(n); |
| 437 | |
| 438 | return Status::OK(); |
| 439 | } |
| 440 | |
| 441 | } // namespace tensorflow |
no test coverage detected