util.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*************************************************************************
  2. * Copyright (C) [2019] by Cambricon, Inc. All rights reserved
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * The above copyright notice and this permission notice shall be included in
  11. * all copies or substantial portions of the Software.
  12. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  13. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  15. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18. * THE SOFTWARE.
  19. *************************************************************************/
  20. #ifndef SAMPLES_COMMON_UTIL_HPP_
  21. #define SAMPLES_COMMON_UTIL_HPP_
  22. #define PATH_MAX_LENGTH 1024
  23. #include <profiler/profile.hpp>
  24. #include <iostream>
  25. #include <list>
  26. #include <string>
  27. #include <vector>
  28. std::vector<std::string> LoadLabels(const std::string &filename);
  29. bool CheckDir(const std::string &path, std::string *estr);
  30. std::string GetExePath();
  31. void CheckExePath(const std::string &path);
  32. std::list<std::string> ReadFileList(const std::string &list);
  33. std::list<std::string> GetFileNameFromDir(const std::string &dir, const char *filter);
  34. size_t GetFileSize(const std::string &filename);
  35. void PrintPipelinePerformance(const std::string& prefix_str, const cnstream::PipelineProfile& profile);
  36. #endif // SAMPLES_COMMON_UTIL_HPP_