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.

data_dump_parser.h 2.2 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /**
  2. * Copyright 2020 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_CCSRC_DEBUG_ASYNC_DUMP_JSON_PARE_H_
  17. #define MINDSPORE_CCSRC_DEBUG_ASYNC_DUMP_JSON_PARE_H_
  18. #include <string>
  19. #include <map>
  20. #include <mutex>
  21. #include <optional>
  22. #include "nlohmann/json.hpp"
  23. #include "utils/ms_utils.h"
  24. namespace mindspore {
  25. class DataDumpParser {
  26. public:
  27. static DataDumpParser &GetInstance() {
  28. static DataDumpParser instance;
  29. return instance;
  30. }
  31. void ParseDumpConfig();
  32. bool NeedDump(const std::string &op_full_name) const;
  33. bool DumpEnabled() const;
  34. std::optional<std::string> GetDumpPath() const;
  35. bool enable() const { return enable_; }
  36. const std::string &net_name() const { return net_name_; }
  37. uint32_t dump_mode() const { return dump_mode_; }
  38. uint32_t op_debug_mode() const { return op_debug_mode_; }
  39. uint32_t dump_step() const { return dump_step_; }
  40. void MatchKernel(const std::string &kernel_name);
  41. void PrintUnusedKernel();
  42. std::string GetOpOverflowBinPath(uint32_t graph_id, uint32_t device_id) const;
  43. private:
  44. DataDumpParser() = default;
  45. virtual ~DataDumpParser() = default;
  46. DISABLE_COPY_AND_ASSIGN(DataDumpParser);
  47. void ResetParam();
  48. bool IsConfigExist(const nlohmann::json &dump_settings) const;
  49. bool ParseDumpSetting(const nlohmann::json &dump_settings);
  50. void CheckDumpMode(uint32_t dump_mode) const;
  51. void CheckOpDebugMode(uint32_t op_debug_mode) const;
  52. std::mutex lock_;
  53. bool enable_{false};
  54. std::string net_name_;
  55. uint32_t op_debug_mode_{0};
  56. uint32_t dump_mode_{0};
  57. uint32_t dump_step_{0};
  58. std::map<std::string, uint32_t> kernel_map_;
  59. };
  60. } // namespace mindspore
  61. #endif // MINDSPORE_CCSRC_DEBUG_ASYNC_DUMP_JSON_PARE_H_