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_PROFILE_HANDLER_H_ 17 #define TENSORFLOW_CORE_COMMON_RUNTIME_PROFILE_HANDLER_H_ 18 19 #include "tensorflow/core/framework/step_stats.pb.h" 20 #include "tensorflow/core/graph/types.h" 21 #include "tensorflow/core/lib/core/status.h" 22 #include "tensorflow/core/lib/core/stringpiece.h" 23 24 namespace tensorflow { 25 26 // A profile handler collects event stats from a running step. 27 class ProfileHandler { 28 public: ProfileHandler()29 ProfileHandler() {} ~ProfileHandler()30 virtual ~ProfileHandler() {} 31 32 // Records that a single Op was executed in the current step. 33 // 34 // Implementations of this method must be thread-safe. 35 // 36 // Args: 37 // - device: Device on which the Op was executed. 38 // - stats: Statistics of node execution timing. 39 // - is_copy: True if the op was a copy, send or recv. 40 // - label: Extra content for timeline click text. 41 // - op_type: String name of the Op. 42 // - details: Main content for timeline click text. 43 virtual void RecordOneOp(const string& device, const NodeExecStats& stats, 44 bool is_copy, StringPiece label, StringPiece op_type, 45 StringPiece details) = 0; 46 47 // Records that the current step finished. 48 // 49 // Implementations of this method need not be thread-safe. 50 // 51 // Args: 52 // - start_time: The time at which the step started. 53 // - finish_time: The time at which the step finished. 54 // - cleanup_time: The time at which cleanup for the step finished. 55 // - total_runops: The number of ops that ran during this step. 56 // - final_status: The status that this step finished with. 57 virtual void StepDone(Microseconds start_time, Microseconds finish_time, 58 Microseconds cleanup_time, int total_runops, 59 Status final_status) = 0; 60 61 // Returns true if the caller should collect rpc activity. 62 virtual bool should_collect_rpcs() = 0; 63 }; 64 65 } // namespace tensorflow 66 67 #endif // TENSORFLOW_CORE_COMMON_RUNTIME_PROFILE_HANDLER_H_ 68