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

4 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /**
  2. * Copyright 2020-2021 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_DATA_DUMP_E_2_E_DUMP_H_
  17. #define MINDSPORE_MINDSPORE_CCSRC_DEBUG_DATA_DUMP_E_2_E_DUMP_H_
  18. #include <dirent.h>
  19. #include <stdlib.h>
  20. #include <map>
  21. #include <string>
  22. #include "backend/session/kernel_graph.h"
  23. #include "runtime/device/device_address.h"
  24. #include "debug/data_dump/dump_json_parser.h"
  25. #include "debug/data_dump/dump_utils.h"
  26. #ifndef ENABLE_DEBUGGER
  27. class Debugger;
  28. #endif
  29. namespace mindspore {
  30. class E2eDump {
  31. public:
  32. E2eDump() = default;
  33. ~E2eDump() = default;
  34. static void DumpSetup(const session::KernelGraph *graph, uint32_t rank_id);
  35. static void DumpData(const session::KernelGraph *graph, uint32_t rank_id, const Debugger *debugger = nullptr);
  36. static bool DumpParametersAndConstData(const session::KernelGraph *graph, uint32_t rank_id, const Debugger *debugger);
  37. static bool DumpSingleNodeData(const CNodePtr &node, uint32_t graph_id, uint32_t rank_id,
  38. const Debugger *debugger = nullptr);
  39. static bool isDatasetGraph(const session::KernelGraph *graph);
  40. // Dump data when task error.
  41. static void DumpInputImpl(const CNodePtr &node, bool trans_flag, const std::string &dump_path,
  42. std::string *kernel_name, const Debugger *debugger);
  43. static void DumpOutputImpl(const CNodePtr &node, bool trans_flag, const std::string &dump_path,
  44. std::string *kernel_name, const Debugger *debugger);
  45. static bool DumpDirExists(const std::string &dump_path);
  46. static bool MoveDumpFiles(const std::string &first_dir, const std::string &second_dir);
  47. static bool DeleteDirContents(const std::string &dir_path);
  48. private:
  49. static void DumpOutput(const session::KernelGraph *graph, const std::string &dump_path, const Debugger *debugger);
  50. static void DumpOutputSingleNode(const CNodePtr &node, const std::string &dump_path, const Debugger *debugger);
  51. static void DumpInput(const session::KernelGraph *graph, const std::string &dump_path, const Debugger *debugger);
  52. static void DumpInputSingleNode(const CNodePtr &node, const std::string &dump_path, const Debugger *debugger);
  53. static void DumpParametersAndConst(const session::KernelGraph *graph, const std::string &dump_path,
  54. const Debugger *debugger);
  55. static void DumpGPUMemToFile(const std::string &file_path, const std::string &original_kernel_name,
  56. const device::DeviceAddress &addr, const ShapeVector &int_shapes,
  57. const TypeId &host_type, const TypeId &device_type, bool trans_flag, size_t slot,
  58. const Debugger *debugger);
  59. static bool IsDeviceTargetGPU();
  60. static void DumpSingleAnfNode(const AnfNodePtr &anf_node, const size_t output_index, const std::string &dump_path,
  61. bool trans_flag, std::map<std::string, size_t> *const_map, const Debugger *debugger);
  62. inline static unsigned int starting_graph_id = INT32_MAX;
  63. };
  64. } // namespace mindspore
  65. #endif // MINDSPORE_MINDSPORE_CCSRC_DEBUG_DATA_DUMP_E_2_E_DUMP_UTIL_H_