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
5 years ago
5 years ago
5 years ago
5 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 "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. void MatchKernel(const std::string &kernel_name);
  40. void PrintUnusedKernel();
  41. private:
  42. DataDumpParser() = default;
  43. virtual ~DataDumpParser() = default;
  44. DISABLE_COPY_AND_ASSIGN(DataDumpParser);
  45. void ResetParam();
  46. bool IsConfigExist(const nlohmann::json &dump_settings) const;
  47. bool ParseDumpSetting(const nlohmann::json &dump_settings);
  48. std::mutex lock_;
  49. bool enable_{false};
  50. std::string net_name_;
  51. uint32_t dump_mode_{0};
  52. uint32_t dump_step_{0};
  53. std::map<std::string, uint32_t> kernel_map_;
  54. };
  55. } // namespace mindspore
  56. #endif // MINDSPORE_CCSRC_DEBUG_ASYNC_DUMP_JSON_PARE_H_