1 /* Copyright 2019 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_COMPILER_XLA_SERVICE_COMPILATION_STATS_H_ 17 #define TENSORFLOW_COMPILER_XLA_SERVICE_COMPILATION_STATS_H_ 18 19 #include <memory> 20 #include <string> 21 22 #include "absl/strings/str_format.h" 23 24 namespace xla { 25 26 // This class is used to collect information about HLO passes and print some 27 // statistics at the end of compilation. From HloPassPipeline, we call StartPass 28 // before the execution of a pass, and EndPass after. Currently, we only collect 29 // timing information and how many times each pass was run. In the future, we 30 // can add more things, such as the size of the HLO graph after each pass. 31 class CompilationStats { 32 public: 33 virtual ~CompilationStats() = default; 34 35 static std::unique_ptr<CompilationStats> MakeNoopStats(); 36 37 static std::unique_ptr<CompilationStats> MakeStats(); 38 39 virtual void StartPass(absl::string_view pass_name) = 0; 40 41 virtual void EndPass(absl::string_view pass_name) = 0; 42 43 virtual void CompilationReport() = 0; 44 }; 45 46 } // namespace xla 47 48 #endif // TENSORFLOW_COMPILER_XLA_SERVICE_COMPILATION_STATS_H_ 49