| 908 | #undef ADD_ATTR |
| 909 | |
| 910 | Status AddPrefixAndSuffixToNode(StringPiece prefix, StringPiece suffix, |
| 911 | NodeDef* node_def, bool uniquify_frame_name) { |
| 912 | node_def->set_name(strings::StrCat(prefix, node_def->name(), suffix)); |
| 913 | |
| 914 | // Update frame name to avoid multiple LoopCond nodes in one frame. |
| 915 | if (uniquify_frame_name && |
| 916 | (node_def->op() == "Enter" || node_def->op() == "RefEnter")) { |
| 917 | string frame_name; |
| 918 | TF_RETURN_IF_ERROR(GetNodeAttr(*node_def, "frame_name", &frame_name)); |
| 919 | AttrValue& attr = (*node_def->mutable_attr())["frame_name"]; |
| 920 | frame_name = strings::StrCat(prefix, frame_name, suffix); |
| 921 | attr.set_s(frame_name); |
| 922 | } |
| 923 | |
| 924 | // Update colocation constraints. |
| 925 | constexpr char kClassAttr[] = "_class"; |
| 926 | auto class_attr = node_def->mutable_attr()->find(kClassAttr); |
| 927 | if (class_attr != node_def->mutable_attr()->end()) { |
| 928 | AttrValue new_value; |
| 929 | new_value.mutable_list()->add_s( |
| 930 | strings::StrCat(prefix, class_attr->second.s())); |
| 931 | node_def->mutable_attr()->erase(kClassAttr); |
| 932 | node_def->mutable_attr()->insert({kClassAttr, new_value}); |
| 933 | } |
| 934 | |
| 935 | return Status::OK(); |
| 936 | } |
| 937 | |
| 938 | } // namespace tensorflow |