Move profiler services behind profiler namespace.

PiperOrigin-RevId: 329046847
Change-Id: Ibc26db95ec314af01c6cf0a9efd4c9a796af66ca
This commit is contained in:
Yi Situ 2020-08-28 18:52:38 -07:00 committed by TensorFlower Gardener
parent c8df8f1471
commit c5aac1cc59
9 changed files with 28 additions and 10 deletions

View File

@ -171,13 +171,13 @@ class TraceMeWrapper : public tensorflow::profiler::TraceMeWrapper {
void BuildProfilerSubmodule(py::module* m) {
py::module profiler =
m->def_submodule("profiler", "TensorFlow profiler integration");
py::class_<tensorflow::ProfilerServer,
std::unique_ptr<tensorflow::ProfilerServer>>
py::class_<tensorflow::profiler::ProfilerServer,
std::unique_ptr<tensorflow::profiler::ProfilerServer>>
profiler_server_class(profiler, "ProfilerServer");
profiler.def(
"start_server",
[](int port) -> std::unique_ptr<tensorflow::ProfilerServer> {
auto server = absl::make_unique<tensorflow::ProfilerServer>();
[](int port) -> std::unique_ptr<tensorflow::profiler::ProfilerServer> {
auto server = absl::make_unique<tensorflow::profiler::ProfilerServer>();
server->StartProfilerServer(port);
return server;
},

View File

@ -82,7 +82,7 @@ int GrpcDataServerBase::BoundPort() { return bound_port(); }
void GrpcDataServerBase::AddProfilerServiceToBuilder(
::grpc::ServerBuilder& builder) {
profiler_service_ = CreateProfilerService();
profiler_service_ = profiler::CreateProfilerService();
builder.RegisterService(profiler_service_.get());
}

View File

@ -249,7 +249,7 @@ Status GrpcServer::Init(const GrpcServerOptions& opts) {
.release();
eager_service_ = new eager::GrpcEagerServiceImpl(&worker_env_, &builder);
profiler_service_ = CreateProfilerService();
profiler_service_ = profiler::CreateProfilerService();
builder.RegisterService(profiler_service_.get());
// extra service:

View File

@ -27,6 +27,7 @@ limitations under the License.
#include "tensorflow/core/profiler/rpc/profiler_service_impl.h"
namespace tensorflow {
namespace profiler {
void ProfilerServer::StartProfilerServer(int32 port) {
std::string server_address = absl::StrCat("[::]:", port);
@ -54,4 +55,5 @@ ProfilerServer::~ProfilerServer() {
}
}
} // namespace profiler
} // namespace tensorflow

View File

@ -22,6 +22,7 @@ limitations under the License.
#include "tensorflow/core/profiler/profiler_service.grpc.pb.h"
namespace tensorflow {
namespace profiler {
class ProfilerServer {
public:
@ -34,6 +35,7 @@ class ProfilerServer {
std::unique_ptr<::grpc::Server> server_;
};
} // namespace profiler
} // namespace tensorflow
#endif // TENSORFLOW_CORE_PROFILER_RPC_PROFILER_SERVER_H_

View File

@ -34,6 +34,7 @@ limitations under the License.
#include "tensorflow/core/profiler/protobuf/xplane.pb.h"
namespace tensorflow {
namespace profiler {
namespace {
const absl::string_view kXPlanePb = "xplane.pb";
@ -115,4 +116,10 @@ std::unique_ptr<grpc::ProfilerService::Service> CreateProfilerService() {
return absl::make_unique<ProfilerServiceImpl>();
}
} // namespace profiler
std::unique_ptr<grpc::ProfilerService::Service> CreateProfilerService() {
return absl::make_unique<profiler::ProfilerServiceImpl>();
}
} // namespace tensorflow

View File

@ -23,6 +23,11 @@ namespace tensorflow {
std::unique_ptr<grpc::ProfilerService::Service> CreateProfilerService();
namespace profiler {
std::unique_ptr<grpc::ProfilerService::Service> CreateProfilerService();
} // namespace profiler
} // namespace tensorflow
#endif // TENSORFLOW_CORE_PROFILER_RPC_PROFILER_SERVICE_IMPL_H_

View File

@ -16,6 +16,7 @@ limitations under the License.
#include <memory>
#include "absl/memory/memory.h"
#include "absl/strings/match.h"
#include "absl/strings/numbers.h"
#include "pybind11/pybind11.h"
#include "pybind11/pytypes.h"
@ -50,7 +51,7 @@ tensorflow::Status ValidateHostPortPair(const std::string& host_port) {
// Must be host:port, port must be a number, host must not contain a '/',
// host also must not be empty.
if (parts.size() != 2 || !absl::SimpleAtoi(parts[1], &port) ||
parts[0].find("/") != std::string::npos || parts[0].empty()) {
absl::StrContains(parts[0], "/") || parts[0].empty()) {
return tensorflow::errors::InvalidArgument(
"Could not interpret \"", host_port, "\" as a host-port pair.");
}
@ -123,7 +124,8 @@ PYBIND11_MODULE(_pywrap_profiler, m) {
.def("export_to_tb", &ProfilerSessionWrapper::ExportToTensorBoard);
m.def("start_server", [](int port) {
auto profiler_server = absl::make_unique<tensorflow::ProfilerServer>();
auto profiler_server =
absl::make_unique<tensorflow::profiler::ProfilerServer>();
profiler_server->StartProfilerServer(port);
// Intentionally release profiler server. Should transfer ownership to
// caller instead.

View File

@ -337,8 +337,8 @@ tensorflow::ProfilerSession::Status
tensorflow::ProfilerSession::~ProfilerSession
[profiler_server_impl] # profiler
tensorflow::ProfilerServer::StartProfilerServer
tensorflow::ProfilerServer::~ProfilerServer
tensorflow::profiler::ProfilerServer::StartProfilerServer
tensorflow::profiler::ProfilerServer::~ProfilerServer
[profiler_client_impl] # profiler
tensorflow::profiler::ProfileGrpc