Skip to content

Commit

Permalink
[XLA] De-emphasize uninteresting nodes in the HLO graph dump.
Browse files Browse the repository at this point in the history
The hope is that this will make expensive / interesting ops easier to
see.

PiperOrigin-RevId: 173478095
  • Loading branch information
Justin Lebar authored and tensorflower-gardener committed Oct 26, 2017
1 parent b4aac5d commit 5965a76
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions tensorflow/compiler/xla/service/hlo_graph_dumper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ string HtmlLikeStringSanitize(tensorflow::StringPiece s) {
// commutative, we also support them with param0 and param1 swapped.
//
// This is useful primarily for reduce and map nodes. These take a
// subcomputation which is almost always one of the four above, and pattern
// matching it to a short string lets us tell the user what the subcomputation
// is without drawing it as a graph.
// subcomputation which is almost always one of the above, and pattern matching
// it to a short string lets us tell the user what the subcomputation is without
// drawing it as a graph.
optional<string> MatchTrivialComputation(const HloComputation* computation) {
if (computation->instruction_count() != 3) {
return nullopt;
Expand Down Expand Up @@ -788,7 +788,6 @@ ColorScheme HloDotDumper::GetInstructionColor(const HloInstruction* instr) {
case HloOpcode::kNegate:
case HloOpcode::kPower:
case HloOpcode::kRemainder:
case HloOpcode::kSelect:
case HloOpcode::kShiftLeft:
case HloOpcode::kShiftRightArithmetic:
case HloOpcode::kShiftRightLogical:
Expand All @@ -799,21 +798,46 @@ ColorScheme HloDotDumper::GetInstructionColor(const HloInstruction* instr) {
case HloOpcode::kSubtract:
case HloOpcode::kTanh:
case HloOpcode::kRng:
case HloOpcode::kBroadcast:
case HloOpcode::kTranspose:
// De-emphasize scalar-shaped elementwise ops -- they're generally
// uninteresting.
if (ShapeUtil::IsEffectiveScalar(instr->shape())) {
return kWhite;
}
return kYellow;
case HloOpcode::kBitcast:
case HloOpcode::kTuple:
case HloOpcode::kTrace:
case HloOpcode::kGetTupleElement:
return kWhite;
case HloOpcode::kBroadcast:
// De-emphasize nodes which broadcast a scalar within a fusion node --
// these are essentially free.
if (instr->IsFused() &&
ShapeUtil::IsEffectiveScalar(instr->operand(0)->shape())) {
return kWhite;
}
return kGreen;
case HloOpcode::kConcatenate:
case HloOpcode::kCopy:
case HloOpcode::kDynamicSlice:
case HloOpcode::kDynamicUpdateSlice:
case HloOpcode::kPad:
case HloOpcode::kReshape:
case HloOpcode::kReverse:
case HloOpcode::kSelect:
case HloOpcode::kTranspose:
// De-emphasize scalar-shaped data movement ops and all data movement ops
// inside fusion nodes, both of which are essentially free.
if (ShapeUtil::IsEffectiveScalar(instr->shape()) || instr->IsFused()) {
return kWhite;
}
return kGreen;
case HloOpcode::kDynamicUpdateSlice:
// Unlike the data-movement ops above, dynamic-update-slice is not ~free
// inside of fusion nodes, so we de-emphasize it only if it's
// scalar-shaped.
if (ShapeUtil::IsEffectiveScalar(instr->shape())) {
return kWhite;
}
return kGreen;
case HloOpcode::kConvolution:
case HloOpcode::kDot:
Expand Down

0 comments on commit 5965a76

Please sign in to comment.