[XLA] Only overwrite the hlo_profiling flag when it's not enabled by default.
authorBenjamin Kramer <kramerb@google.com>
Thu, 22 Mar 2018 16:34:29 +0000 (09:34 -0700)
committerTensorFlower Gardener <gardener@tensorflow.org>
Thu, 22 Mar 2018 16:37:15 +0000 (09:37 -0700)
This got broken in 504d103a405654f029e8902d97d4dd8f3aa07513

PiperOrigin-RevId: 190077360

tensorflow/compiler/xla/client/executable_build_options.cc
tensorflow/compiler/xla/client/executable_build_options.h
tensorflow/compiler/xla/service/local_service.cc

index 4ff4da6..6e3c5cb 100644 (file)
@@ -103,6 +103,8 @@ ExecutableBuildOptions& ExecutableBuildOptions::set_hlo_profile(bool enabled) {
   return *this;
 }
 
-bool ExecutableBuildOptions::hlo_profile() const { return hlo_profile_; }
+tensorflow::gtl::optional<bool> ExecutableBuildOptions::hlo_profile() const {
+  return hlo_profile_;
+}
 
 }  // namespace xla
index 85b2cd9..11f1098 100644 (file)
@@ -70,17 +70,18 @@ class ExecutableBuildOptions {
       tensorflow::StringPiece dirpath);
   const tensorflow::gtl::optional<string>& dump_per_pass_hlo_proto_to() const;
 
-  // If set, specifies that we should record an HLO profile during execution and
-  // log it after execution (as in DebugOptions).
+  // If true, specifies that we should record an HLO profile during execution
+  // and log it after execution (as in DebugOptions). If nullopt the default is
+  // used.
   ExecutableBuildOptions& set_hlo_profile(bool enabled);
-  bool hlo_profile() const;
+  tensorflow::gtl::optional<bool> hlo_profile() const;
 
   // Returns a string representation of the build options, suitable for
   // debugging.
   string ToString() const;
 
  private:
-  bool hlo_profile_ = false;
+  tensorflow::gtl::optional<bool> hlo_profile_;
   int device_ordinal_ = -1;
   Shape result_layout_;
   bool result_layout_set_ = false;
index 7fd1ccd..5690a89 100644 (file)
@@ -119,8 +119,10 @@ StatusOr<std::unique_ptr<Executable>> LocalService::CompileExecutable(
   }
 
   ExecutionOptions execution_options = CreateDefaultExecutionOptions();
-  execution_options.mutable_debug_options()->set_xla_hlo_profile(
-      build_options.hlo_profile());
+  if (build_options.hlo_profile().has_value()) {
+    execution_options.mutable_debug_options()->set_xla_hlo_profile(
+        *build_options.hlo_profile());
+  }
   if (build_options.generate_hlo_graph().has_value()) {
     execution_options.mutable_debug_options()->set_xla_generate_hlo_graph(
         build_options.generate_hlo_graph().value());