Remove ProfilerSession::Create with no arguments
PiperOrigin-RevId: 324688779
Change-Id: Ia285b30de66e04ad3e6286c315a4563420287cf8
diff --git a/tensorflow/core/distributed_runtime/worker.cc b/tensorflow/core/distributed_runtime/worker.cc
index 5212f51..c4dc51c 100644
--- a/tensorflow/core/distributed_runtime/worker.cc
+++ b/tensorflow/core/distributed_runtime/worker.cc
@@ -198,7 +198,9 @@
ProfilerSession* profiler_session = nullptr;
if (collector && request->exec_opts().record_timeline()) {
// If timeline was requested, assume we want hardware level tracing.
- profiler_session = ProfilerSession::Create().release();
+ ProfileOptions options = ProfilerSession::DefaultOptions();
+ options.set_host_tracer_level(0);
+ profiler_session = ProfilerSession::Create(options).release();
}
CancellationManager* cm = new CancellationManager;
opts->SetCancelCallback([this, cm, step_id]() {
diff --git a/tensorflow/core/profiler/lib/BUILD b/tensorflow/core/profiler/lib/BUILD
index 0f92ffd..57a3fa8 100644
--- a/tensorflow/core/profiler/lib/BUILD
+++ b/tensorflow/core/profiler/lib/BUILD
@@ -46,7 +46,6 @@
],
deps = [
"//tensorflow/core:lib",
- "//tensorflow/core:lib_internal",
"//tensorflow/core/platform",
"//tensorflow/core/profiler/internal:profiler_interface",
"//tensorflow/core/profiler/protobuf:xplane_proto_cc",
diff --git a/tensorflow/core/profiler/lib/profiler_session.cc b/tensorflow/core/profiler/lib/profiler_session.cc
index 90857ea..ee6eb55 100644
--- a/tensorflow/core/profiler/lib/profiler_session.cc
+++ b/tensorflow/core/profiler/lib/profiler_session.cc
@@ -29,7 +29,6 @@
#include "tensorflow/core/profiler/protobuf/xplane.pb.h"
#include "tensorflow/core/protobuf/config.pb.h"
#include "tensorflow/core/protobuf/error_codes.pb.h"
-#include "tensorflow/core/util/env_var.h"
#if !defined(IS_MOBILE_PLATFORM)
#include "tensorflow/core/profiler/internal/profiler_factory.h"
@@ -41,31 +40,20 @@
#endif
namespace tensorflow {
-
namespace {
+
ProfileOptions GetOptions(const ProfileOptions& opts) {
if (opts.version()) return opts;
ProfileOptions options = ProfilerSession::DefaultOptions();
options.set_include_dataset_ops(opts.include_dataset_ops());
return options;
}
+
}; // namespace
/*static*/ std::unique_ptr<ProfilerSession> ProfilerSession::Create(
const ProfileOptions& options) {
- return absl::WrapUnique(new ProfilerSession(options));
-}
-
-/*static*/ std::unique_ptr<ProfilerSession> ProfilerSession::Create() {
- int64 host_tracer_level = 2;
- tensorflow::Status s = ReadInt64FromEnvVar("TF_PROFILER_HOST_TRACER_LEVEL", 2,
- &host_tracer_level);
- if (!s.ok()) {
- LOG(WARNING) << "ProfilerSession: " << s.error_message();
- }
- ProfileOptions options = DefaultOptions();
- options.set_host_tracer_level(host_tracer_level);
- return Create(options);
+ return absl::WrapUnique(new ProfilerSession(GetOptions(options)));
}
tensorflow::Status ProfilerSession::Status() {
@@ -141,14 +129,14 @@
return Status::OK();
}
-ProfilerSession::ProfilerSession(const ProfileOptions& options)
+ProfilerSession::ProfilerSession(ProfileOptions options)
#if !defined(IS_MOBILE_PLATFORM)
: active_(profiler::AcquireProfilerLock()),
#else
: active_(false),
#endif
start_time_ns_(EnvTime::NowNanos()),
- options_(GetOptions(options)) {
+ options_(std::move(options)) {
if (!active_) {
#if !defined(IS_MOBILE_PLATFORM)
status_ = tensorflow::Status(error::UNAVAILABLE,
diff --git a/tensorflow/core/profiler/lib/profiler_session.h b/tensorflow/core/profiler/lib/profiler_session.h
index 6f92b04..93541f5 100644
--- a/tensorflow/core/profiler/lib/profiler_session.h
+++ b/tensorflow/core/profiler/lib/profiler_session.h
@@ -40,7 +40,6 @@
public:
// Creates and ProfilerSession and starts profiling.
static std::unique_ptr<ProfilerSession> Create(const ProfileOptions& options);
- static std::unique_ptr<ProfilerSession> Create();
static ProfileOptions DefaultOptions() {
ProfileOptions options;
@@ -67,7 +66,7 @@
private:
// Constructs an instance of the class and starts profiling
- explicit ProfilerSession(const ProfileOptions& options);
+ explicit ProfilerSession(ProfileOptions options);
// ProfilerSession is neither copyable or movable.
ProfilerSession(const ProfilerSession&) = delete;