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_INTERNAL_PROFILER_INTERFACE_H_ 16 #define TENSORFLOW_CORE_PROFILER_INTERNAL_PROFILER_INTERFACE_H_ 17 18 #include "tensorflow/core/lib/core/status.h" 19 #include "tensorflow/core/protobuf/config.pb.h" 20 21 namespace tensorflow { 22 namespace profiler { 23 24 // Interface for tensorflow profiler plugins. 25 // 26 // ProfileSession calls each of these methods at most once per instance, and 27 // implementations can rely on that guarantee for simplicity. 28 // 29 // Thread-safety: Implementations are only required to be go/thread-compatible. 30 // ProfileSession is go/thread-safe and synchronizes access to ProfilerInterface 31 // instances. 32 class ProfilerInterface { 33 public: 34 virtual ~ProfilerInterface() = default; 35 36 // Starts profiling. 37 virtual Status Start() = 0; 38 39 // Stops profiling. 40 virtual Status Stop() = 0; 41 42 // Moves collected profile data into run_metadata. 43 virtual Status CollectData(RunMetadata* run_metadata) = 0; 44 }; 45 46 } // namespace profiler 47 } // namespace tensorflow 48 49 #endif // TENSORFLOW_CORE_PROFILER_INTERNAL_PROFILER_INTERFACE_H_ 50