in ngraph_bridge/deassign_clusters.cc [57:142]
static void MaybeLogPlacement(const Graph* graph) {
if (!api::IsLoggingPlacement()) return;
std::map<int, std::set<const Node*>> final_cluster_map;
int number_of_nodes = 0, nodes_marked_for_clustering = 0,
nodes_assigned_a_cluster = 0;
for (auto node : graph->nodes()) {
number_of_nodes++;
// Check marked for clustering
if (NodeIsMarkedForClustering(node)) {
nodes_marked_for_clustering++;
}
// Check Cluster Assignment
int cluster_idx;
if (!GetNodeCluster(node, &cluster_idx).ok()) {
cluster_idx = -1;
} else {
nodes_assigned_a_cluster++;
}
final_cluster_map[cluster_idx].insert(node);
}
if (number_of_nodes == 0) return;
int perc_marked_for_clustering_of_total =
(int)((num_nodes_marked_before_deassign * 100.0) / number_of_nodes);
int perc_assigned_clusters_of_total =
(int)((nodes_assigned_a_cluster * 100.0) / number_of_nodes);
int perc_assigned_clusters_of_marked =
num_nodes_marked_before_deassign > 0
? (int)((nodes_assigned_a_cluster * 100.0) /
num_nodes_marked_before_deassign)
: 0;
std::cout << "\n"; // insert a new line at the start of NGTF_SUMMARY
std::cout << "NGTF_SUMMARY: Number of nodes in the graph: " << number_of_nodes
<< std::endl;
// print out the number of nodes marked before deassign
std::cout << "NGTF_SUMMARY: Number of nodes marked for clustering: "
<< num_nodes_marked_before_deassign << " ("
<< perc_marked_for_clustering_of_total << "% of total nodes)"
<< std::endl;
// print out the number of nodes that are running on NGraph after deassign
std::cout << "NGTF_SUMMARY: Number of nodes assigned a cluster: "
<< nodes_assigned_a_cluster << " ("
<< perc_assigned_clusters_of_total << "% of total nodes) \t"
<< " (" << perc_assigned_clusters_of_marked
<< "% of nodes marked for clustering) \t" << std::endl;
int num_encapsulates = final_cluster_map.size() - 1;
std::cout << "NGTF_SUMMARY: Number of ngraph clusters :" << num_encapsulates
<< std::endl;
std::cout << "NGTF_SUMMARY: Nodes per cluster: "
<< ((num_encapsulates > 0) ? (float(nodes_assigned_a_cluster) /
float(num_encapsulates))
: 0)
<< endl;
for (auto kv : final_cluster_map) {
int cluster_idx = kv.first;
if (cluster_idx != -1) {
std::cout << "NGTF_SUMMARY: Size of nGraph Cluster[" << cluster_idx
<< "]:\t" << kv.second.size() << std::endl;
}
}
// log the ops gets deassigned
std::cout << "NGTF_SUMMARY: Op_deassigned: ";
tf_utils::PrintNodeHistogram(deassigned_histogram);
for (auto kv : final_cluster_map) {
int cluster_idx = kv.first;
std::set<const Node*>& nodes = kv.second;
for (auto node : nodes) {
std::stringstream placement_dev;
placement_dev << "OP_placement:\t";
if (cluster_idx == -1) {
placement_dev << "Host\t";
} else {
placement_dev << "nGraph[" << cluster_idx << "]\t";
}
placement_dev << node->name() << " (" << node->type_string() << ")";
std::cout << placement_dev.str() << std::endl;
}
}
std::cout << endl;
}