1 /* Copyright 2017 The TensorFlow Authors All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7     http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 // GRPC client to perform on-demand profiling
16 
17 #ifndef TENSORFLOW_CORE_PROFILER_RPC_CLIENT_CAPTURE_PROFILE_H_
18 #define TENSORFLOW_CORE_PROFILER_RPC_CLIENT_CAPTURE_PROFILE_H_
19 
20 #include <string>
21 
22 #include "tensorflow/core/platform/status.h"
23 #include "tensorflow/core/profiler/profiler_options.pb.h"
24 #include "tensorflow/core/profiler/profiler_service.pb.h"
25 #include "tensorflow/core/profiler/protobuf/xplane.pb.h"
26 
27 namespace tensorflow {
28 namespace profiler {
29 
30 // Convert XSpace to tool data and saves under <logdir>/plugins/profile/.
31 Status ExportToTensorBoard(const XSpace& xspace, const std::string& logdir);
32 
33 // Collects one sample of monitoring profile and shows user-friendly metrics.
34 // If timestamp flag is true, timestamp will be displayed in "%H:%M:%S" format.
35 Status Monitor(const std::string& service_addr, int duration_ms,
36                int monitoring_level, bool display_timestamp,
37                std::string* result);
38 
39 // Starts tracing on a single or multiple hosts. Each host will save the result
40 // in the given logdir. If no trace was collected, retries tracing for
41 // num_tracing_attempts. Assumes that options have been validated.
42 Status Trace(const std::string& logdir, int num_tracing_attempts,
43              RemoteProfilerSessionManagerOptions& opts,
44              bool is_cloud_tpu_session);
45 
46 }  // namespace profiler
47 }  // namespace tensorflow
48 
49 #endif  // TENSORFLOW_CORE_PROFILER_RPC_CLIENT_CAPTURE_PROFILE_H_
50