From a13443841dabc86deaaf6050bfd04f42b68281f2 Mon Sep 17 00:00:00 2001 From: Justin Lebar Date: Tue, 9 Jul 2019 09:51:48 -0700 Subject: [PATCH] [XLA] Don't print LLVM IR to stdout if the user specifies just --xla_dump_hlo_as_url. This flag alone means you probably just want the rendered HLO graphs printed to stdout and nothing more. If you do want the LLVM IR printed to stdout, just add --xla_dump_hlo_as_text. PiperOrigin-RevId: 257213859 --- tensorflow/compiler/xla/service/dump.cc | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/tensorflow/compiler/xla/service/dump.cc b/tensorflow/compiler/xla/service/dump.cc index d251c828bcd..6a4837211e8 100644 --- a/tensorflow/compiler/xla/service/dump.cc +++ b/tensorflow/compiler/xla/service/dump.cc @@ -48,22 +48,27 @@ struct CanonicalDebugOptions { // function we treat this struct's members as write-only, and read only from // `opts`. - // If dump_to is empty, default to dumping to stdout. - if (opts.xla_dump_to().empty()) { - dump_to = "-"; - } - // Did the user specifiy an explicit format for dumping? - bool output_format_specified = + bool output_format_other_than_url_specified = opts.xla_dump_hlo_as_text() || opts.xla_dump_hlo_as_proto() || opts.xla_dump_hlo_as_dot() || opts.xla_dump_hlo_as_html() || - opts.xla_dump_hlo_as_url() || opts.xla_dump_hlo_snapshots(); + opts.xla_dump_hlo_snapshots(); + bool output_format_specified = + output_format_other_than_url_specified || opts.xla_dump_hlo_as_url(); // If we haven't specified an output format, default to dumping as text. if (!output_format_specified) { dump_as_text = true; } + // If dump_to is empty, default to dumping to stdout, so long as some dump + // format other than dump-as-url was specified. If the user only specified + // --xla_dump_hlo_as_url, then don't dump to stdout, that is likely noise + // they don't want. + if (opts.xla_dump_to().empty() && output_format_other_than_url_specified) { + dump_to = "-"; + } + // If we specified a regular expression restricting which modules to dump, // respect that. // @@ -143,6 +148,10 @@ void DumpToFileInDirImpl(string_view filename, string_view contents, return; } + if (opts.dump_to.empty()) { + return; + } + const string& dir = opts.dump_to; VLOG(1) << "Dumping " << filename << " to " << dir;