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 1.9 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. private:
  49. bool ParseDumpConfig(const std::string &dump_config_file);
  50. bool IsConfigExist(const nlohmann::json &dumpSettings);
  51. bool IsConfigValid(const nlohmann::json &dumpSettings);
  52. };
  53. using DumpConfPtr = std::shared_ptr<Dump>;
  54. } // namespace mindspore
  55. #endif // MINDSPORE_E2E_DUMP_H