aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow
diff options
context:
space:
mode:
authorGravatar Justin Lebar <jlebar@google.com>2018-06-04 17:23:10 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-06-04 17:26:24 -0700
commit35c8574e49aadcf16d009717e1d31fcce148db02 (patch)
tree29d1340b7485e7b3b2d38536112c77447bb0fb70 /tensorflow
parent310a51bd875bbac16cb2829e16428fca04fc3a29 (diff)
[XLA] Don't dump subgraphs twice in hlo_graph_dumper.
Surprisingly a subgraph twice mostly worked. But it broke the rollover edge highlighting, and it also drew all the edges in the subgraph twice. PiperOrigin-RevId: 199221368
Diffstat (limited to 'tensorflow')
-rw-r--r--tensorflow/compiler/xla/service/hlo_graph_dumper.cc54
1 files changed, 28 insertions, 26 deletions
diff --git a/tensorflow/compiler/xla/service/hlo_graph_dumper.cc b/tensorflow/compiler/xla/service/hlo_graph_dumper.cc
index 05adb45713..61612bebd1 100644
--- a/tensorflow/compiler/xla/service/hlo_graph_dumper.cc
+++ b/tensorflow/compiler/xla/service/hlo_graph_dumper.cc
@@ -590,15 +590,26 @@ bool HloDotDumper::ShouldShowSubcomputation(const HloComputation* subcomp) {
string HloDotDumper::DumpSubcomputation(const HloComputation* subcomp,
const HloInstruction* parent_instr) {
VLOG(2) << "Dumping subcomputation " << subcomp->name();
- const char* computation_fmt = R"(subgraph %s {
-%s
-label = <%s>;
-labelloc = t;
-tooltip = " ";
-%s
-} // %s
+ // Add an edge from the subcomputation to its parent node. If subcomp
+ // belongs to a fusion node, it's drawn in place of the fusion instruction,
+ // so there's no need to link those.
+ if (parent_instr->opcode() != HloOpcode::kFusion) {
+ const HloInstruction* from = GetNodeForEdge(subcomp->root_instruction());
+ VLOG(2) << "Edge: from " << from->name() << " to " << parent_instr->name()
+ << " as " << next_edge_id_;
+ edge_ids_.insert({{from, parent_instr}, next_edge_id_++});
+ const char* edge_fmt =
+ R"(%s -> %s [ltail="%s", style="dashed" tooltip="%s -> %s"];)";
+ edges_.push_back(Printf(
+ edge_fmt, InstructionId(from), InstructionId(parent_instr),
+ SubcomputationId(subcomp), subcomp->name(), parent_instr->name()));
+ }
-)";
+ // Have we already dumped this subcomputation? If so, generating the edge
+ // linking it and parent_instr is all we want to do in this function.
+ if (cluster_ids_.find(subcomp) != cluster_ids_.end()) {
+ return "";
+ }
cluster_ids_[subcomp] = next_cluster_id_++;
@@ -645,25 +656,16 @@ tooltip = " ";
string comp_body = DumpComputation(subcomp);
- // Add an edge from the subcomputation to its parent node. If subcomp
- // belongs to a fusion node, it's drawn in place of the fusion instruction,
- // so there's no need to link those.
- if (parent_instr->opcode() != HloOpcode::kFusion) {
- const HloInstruction* from = GetNodeForEdge(subcomp->root_instruction());
- VLOG(2) << "Edge: from " << from->name() << " to " << parent_instr->name()
- << " as " << next_edge_id_;
- edge_ids_.insert({{from, parent_instr}, next_edge_id_++});
- const char* edge_fmt =
- R"(%s -> %s [ltail="%s", style="dashed" tooltip="%s -> %s"];)";
- edges_.push_back(Printf(
- edge_fmt, InstructionId(from), InstructionId(parent_instr),
- SubcomputationId(subcomp), subcomp->name(), parent_instr->name()));
- }
-
- string computation =
- Printf(computation_fmt, id, style, subcomp_label, comp_body, id);
+ const char* computation_fmt = R"(subgraph %s {
+%s
+label = <%s>;
+labelloc = t;
+tooltip = " ";
+%s
+} // %s
- return computation;
+)";
+ return Printf(computation_fmt, id, style, subcomp_label, comp_body, id);
}
string HloDotDumper::DumpComputation(const HloComputation* comp) {