| 269 | } // namespace |
| 270 | |
| 271 | Status RewriteCaseNode(Node* n, Graph* g, bool keep_node_fetchable) { |
| 272 | VLOG(2) << "Lower Case node (keep_node_fetchable=" << keep_node_fetchable |
| 273 | << "): " << SummarizeNode(*n); |
| 274 | const AttrValue* branches_attr = n->attrs().Find("branches"); |
| 275 | if (branches_attr == nullptr) { |
| 276 | return errors::InvalidArgument("branch functions missing"); |
| 277 | } |
| 278 | |
| 279 | int num_branches = branches_attr->list().func_size(); |
| 280 | std::vector<string> branch_fn_names; |
| 281 | branch_fn_names.reserve(num_branches); |
| 282 | for (int b = 0; b < num_branches; b++) { |
| 283 | branch_fn_names.emplace_back(branches_attr->list().func(b).name()); |
| 284 | } |
| 285 | CaseBuilder cb(n, branch_fn_names, keep_node_fetchable, 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