aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/compiler/xla/service/hlo_computation.cc
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-05-11 17:53:06 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-05-11 17:55:58 -0700
commit5ec03a85e6cb6ee360fcf2a99611dc7e678dc09c (patch)
tree940062f7114322849ab137fa90664be5324d76c4 /tensorflow/compiler/xla/service/hlo_computation.cc
parentd8f01370b8e126bf4eedb9e07ba690c651204120 (diff)
Implement additional options to control the string output of HloInstruction and HloComputation.
PiperOrigin-RevId: 196334340
Diffstat (limited to 'tensorflow/compiler/xla/service/hlo_computation.cc')
-rw-r--r--tensorflow/compiler/xla/service/hlo_computation.cc39
1 files changed, 26 insertions, 13 deletions
diff --git a/tensorflow/compiler/xla/service/hlo_computation.cc b/tensorflow/compiler/xla/service/hlo_computation.cc
index 05dceb1dc0..63c3dc4a59 100644
--- a/tensorflow/compiler/xla/service/hlo_computation.cc
+++ b/tensorflow/compiler/xla/service/hlo_computation.cc
@@ -365,25 +365,38 @@ std::list<HloComputation*> HloComputation::MakeEmbeddedComputationsList()
string HloComputation::ToString(const HloPrintOptions& options) const {
std::ostringstream s;
for (int i = 0; i < options.indent_amount(); i++) {
- s << " ";
+ s << " ";
}
- if (options.print_percent()) {
- s << "%";
+
+ if (!options.is_in_nested_computation()) {
+ if (options.print_percent()) {
+ s << "%";
+ }
+ s << name() << " ";
}
- s << name();
+
if (options.print_program_shape()) {
- s << " " << ShapeUtil::HumanString(ComputeProgramShape());
- }
- s << " {\n";
- for (const HloInstruction* instruction : MakeInstructionPostOrder()) {
- for (int i = 0; i < options.indent_amount(); i++) {
- s << " ";
+ s << ShapeUtil::HumanString(ComputeProgramShape()) << " ";
+ }
+ s << "{\n";
+ {
+ // Print the instructions in this computation.
+ HloPrintOptions new_options = options;
+ new_options.set_indent_amount(options.indent_amount() + 1)
+ .set_is_in_nested_computation(true);
+ CanonicalNameMap name_map;
+ for (const HloInstruction* instruction : MakeInstructionPostOrder()) {
+ for (int i = 0; i < new_options.indent_amount(); i++) {
+ s << " ";
+ }
+ s << (instruction == root_instruction_ ? "ROOT " : "")
+ << instruction->ToStringWithCanonicalNameMap(new_options, &name_map)
+ << "\n";
}
- s << " " << (instruction == root_instruction_ ? "ROOT " : "")
- << instruction->ToString(options) << "\n";
}
+
for (int i = 0; i < options.indent_amount(); i++) {
- s << " ";
+ s << " ";
}
s << "}";
return s.str();