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.0 kB

5 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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_MINDSPORE_CCSRC_DEBUG_ASYNC_DUMP_JSON_PARE_H_
  17. #define MINDSPORE_MINDSPORE_CCSRC_DEBUG_ASYNC_DUMP_JSON_PARE_H_
  18. #include <string>
  19. #include <set>
  20. #include <mutex>
  21. #include <optional>
  22. #include "nlohmann/json.hpp"
  23. #include "common/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 dump_step() const { return dump_step_; }
  39. const std::set<std::string> &kernel_set() const { return kernel_set_; }
  40. private:
  41. DataDumpParser() = default;
  42. virtual ~DataDumpParser() = default;
  43. DISABLE_COPY_AND_ASSIGN(DataDumpParser);
  44. void ResetParam();
  45. bool IsConfigExist(const nlohmann::json &dump_settings) const;
  46. bool ParseDumpSetting(const nlohmann::json &dump_settings);
  47. std::mutex lock_;
  48. bool enable_{false};
  49. std::string net_name_;
  50. uint32_t dump_mode_{0};
  51. uint32_t dump_step_{0};
  52. std::set<std::string> kernel_set_;
  53. };
  54. } // namespace mindspore
  55. #endif // MINDSPORE_MINDSPORE_CCSRC_DEBUG_ASYNC_DUMP_JSON_PARE_H_