MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / GetGroupNodes

Function GetGroupNodes

tensorflow/core/common_runtime/colocation_graph.cc:766–794  ·  view source on GitHub ↗

Given a node requiring placer inspection and its IOColocationGroups, computes `group_nodes`. group_nodes[i] contains the nodes that are members of colocation group i. These nodes are inputs or outputs of `node`. group_nodes[i][j] is a pair containing a node and whether this node has a resource input from `node`. Note: The same node can be added multiple times to the same group. The same node can b

Source from the content-addressed store, hash-verified

764// The same node can be added multiple times to the same group.
765// The same node can be added to multiple groups.
766Status GetGroupNodes(const IOColocationGroups& groups, const Node& node,
767 std::vector<std::vector<NodeAndBool>>* group_nodes) {
768 group_nodes->reserve(groups.group_devices.size());
769 for (int arg_idx = 0; arg_idx < groups.input_groups.size(); ++arg_idx) {
770 const Node* src;
771 TF_RETURN_IF_ERROR(node.input_node(arg_idx, &src));
772 int group_id = groups.input_groups[arg_idx];
773 (*group_nodes)[group_id].emplace_back(src, false);
774 }
775
776 for (const Edge* edge : node.out_edges()) {
777 if (edge->IsControlEdge()) {
778 continue;
779 }
780
781 int group_id = groups.output_groups[edge->src_output()];
782 (*group_nodes)[group_id].emplace_back(
783 edge->dst(), edge->dst()->input_type(edge->dst_input()) == DT_RESOURCE);
784 }
785
786 if (VLOG_IS_ON(2)) {
787 VLOG(2) << "Colocated inputs/outputs of node: " << node.DebugString();
788 for (const std::vector<NodeAndBool>& nodes : *group_nodes) {
789 VLOG(2) << "\t[" << absl::StrJoin(NodeAndBoolToString(nodes), "\t\n")
790 << "]";
791 }
792 }
793 return Status::OK();
794}
795
796} // namespace
797

Callers 1

Calls 11

NodeAndBoolToStringFunction · 0.85
input_nodeMethod · 0.80
reserveMethod · 0.45
sizeMethod · 0.45
emplace_backMethod · 0.45
IsControlEdgeMethod · 0.45
src_outputMethod · 0.45
dstMethod · 0.45
input_typeMethod · 0.45
dst_inputMethod · 0.45
DebugStringMethod · 0.45

Tested by

no test coverage detected