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 16 #ifndef TENSORFLOW_CORE_COMMON_RUNTIME_STATS_PUBLISHER_INTERFACE_H_ 17 #define TENSORFLOW_CORE_COMMON_RUNTIME_STATS_PUBLISHER_INTERFACE_H_ 18 19 #include "tensorflow/core/common_runtime/build_graph_options.h" 20 #include "tensorflow/core/common_runtime/profile_handler.h" 21 #include "tensorflow/core/protobuf/config.pb.h" 22 #include "tensorflow/core/public/session_options.h" 23 24 namespace tensorflow { 25 26 // StatsPublisherInterface describes objects that publish information exported 27 // by Sessions. 28 // NOTE: This interface is experimental and subject to change. 29 // Implementations must be thread-safe. 30 class StatsPublisherInterface { 31 public: 32 // PublishStatsProto publishes step_stats. 33 // When PublishStatsProto is called multiple times, only the step_stats 34 // corresponding to the latest call will be published. 35 virtual void PublishStatsProto(const StepStats& step_stats) = 0; 36 37 // PublishGraphProto publishes the graph_defs corresponding to each partition 38 // in the session. 39 // When PublishGraphProto is called multiple times, only the graph_defs 40 // corresponding to the latest call will be published. 41 virtual void PublishGraphProto( 42 const std::vector<const GraphDef*>& graph_defs) = 0; 43 44 // Returns a profile handler for the given step based on the execution_count 45 // and RunOptions. 46 // 47 // This method may return a null pointer, if no handler was created. 48 virtual std::unique_ptr<ProfileHandler> GetProfileHandler( 49 uint64 step, int64 execution_count, const RunOptions& ropts) = 0; 50 ~StatsPublisherInterface()51 virtual ~StatsPublisherInterface() {} 52 }; 53 54 typedef std::function<std::unique_ptr<StatsPublisherInterface>( 55 const string&, const BuildGraphOptions&, const SessionOptions&)> 56 StatsPublisherFactory; 57 58 std::unique_ptr<StatsPublisherInterface> CreateNoOpStatsPublisher( 59 const string& session, const BuildGraphOptions& bopts, 60 const SessionOptions& sopts); 61 62 } // namespace tensorflow 63 64 #endif // TENSORFLOW_CORE_COMMON_RUNTIME_STATS_PUBLISHER_INTERFACE_H_ 65