option.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright (c) 2022 PaddlePaddle 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. #pragma once
  15. namespace ultra_infer {
  16. /** \brief All C++ UltraInfer benchmark profile APIs are defined inside this
  17. * namespace
  18. *
  19. */
  20. namespace benchmark {
  21. // @brief Option object used to control the behavior of the benchmark profiling.
  22. //
  23. struct BenchmarkOption {
  24. int warmup = 50; ///< Warmup for backend inference.
  25. int repeats = 100; ///< Repeats for backend inference.
  26. bool enable_profile = false; ///< Whether to use profile or not.
  27. bool include_h2d_d2h = false; ///< Whether to include time of H2D_D2H for time
  28. ///< of runtime. // NOLINT
  29. friend std::ostream &operator<<(std::ostream &output,
  30. const BenchmarkOption &option) {
  31. if (!option.include_h2d_d2h) {
  32. output << "Running profiling for Runtime "
  33. << "without H2D and D2H, ";
  34. } else {
  35. output << "Running profiling for Runtime "
  36. << "with H2D and D2H, ";
  37. }
  38. output << "Repeats: " << option.repeats << ", "
  39. << "Warmup: " << option.warmup;
  40. return output;
  41. }
  42. };
  43. } // namespace benchmark
  44. } // namespace ultra_infer