| @@ -62,7 +62,7 @@ static bool CheckStridedSlice(const CNodePtr &cnode) { | |||||
| MS_LOG(EXCEPTION) << "For 'StrideSlice', the first input node should be a 'ValueNode' or a 'CNode', but got " | MS_LOG(EXCEPTION) << "For 'StrideSlice', the first input node should be a 'ValueNode' or a 'CNode', but got " | ||||
| << input->ToString(); | << input->ToString(); | ||||
| } | } | ||||
| int base_number = 2; | |||||
| const int base_number = 2; | |||||
| if (shrink_axis_mask >= std::pow<int, int>(base_number, input_dims - 1) && input_dims > 1) { | if (shrink_axis_mask >= std::pow<int, int>(base_number, input_dims - 1) && input_dims > 1) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| @@ -34,7 +34,7 @@ uint32_t ConvertPhysicalDeviceId(uint32_t device_id) { | |||||
| return kernel_runtime->device_id(); | return kernel_runtime->device_id(); | ||||
| } | } | ||||
| std::string GenerateDumpPath(uint32_t *device_id) { | |||||
| std::string GenerateDumpPath(const uint32_t *device_id) { | |||||
| auto &dump_json_parser = DumpJsonParser::GetInstance(); | auto &dump_json_parser = DumpJsonParser::GetInstance(); | ||||
| std::string net_name = dump_json_parser.net_name(); | std::string net_name = dump_json_parser.net_name(); | ||||
| std::string iterator = std::to_string(dump_json_parser.cur_dump_iter()); | std::string iterator = std::to_string(dump_json_parser.cur_dump_iter()); | ||||
| @@ -27,7 +27,7 @@ namespace mindspore { | |||||
| static const size_t PARAMETER_OUTPUT_INDEX = 0; | static const size_t PARAMETER_OUTPUT_INDEX = 0; | ||||
| static const size_t VALUE_NODE_OUTPUT_INDEX = 0; | static const size_t VALUE_NODE_OUTPUT_INDEX = 0; | ||||
| std::string GenerateDumpPath(uint32_t *device_id = nullptr); | |||||
| std::string GenerateDumpPath(const uint32_t *device_id = nullptr); | |||||
| void GetFileKernelName(NotNull<std::string *> kernel_name); | void GetFileKernelName(NotNull<std::string *> kernel_name); | ||||
| @@ -53,7 +53,7 @@ void E2eDump::DumpGPUMemToFile(const std::string &file_path, const std::string & | |||||
| #endif | #endif | ||||
| } | } | ||||
| void E2eDump::DumpOutput(const session::KernelGraph *graph, const std::string &dump_path, Debugger *debugger) { | |||||
| void E2eDump::DumpOutput(const session::KernelGraph *graph, const std::string &dump_path, const Debugger *debugger) { | |||||
| MS_EXCEPTION_IF_NULL(graph); | MS_EXCEPTION_IF_NULL(graph); | ||||
| auto &dump_json_parser = DumpJsonParser::GetInstance(); | auto &dump_json_parser = DumpJsonParser::GetInstance(); | ||||
| if (!dump_json_parser.OutputNeedDump()) { | if (!dump_json_parser.OutputNeedDump()) { | ||||
| @@ -74,7 +74,7 @@ void E2eDump::DumpOutput(const session::KernelGraph *graph, const std::string &d | |||||
| } | } | ||||
| void E2eDump::DumpOutputImpl(const CNodePtr &node, bool trans_flag, const std::string &dump_path, | void E2eDump::DumpOutputImpl(const CNodePtr &node, bool trans_flag, const std::string &dump_path, | ||||
| std::string *kernel_name, Debugger *debugger) { | |||||
| std::string *kernel_name, const Debugger *debugger) { | |||||
| MS_EXCEPTION_IF_NULL(node); | MS_EXCEPTION_IF_NULL(node); | ||||
| GetFileKernelName(NOT_NULL(kernel_name)); | GetFileKernelName(NOT_NULL(kernel_name)); | ||||
| auto output_size = AnfAlgo::GetOutputTensorNum(node); | auto output_size = AnfAlgo::GetOutputTensorNum(node); | ||||
| @@ -96,7 +96,7 @@ void E2eDump::DumpOutputImpl(const CNodePtr &node, bool trans_flag, const std::s | |||||
| } | } | ||||
| } | } | ||||
| void E2eDump::DumpInput(const session::KernelGraph *graph, const std::string &dump_path, Debugger *debugger) { | |||||
| void E2eDump::DumpInput(const session::KernelGraph *graph, const std::string &dump_path, const Debugger *debugger) { | |||||
| MS_EXCEPTION_IF_NULL(graph); | MS_EXCEPTION_IF_NULL(graph); | ||||
| auto &dump_json_parser = DumpJsonParser::GetInstance(); | auto &dump_json_parser = DumpJsonParser::GetInstance(); | ||||
| if (!dump_json_parser.InputNeedDump()) { | if (!dump_json_parser.InputNeedDump()) { | ||||
| @@ -117,7 +117,7 @@ void E2eDump::DumpInput(const session::KernelGraph *graph, const std::string &du | |||||
| } | } | ||||
| void E2eDump::DumpInputImpl(const CNodePtr &node, bool trans_flag, const std::string &dump_path, | void E2eDump::DumpInputImpl(const CNodePtr &node, bool trans_flag, const std::string &dump_path, | ||||
| std::string *kernel_name, Debugger *debugger) { | |||||
| std::string *kernel_name, const Debugger *debugger) { | |||||
| MS_EXCEPTION_IF_NULL(node); | MS_EXCEPTION_IF_NULL(node); | ||||
| GetFileKernelName(NOT_NULL(kernel_name)); | GetFileKernelName(NOT_NULL(kernel_name)); | ||||
| auto input_size = AnfAlgo::GetInputTensorNum(node); | auto input_size = AnfAlgo::GetInputTensorNum(node); | ||||
| @@ -155,7 +155,7 @@ void E2eDump::DumpInputImpl(const CNodePtr &node, bool trans_flag, const std::st | |||||
| } | } | ||||
| void E2eDump::DumpSingleAnfNode(const AnfNodePtr &anf_node, const size_t output_index, const std::string &dump_path, | void E2eDump::DumpSingleAnfNode(const AnfNodePtr &anf_node, const size_t output_index, const std::string &dump_path, | ||||
| bool trans_flag, std::map<std::string, size_t> *const_map, Debugger *debugger) { | |||||
| bool trans_flag, std::map<std::string, size_t> *const_map, const Debugger *debugger) { | |||||
| MS_EXCEPTION_IF_NULL(anf_node); | MS_EXCEPTION_IF_NULL(anf_node); | ||||
| auto &dump_json_parser = DumpJsonParser::GetInstance(); | auto &dump_json_parser = DumpJsonParser::GetInstance(); | ||||
| if (!anf_node->isa<Parameter>() && !anf_node->isa<ValueNode>()) { | if (!anf_node->isa<Parameter>() && !anf_node->isa<ValueNode>()) { | ||||
| @@ -195,7 +195,7 @@ void E2eDump::DumpSingleAnfNode(const AnfNodePtr &anf_node, const size_t output_ | |||||
| } | } | ||||
| void E2eDump::DumpParametersAndConst(const session::KernelGraph *graph, const std::string &dump_path, | void E2eDump::DumpParametersAndConst(const session::KernelGraph *graph, const std::string &dump_path, | ||||
| Debugger *debugger) { | |||||
| const Debugger *debugger) { | |||||
| MS_EXCEPTION_IF_NULL(graph); | MS_EXCEPTION_IF_NULL(graph); | ||||
| auto &dump_json_parser = DumpJsonParser::GetInstance(); | auto &dump_json_parser = DumpJsonParser::GetInstance(); | ||||
| MS_LOG(INFO) << "Start e2e dump parameters and Const values"; | MS_LOG(INFO) << "Start e2e dump parameters and Const values"; | ||||
| @@ -215,7 +215,7 @@ void E2eDump::DumpParametersAndConst(const session::KernelGraph *graph, const st | |||||
| } | } | ||||
| } | } | ||||
| bool E2eDump::DumpData(const session::KernelGraph *graph, uint32_t device_id, Debugger *debugger) { | |||||
| bool E2eDump::DumpData(const session::KernelGraph *graph, uint32_t device_id, const Debugger *debugger) { | |||||
| MS_EXCEPTION_IF_NULL(graph); | MS_EXCEPTION_IF_NULL(graph); | ||||
| auto &dump_json_parser = DumpJsonParser::GetInstance(); | auto &dump_json_parser = DumpJsonParser::GetInstance(); | ||||
| if (starting_graph_id == INT32_MAX) { | if (starting_graph_id == INT32_MAX) { | ||||
| @@ -33,26 +33,26 @@ class E2eDump { | |||||
| public: | public: | ||||
| E2eDump() = default; | E2eDump() = default; | ||||
| ~E2eDump() = default; | ~E2eDump() = default; | ||||
| static bool DumpData(const session::KernelGraph *graph, uint32_t device_id, Debugger *debugger = nullptr); | |||||
| static bool DumpData(const session::KernelGraph *graph, uint32_t device_id, const Debugger *debugger = nullptr); | |||||
| // Dump data when task error. | // Dump data when task error. | ||||
| static void DumpInputImpl(const CNodePtr &node, bool trans_flag, const std::string &dump_path, | static void DumpInputImpl(const CNodePtr &node, bool trans_flag, const std::string &dump_path, | ||||
| std::string *kernel_name, Debugger *debugger); | |||||
| std::string *kernel_name, const Debugger *debugger); | |||||
| static void DumpOutputImpl(const CNodePtr &node, bool trans_flag, const std::string &dump_path, | static void DumpOutputImpl(const CNodePtr &node, bool trans_flag, const std::string &dump_path, | ||||
| std::string *kernel_name, Debugger *debugger); | |||||
| std::string *kernel_name, const Debugger *debugger); | |||||
| private: | private: | ||||
| static void DumpOutput(const session::KernelGraph *graph, const std::string &dump_path, Debugger *debugger); | |||||
| static void DumpInput(const session::KernelGraph *graph, const std::string &dump_path, Debugger *debugger); | |||||
| static void DumpOutput(const session::KernelGraph *graph, const std::string &dump_path, const Debugger *debugger); | |||||
| static void DumpInput(const session::KernelGraph *graph, const std::string &dump_path, const Debugger *debugger); | |||||
| static void DumpParametersAndConst(const session::KernelGraph *graph, const std::string &dump_path, | static void DumpParametersAndConst(const session::KernelGraph *graph, const std::string &dump_path, | ||||
| Debugger *debugger); | |||||
| const Debugger *debugger); | |||||
| static void DumpGPUMemToFile(const std::string &file_path, const std::string &original_kernel_name, | static void DumpGPUMemToFile(const std::string &file_path, const std::string &original_kernel_name, | ||||
| NotNull<const device::DeviceAddress *> addr, const ShapeVector &int_shapes, | NotNull<const device::DeviceAddress *> addr, const ShapeVector &int_shapes, | ||||
| const TypeId &type, bool trans_flag, size_t slot, const Debugger *debugger); | const TypeId &type, bool trans_flag, size_t slot, const Debugger *debugger); | ||||
| static bool IsDeviceTargetGPU(); | static bool IsDeviceTargetGPU(); | ||||
| static void DumpSingleAnfNode(const AnfNodePtr &anf_node, const size_t output_index, const std::string &dump_path, | static void DumpSingleAnfNode(const AnfNodePtr &anf_node, const size_t output_index, const std::string &dump_path, | ||||
| bool trans_flag, std::map<std::string, size_t> *const_map, Debugger *debugger); | |||||
| bool trans_flag, std::map<std::string, size_t> *const_map, const Debugger *debugger); | |||||
| inline static unsigned int starting_graph_id = INT32_MAX; | inline static unsigned int starting_graph_id = INT32_MAX; | ||||
| }; | }; | ||||
| } // namespace mindspore | } // namespace mindspore | ||||
| @@ -40,13 +40,7 @@ bool CPUDeviceAddress::DumpMemToFile(const std::string &filepath, const std::str | |||||
| std::string file_extension = ".bin"; | std::string file_extension = ".bin"; | ||||
| std::string path = filepath + '_' + shape + '_' + TypeIdToType(type_id_)->ToString() + '_' + format_ + file_extension; | std::string path = filepath + '_' + shape + '_' + TypeIdToType(type_id_)->ToString() + '_' + format_ + file_extension; | ||||
| MS_LOG(DEBUG) << "E2E Dump path is " << path; | MS_LOG(DEBUG) << "E2E Dump path is " << path; | ||||
| auto host_tmp = std::vector<uint8_t>(size_); | |||||
| auto ret_code = memcpy_s(host_tmp.data(), size_, ptr_, size_); | |||||
| if (ret_code != EOK) { | |||||
| MS_LOG(ERROR) << "Failed to copy tensor!"; | |||||
| return ret; | |||||
| } | |||||
| ret = DumpJsonParser::DumpToFile(path, host_tmp.data(), size_); | |||||
| ret = DumpJsonParser::DumpToFile(path, ptr_, size_); | |||||
| return ret; | return ret; | ||||
| } | } | ||||