1 /* Copyright 2020 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_PROFILER_CONVERT_XPLANE_TO_TF_DATA_STATS_H_ 17 #define TENSORFLOW_CORE_PROFILER_CONVERT_XPLANE_TO_TF_DATA_STATS_H_ 18 19 #include "absl/strings/string_view.h" 20 #include "tensorflow/core/platform/macros.h" 21 #include "tensorflow/core/platform/types.h" 22 #include "tensorflow/core/profiler/protobuf/tf_data_stats.pb.h" 23 #include "tensorflow/core/profiler/protobuf/xplane.pb.h" 24 25 namespace tensorflow { 26 namespace profiler { 27 28 TF_CONST_INIT extern const int64 kSlowCallThresholdPs; 29 30 enum class BottleneckType { 31 kSlowSource, 32 kSlowDataService, 33 kSlowRemoteSource, 34 kSlowTransformationWithParallelVersion, 35 kSlowTransformationWithoutParallelVersion, 36 kOther, 37 }; 38 39 BottleneckType GetBottleneckType(absl::string_view bottleneck_iterator_name); 40 41 class CombinedTfDataStatsBuilder { 42 public: 43 explicit CombinedTfDataStatsBuilder( 44 CombinedTfDataStats* combined_tf_data_stats, 45 bool generate_suggestion = true) combined_tf_data_stats_(combined_tf_data_stats)46 : combined_tf_data_stats_(combined_tf_data_stats), 47 generate_suggestion_(generate_suggestion) {} 48 49 void Add(absl::string_view host_name, XPlane* host_plane); 50 51 // Finalizes by populating TfDataBottleneckAnalysis. 52 void Finalize(); 53 54 private: 55 CombinedTfDataStats* combined_tf_data_stats_; 56 bool generate_suggestion_; 57 }; 58 59 } // namespace profiler 60 } // namespace tensorflow 61 62 #endif // TENSORFLOW_CORE_PROFILER_CONVERT_XPLANE_TO_TF_DATA_STATS_H_ 63