| 618 | } |
| 619 | |
| 620 | bool SubstitutePlaceholders(const SubstituteFunc& substitute, |
| 621 | AttrValue* value) { |
| 622 | switch (value->value_case()) { |
| 623 | case AttrValue::kList: { |
| 624 | for (NameAttrList& func : *value->mutable_list()->mutable_func()) { |
| 625 | for (auto& p : *func.mutable_attr()) { |
| 626 | if (!SubstitutePlaceholders(substitute, &p.second)) { |
| 627 | return false; |
| 628 | } |
| 629 | } |
| 630 | } |
| 631 | break; |
| 632 | } |
| 633 | case AttrValue::kFunc: |
| 634 | for (auto& p : *(value->mutable_func()->mutable_attr())) { |
| 635 | if (!SubstitutePlaceholders(substitute, &p.second)) { |
| 636 | return false; |
| 637 | } |
| 638 | } |
| 639 | break; |
| 640 | case AttrValue::kPlaceholder: |
| 641 | return substitute(value->placeholder(), value); |
| 642 | case AttrValue::VALUE_NOT_SET: |
| 643 | return false; |
| 644 | default: |
| 645 | break; |
| 646 | } |
| 647 | return true; |
| 648 | } |
| 649 | |
| 650 | } // namespace tensorflow |