You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

e2e_dump.h 2.1 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /**
  2. * Copyright 2019 Huawei Technologies Co., Ltd
  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. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef MINDSPORE_E2E_DUMP_H
  17. #define MINDSPORE_E2E_DUMP_H
  18. #include <stdint.h>
  19. #include <string>
  20. #include <vector>
  21. #include <iostream>
  22. #include <memory>
  23. #include <nlohmann/json.hpp>
  24. namespace mindspore {
  25. class Dump {
  26. public:
  27. Dump();
  28. ~Dump() = default;
  29. bool dump_enable() const { return dump_enable_; }
  30. bool trans_flag() const { return trans_flag_; }
  31. std::string dump_path() const { return dump_path_; }
  32. std::string dump_net_name() const { return dump_net_name_; }
  33. uint32_t dump_iter() const { return dump_iter_; }
  34. void UpdataCurIter() { cur_iter_++; }
  35. uint32_t cur_iter() const { return cur_iter_; }
  36. bool IsKernelNeedDump(const std::string &kernel_name);
  37. bool SetDumpConfFromJsonFile();
  38. static bool DumpToFile(const std::string &filename, const void *data, size_t len);
  39. protected:
  40. bool dump_enable_;
  41. bool trans_flag_;
  42. std::string dump_path_;
  43. std::string dump_net_name_;
  44. uint32_t dump_mode_;
  45. uint32_t dump_iter_;
  46. uint32_t cur_iter_;
  47. std::vector<std::string> dump_kernels_;
  48. static bool GetRealPath(const std::string &inpath, std::string *outpath);
  49. static bool CreateNotExistDirs(const std::string &path);
  50. private:
  51. bool ParseDumpConfig(const std::string &dump_config_file);
  52. bool IsConfigExist(const nlohmann::json &dumpSettings);
  53. bool IsConfigValid(const nlohmann::json &dumpSettings);
  54. };
  55. using DumpConfPtr = std::shared_ptr<Dump>;
  56. } // namespace mindspore
  57. #endif // MINDSPORE_E2E_DUMP_H