1 /* Copyright 2016 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 #ifndef TENSORFLOW_CORE_PROFILER_LIB_PROFILER_INTERFACE_H_ 16 #define TENSORFLOW_CORE_PROFILER_LIB_PROFILER_INTERFACE_H_ 17 18 #include "tensorflow/core/platform/status.h" 19 #include "tensorflow/core/profiler/protobuf/xplane.pb.h" 20 #include "tensorflow/core/protobuf/config.pb.h" 21 22 namespace tensorflow { 23 namespace profiler { 24 25 // Interface for tensorflow profiler plugins. 26 // 27 // ProfileSession calls each of these methods at most once per instance, and 28 // implementations can rely on that guarantee for simplicity. 29 // 30 // Thread-safety: Implementations are only required to be go/thread-compatible. 31 // ProfileSession is go/thread-safe and synchronizes access to ProfilerInterface 32 // instances. 33 class ProfilerInterface { 34 public: 35 virtual ~ProfilerInterface() = default; 36 37 // Starts profiling. 38 virtual Status Start() = 0; 39 40 // Stops profiling. 41 virtual Status Stop() = 0; 42 43 // Saves collected profile data into run_metadata. 44 // After this or the overload below are called once, subsequent calls might 45 // return empty data. 46 virtual Status CollectData(RunMetadata* run_metadata) = 0; 47 48 // Saves collected profile data into XSpace. 49 // After this or the overload above are called once, subsequent calls might 50 // return empty data. 51 virtual Status CollectData(XSpace* space) = 0; 52 }; 53 54 } // namespace profiler 55 } // namespace tensorflow 56 57 #endif // TENSORFLOW_CORE_PROFILER_LIB_PROFILER_INTERFACE_H_ 58