From 499b8bd16d19afd6ce78b868a381101f5eb4c82c Mon Sep 17 00:00:00 2001 From: Sanjoy Das Date: Mon, 12 Nov 2018 07:35:16 -0800 Subject: [PATCH] Print values for parsed MarkForCompilationPassFlags and XlaOpsCommonFlags While at it change from "typedef struct { ... } X;" to "struct X { ... };". The former is a C-ism not necessary in C++. PiperOrigin-RevId: 221089377 --- .../legacy_flags/mark_for_compilation_pass_flags.cc | 12 ++++++++++++ .../legacy_flags/mark_for_compilation_pass_flags.h | 4 ++-- .../jit/legacy_flags/xla_ops_common_flags.cc | 8 +++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/tensorflow/compiler/jit/legacy_flags/mark_for_compilation_pass_flags.cc b/tensorflow/compiler/jit/legacy_flags/mark_for_compilation_pass_flags.cc index 91d6276f495..bad306e0b0a 100644 --- a/tensorflow/compiler/jit/legacy_flags/mark_for_compilation_pass_flags.cc +++ b/tensorflow/compiler/jit/legacy_flags/mark_for_compilation_pass_flags.cc @@ -20,6 +20,7 @@ limitations under the License. #include "tensorflow/compiler/jit/legacy_flags/mark_for_compilation_pass_flags.h" #include "tensorflow/compiler/xla/parse_flags_from_env.h" +#include "tensorflow/core/platform/logging.h" #include "tensorflow/core/platform/types.h" #include "tensorflow/core/util/command_line_flags.h" @@ -65,6 +66,17 @@ static void AllocateFlags() { "enable fusion of element-wise operations only using XLA when " "global_jit_level is ON*.")}); xla::ParseFlagsFromEnv(*flag_list); + + if (VLOG_IS_ON(1)) { + VLOG(1) << "Parsed MarkForCompilationPassFlags:"; + VLOG(1) << " tf_xla_auto_jit = " << flags->tf_xla_auto_jit; + VLOG(1) << " tf_xla_min_cluster_size = " << flags->tf_xla_min_cluster_size; + VLOG(1) << " tf_xla_max_cluster_size = " << flags->tf_xla_max_cluster_size; + VLOG(1) << " tf_xla_clustering_debug = " << flags->tf_xla_clustering_debug; + VLOG(1) << " tf_xla_cpu_global_jit = " << flags->tf_xla_cpu_global_jit; + VLOG(1) << " tf_xla_clustering_fuel = " << flags->tf_xla_clustering_fuel; + VLOG(1) << " tf_xla_fusion_only = " << flags->tf_xla_fusion_only; + } } // Append to *append_to flag definitions associated with the XLA bridge's diff --git a/tensorflow/compiler/jit/legacy_flags/mark_for_compilation_pass_flags.h b/tensorflow/compiler/jit/legacy_flags/mark_for_compilation_pass_flags.h index 2affda6ab4e..79b47357a17 100644 --- a/tensorflow/compiler/jit/legacy_flags/mark_for_compilation_pass_flags.h +++ b/tensorflow/compiler/jit/legacy_flags/mark_for_compilation_pass_flags.h @@ -33,7 +33,7 @@ void AppendMarkForCompilationPassFlags( // The values of flags associated with the XLA bridge's // mark_for_compilation_pass module. -typedef struct { +struct MarkForCompilationPassFlags { int32 tf_xla_auto_jit; // Control compilation of operators into XLA // computations on CPU and GPU devices. 0 = use // ConfigProto setting; -1 = off; 1 = on for things @@ -55,7 +55,7 @@ typedef struct { // is set to ON* and overrides its behavior. If // true, enable fusion of element-wise operations // only using XLA. -} MarkForCompilationPassFlags; +}; // Return a pointer to the MarkForCompilationPassFlags struct; // repeated calls return the same pointer. diff --git a/tensorflow/compiler/jit/legacy_flags/xla_ops_common_flags.cc b/tensorflow/compiler/jit/legacy_flags/xla_ops_common_flags.cc index 8bcf80b2ab5..1443d48a734 100644 --- a/tensorflow/compiler/jit/legacy_flags/xla_ops_common_flags.cc +++ b/tensorflow/compiler/jit/legacy_flags/xla_ops_common_flags.cc @@ -18,7 +18,7 @@ limitations under the License. #include "tensorflow/compiler/jit/legacy_flags/xla_ops_common_flags.h" #include "tensorflow/compiler/xla/parse_flags_from_env.h" - +#include "tensorflow/core/platform/logging.h" #include "tensorflow/core/util/command_line_flags.h" namespace tensorflow { @@ -36,6 +36,12 @@ void AllocateAndParseFlags() { &flags->tf_xla_always_defer_compilation, ""), }); xla::ParseFlagsFromEnv(*flag_list); + + if (VLOG_IS_ON(1)) { + VLOG(1) << "Parsed XlaOpsCommonFlags:"; + VLOG(1) << " tf_xla_always_defer_compilation = " + << flags->tf_xla_always_defer_compilation; + } } const XlaOpsCommonFlags& GetXlaOpsCommonFlags() {