Move third_party/tensorflow/core/protobuf/trace_events.proto.h to third_party/tensorflow/core/profiler/protobuf/trace_events.proto.h
PiperOrigin-RevId: 303188235 Change-Id: I06294ff7b4d2b38eb0b704c82dd53b1d02642c3f
This commit is contained in:
parent
6d947c837a
commit
b97c90c87f
@ -199,7 +199,6 @@ COMMON_PROTO_SRCS = [
|
||||
"protobuf/tensor_bundle.proto",
|
||||
"protobuf/saver.proto",
|
||||
"protobuf/verifier_config.proto",
|
||||
"protobuf/trace_events.proto",
|
||||
]
|
||||
|
||||
EXAMPLE_PROTO_SRCS = [
|
||||
|
@ -159,7 +159,7 @@ cc_library(
|
||||
hdrs = ["trace_events_to_json.h"],
|
||||
deps = [
|
||||
"//tensorflow/core:lib",
|
||||
"//tensorflow/core:protos_all_cc",
|
||||
"//tensorflow/core/profiler/protobuf:trace_events_proto_cc",
|
||||
"@com_google_absl//absl/strings",
|
||||
"@com_google_absl//absl/strings:str_format",
|
||||
"@jsoncpp_git//:jsoncpp",
|
||||
@ -172,9 +172,9 @@ tf_cc_test(
|
||||
deps = [
|
||||
":trace_events_to_json",
|
||||
"//tensorflow/core:lib",
|
||||
"//tensorflow/core:protos_all_cc",
|
||||
"//tensorflow/core:test",
|
||||
"//tensorflow/core:test_main",
|
||||
"//tensorflow/core/profiler/protobuf:trace_events_proto_cc",
|
||||
"@jsoncpp_git//:jsoncpp",
|
||||
],
|
||||
)
|
||||
@ -305,7 +305,7 @@ cc_library(
|
||||
hdrs = ["xplane_to_trace_events.h"],
|
||||
deps = [
|
||||
"//tensorflow/core:lib",
|
||||
"//tensorflow/core:protos_all_cc",
|
||||
"//tensorflow/core/profiler/protobuf:trace_events_proto_cc",
|
||||
"//tensorflow/core/profiler/protobuf:xplane_proto_cc",
|
||||
"//tensorflow/core/profiler/utils:tf_xplane_visitor",
|
||||
"//tensorflow/core/profiler/utils:xplane_schema",
|
||||
|
@ -18,7 +18,7 @@ limitations under the License.
|
||||
#include "absl/strings/str_cat.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "include/json/json.h"
|
||||
#include "tensorflow/core/protobuf/trace_events.pb.h"
|
||||
#include "tensorflow/core/profiler/protobuf/trace_events.pb.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace profiler {
|
||||
|
@ -17,7 +17,7 @@ limitations under the License.
|
||||
#define TENSORFLOW_CORE_PROFILER_CONVERT_TRACE_EVENTS_TO_JSON_H_
|
||||
|
||||
#include "tensorflow/core/platform/types.h"
|
||||
#include "tensorflow/core/protobuf/trace_events.pb.h"
|
||||
#include "tensorflow/core/profiler/protobuf/trace_events.pb.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace profiler {
|
||||
|
@ -18,7 +18,7 @@ limitations under the License.
|
||||
#include "include/json/json.h"
|
||||
#include "tensorflow/core/platform/protobuf.h"
|
||||
#include "tensorflow/core/platform/test.h"
|
||||
#include "tensorflow/core/protobuf/trace_events.pb.h"
|
||||
#include "tensorflow/core/profiler/protobuf/trace_events.pb.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace profiler {
|
||||
|
@ -77,10 +77,10 @@ void ConvertXSpaceToTraceEvents(const XSpace& xspace, Trace* trace) {
|
||||
event->set_device_id(device_id);
|
||||
event->set_resource_id(resource_id);
|
||||
if (xevent.HasDisplayName()) {
|
||||
event->set_name(string(xevent.DisplayName()));
|
||||
args["long_name"] = string(xevent.Name());
|
||||
event->set_name(std::string(xevent.DisplayName()));
|
||||
args["long_name"] = std::string(xevent.Name());
|
||||
} else {
|
||||
event->set_name(string(xevent.Name()));
|
||||
event->set_name(std::string(xevent.Name()));
|
||||
}
|
||||
event->set_timestamp_ps(xevent.TimestampPs());
|
||||
event->set_duration_ps(xevent.DurationPs());
|
||||
@ -88,7 +88,7 @@ void ConvertXSpaceToTraceEvents(const XSpace& xspace, Trace* trace) {
|
||||
xevent.ForEachStat([&](const XStatVisitor& stat) {
|
||||
if (stat.ValueCase() == XStat::VALUE_NOT_SET) return;
|
||||
if (IsInternalStat(stat.Type())) return;
|
||||
args[string(stat.Name())] = stat.ToString();
|
||||
args[std::string(stat.Name())] = stat.ToString();
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -100,5 +100,12 @@ void ConvertXSpaceToTraceEvents(const XSpace& xspace, Trace* trace) {
|
||||
MaybeDropEventsForTraceViewer(trace, kMaxEvents);
|
||||
}
|
||||
|
||||
void ConvertXSpaceToTraceEventsString(const XSpace& xspace,
|
||||
std::string* content) {
|
||||
Trace trace;
|
||||
ConvertXSpaceToTraceEvents(xspace, &trace);
|
||||
trace.SerializeToString(content);
|
||||
}
|
||||
|
||||
} // namespace profiler
|
||||
} // namespace tensorflow
|
||||
|
@ -18,14 +18,17 @@ limitations under the License.
|
||||
|
||||
#include "absl/strings/str_split.h"
|
||||
#include "tensorflow/core/platform/types.h"
|
||||
#include "tensorflow/core/profiler/protobuf/trace_events.pb.h"
|
||||
#include "tensorflow/core/profiler/protobuf/xplane.pb.h"
|
||||
#include "tensorflow/core/protobuf/trace_events.pb.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace profiler {
|
||||
|
||||
void ConvertXSpaceToTraceEvents(const XSpace& xspace, Trace* trace);
|
||||
|
||||
void ConvertXSpaceToTraceEventsString(const XSpace& xspace,
|
||||
std::string* content);
|
||||
|
||||
// Not Public API, Testing only.
|
||||
void MaybeDropEventsForTraceViewer(Trace* trace, uint32 limit);
|
||||
|
||||
|
@ -47,7 +47,6 @@ cc_library(
|
||||
"//tensorflow/core:lib",
|
||||
"//tensorflow/core:lib_internal",
|
||||
"//tensorflow/core:framework",
|
||||
"//tensorflow/core:protos_all_cc",
|
||||
"//tensorflow/core/platform",
|
||||
"//tensorflow/core/profiler/internal:profiler_interface",
|
||||
"//tensorflow/core/profiler/protobuf:xplane_proto_cc",
|
||||
@ -55,7 +54,6 @@ cc_library(
|
||||
] + if_not_android([
|
||||
":profiler_utils",
|
||||
"//tensorflow/core/profiler/internal:profiler_factory",
|
||||
"//tensorflow/core/profiler/convert:xplane_to_trace_events",
|
||||
"//tensorflow/core/profiler/utils:derived_timeline",
|
||||
"//tensorflow/core/profiler/utils:group_events",
|
||||
"//tensorflow/core/profiler/utils:xplane_utils",
|
||||
|
@ -20,14 +20,10 @@ limitations under the License.
|
||||
#include "tensorflow/core/platform/mutex.h"
|
||||
#include "tensorflow/core/platform/platform.h"
|
||||
#include "tensorflow/core/platform/types.h"
|
||||
#include "tensorflow/core/protobuf/config.pb.h"
|
||||
#include "tensorflow/core/protobuf/error_codes.pb.h"
|
||||
#include "tensorflow/core/protobuf/trace_events.pb.h"
|
||||
#include "tensorflow/core/util/env_var.h"
|
||||
#include "tensorflow/core/util/ptr_util.h"
|
||||
|
||||
#if !defined(IS_MOBILE_PLATFORM)
|
||||
#include "tensorflow/core/profiler/convert/xplane_to_trace_events.h"
|
||||
#include "tensorflow/core/profiler/internal/profiler_factory.h"
|
||||
#include "tensorflow/core/profiler/lib/profiler_utils.h"
|
||||
#include "tensorflow/core/profiler/utils/derived_timeline.h"
|
||||
@ -126,16 +122,6 @@ Status ProfilerSession::CollectData(RunMetadata* run_metadata) {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status ProfilerSession::SerializeToString(string* content) {
|
||||
profiler::Trace trace;
|
||||
#if !defined(IS_MOBILE_PLATFORM)
|
||||
profiler::XSpace xspace;
|
||||
TF_RETURN_IF_ERROR(CollectData(&xspace));
|
||||
profiler::ConvertXSpaceToTraceEvents(xspace, &trace);
|
||||
#endif
|
||||
trace.SerializeToString(content);
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
ProfilerSession::ProfilerSession(const profiler::ProfilerOptions& options)
|
||||
#if !defined(IS_MOBILE_PLATFORM)
|
||||
|
@ -23,7 +23,6 @@ limitations under the License.
|
||||
#include "tensorflow/core/platform/thread_annotations.h"
|
||||
#include "tensorflow/core/profiler/internal/profiler_interface.h"
|
||||
#include "tensorflow/core/profiler/protobuf/xplane.pb.h"
|
||||
#include "tensorflow/core/protobuf/config.pb.h"
|
||||
|
||||
namespace tensorflow {
|
||||
|
||||
@ -52,9 +51,6 @@ class ProfilerSession {
|
||||
tensorflow::Status CollectData(RunMetadata* run_metadata)
|
||||
TF_LOCKS_EXCLUDED(mutex_);
|
||||
|
||||
tensorflow::Status SerializeToString(string* content)
|
||||
TF_LOCKS_EXCLUDED(mutex_);
|
||||
|
||||
private:
|
||||
// Constructs an instance of the class and starts profiling
|
||||
explicit ProfilerSession(const profiler::ProfilerOptions& options);
|
||||
|
@ -99,6 +99,13 @@ tf_proto_library(
|
||||
visibility = [":friends"],
|
||||
)
|
||||
|
||||
tf_proto_library(
|
||||
name = "trace_events_proto",
|
||||
srcs = ["trace_events.proto"],
|
||||
cc_api_version = 2,
|
||||
visibility = [":friends"],
|
||||
)
|
||||
|
||||
tf_proto_library(
|
||||
name = "hardware_types_proto",
|
||||
srcs = ["hardware_types.proto"],
|
||||
|
@ -26,8 +26,8 @@ cc_library(
|
||||
deps = [
|
||||
"//tensorflow/core:framework",
|
||||
"//tensorflow/core:lib",
|
||||
"//tensorflow/core:protos_all_cc",
|
||||
"//tensorflow/core/profiler:profiler_service_proto_cc",
|
||||
"//tensorflow/core/profiler/protobuf:trace_events_proto_cc",
|
||||
"@com_google_absl//absl/strings",
|
||||
"@com_google_absl//absl/time",
|
||||
],
|
||||
|
@ -28,10 +28,10 @@ limitations under the License.
|
||||
#include "tensorflow/core/lib/io/compression.h"
|
||||
#include "tensorflow/core/platform/env.h"
|
||||
#include "tensorflow/core/platform/protobuf.h"
|
||||
#include "tensorflow/core/profiler/protobuf/trace_events.pb.h"
|
||||
// Windows.h #defines ERROR, but it is also used in
|
||||
// tensorflow/core/util/event.proto
|
||||
#undef ERROR
|
||||
#include "tensorflow/core/protobuf/trace_events.pb.h"
|
||||
#include "tensorflow/core/util/events_writer.h"
|
||||
|
||||
namespace tensorflow {
|
||||
|
@ -216,6 +216,7 @@ cuda_py_test(
|
||||
deps = [
|
||||
":profiler",
|
||||
":test",
|
||||
"//tensorflow/core/profiler/protobuf:trace_events_proto_py",
|
||||
"//tensorflow/python:constant_op",
|
||||
"//tensorflow/python/profiler:traceme",
|
||||
],
|
||||
|
@ -20,7 +20,7 @@ from __future__ import print_function
|
||||
|
||||
import os
|
||||
|
||||
from tensorflow.core.protobuf import trace_events_pb2
|
||||
from tensorflow.core.profiler.protobuf import trace_events_pb2
|
||||
from tensorflow.python.eager import profiler
|
||||
from tensorflow.python.eager import test
|
||||
from tensorflow.python.framework import config
|
||||
|
@ -119,6 +119,7 @@ tf_python_pybind_extension(
|
||||
deps = [
|
||||
"//tensorflow/core:lib",
|
||||
"//tensorflow/core/profiler/convert:xplane_to_profile_response",
|
||||
"//tensorflow/core/profiler/convert:xplane_to_trace_events",
|
||||
"//tensorflow/core/profiler/lib:profiler_session_headers",
|
||||
"//tensorflow/core/profiler/rpc:profiler_server",
|
||||
"//tensorflow/core/profiler/rpc/client:capture_profile",
|
||||
|
@ -20,6 +20,7 @@ limitations under the License.
|
||||
#include "tensorflow/core/platform/host_info.h"
|
||||
#include "tensorflow/core/platform/types.h"
|
||||
#include "tensorflow/core/profiler/convert/xplane_to_profile_response.h"
|
||||
#include "tensorflow/core/profiler/convert/xplane_to_trace_events.h"
|
||||
#include "tensorflow/core/profiler/lib/profiler_session.h"
|
||||
#include "tensorflow/core/profiler/rpc/client/capture_profile.h"
|
||||
#include "tensorflow/core/profiler/rpc/client/save_profile.h"
|
||||
@ -56,8 +57,10 @@ class ProfilerSessionWrapper {
|
||||
py::bytes Stop() {
|
||||
tensorflow::string content;
|
||||
if (session_ != nullptr) {
|
||||
tensorflow::Status status = session_->SerializeToString(&content);
|
||||
tensorflow::profiler::XSpace xspace;
|
||||
tensorflow::Status status = session_->CollectData(&xspace);
|
||||
session_.reset();
|
||||
tensorflow::profiler::ConvertXSpaceToTraceEventsString(xspace, &content);
|
||||
tensorflow::MaybeRaiseRegisteredFromStatus(status);
|
||||
}
|
||||
// The content is not valid UTF-8, so it must be converted to bytes.
|
||||
|
@ -11,8 +11,8 @@ py_library(
|
||||
srcs_version = "PY2AND3",
|
||||
deps = [
|
||||
":profiler_analysis_pb2_grpc",
|
||||
"//tensorflow/core:protos_all_py",
|
||||
"//tensorflow/core/profiler:profiler_analysis_proto_py",
|
||||
"//tensorflow/core/profiler/protobuf:trace_events_proto_py",
|
||||
"//tensorflow/python:util",
|
||||
],
|
||||
)
|
||||
|
@ -20,7 +20,7 @@ from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
# pylint: disable=wildcard-import,unused-import
|
||||
from tensorflow.core.protobuf.trace_events_pb2 import *
|
||||
from tensorflow.core.profiler.protobuf.trace_events_pb2 import *
|
||||
from tensorflow.core.profiler.profiler_analysis_pb2 import *
|
||||
# pylint: enable=wildcard-import,unused-import
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user