diff --git a/mindspore/ccsrc/backend/kernel_compiler/tbe/tbe_kernel_select/tbe_property_checker.cc b/mindspore/ccsrc/backend/kernel_compiler/tbe/tbe_kernel_select/tbe_property_checker.cc index 5159588b3e..c835ed14ec 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/tbe/tbe_kernel_select/tbe_property_checker.cc +++ b/mindspore/ccsrc/backend/kernel_compiler/tbe/tbe_kernel_select/tbe_property_checker.cc @@ -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 " << input->ToString(); } - int base_number = 2; + const int base_number = 2; if (shrink_axis_mask >= std::pow(base_number, input_dims - 1) && input_dims > 1) { return false; } diff --git a/mindspore/ccsrc/debug/data_dump/dump_utils.cc b/mindspore/ccsrc/debug/data_dump/dump_utils.cc index c0eb88dadb..c3dfabcbbf 100644 --- a/mindspore/ccsrc/debug/data_dump/dump_utils.cc +++ b/mindspore/ccsrc/debug/data_dump/dump_utils.cc @@ -34,7 +34,7 @@ uint32_t ConvertPhysicalDeviceId(uint32_t 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(); std::string net_name = dump_json_parser.net_name(); std::string iterator = std::to_string(dump_json_parser.cur_dump_iter()); diff --git a/mindspore/ccsrc/debug/data_dump/dump_utils.h b/mindspore/ccsrc/debug/data_dump/dump_utils.h index dbbc2b061b..47f04cb16b 100644 --- a/mindspore/ccsrc/debug/data_dump/dump_utils.h +++ b/mindspore/ccsrc/debug/data_dump/dump_utils.h @@ -27,7 +27,7 @@ namespace mindspore { static const size_t PARAMETER_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 kernel_name); diff --git a/mindspore/ccsrc/debug/data_dump/e2e_dump.cc b/mindspore/ccsrc/debug/data_dump/e2e_dump.cc index aedbc3acdf..3f24b56ae6 100644 --- a/mindspore/ccsrc/debug/data_dump/e2e_dump.cc +++ b/mindspore/ccsrc/debug/data_dump/e2e_dump.cc @@ -53,7 +53,7 @@ void E2eDump::DumpGPUMemToFile(const std::string &file_path, const std::string & #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); auto &dump_json_parser = DumpJsonParser::GetInstance(); 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, - std::string *kernel_name, Debugger *debugger) { + std::string *kernel_name, const Debugger *debugger) { MS_EXCEPTION_IF_NULL(node); GetFileKernelName(NOT_NULL(kernel_name)); 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); auto &dump_json_parser = DumpJsonParser::GetInstance(); 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, - std::string *kernel_name, Debugger *debugger) { + std::string *kernel_name, const Debugger *debugger) { MS_EXCEPTION_IF_NULL(node); GetFileKernelName(NOT_NULL(kernel_name)); 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, - bool trans_flag, std::map *const_map, Debugger *debugger) { + bool trans_flag, std::map *const_map, const Debugger *debugger) { MS_EXCEPTION_IF_NULL(anf_node); auto &dump_json_parser = DumpJsonParser::GetInstance(); if (!anf_node->isa() && !anf_node->isa()) { @@ -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, - Debugger *debugger) { + const Debugger *debugger) { MS_EXCEPTION_IF_NULL(graph); auto &dump_json_parser = DumpJsonParser::GetInstance(); 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); auto &dump_json_parser = DumpJsonParser::GetInstance(); if (starting_graph_id == INT32_MAX) { diff --git a/mindspore/ccsrc/debug/data_dump/e2e_dump.h b/mindspore/ccsrc/debug/data_dump/e2e_dump.h index 670d7c31f3..372232eaea 100644 --- a/mindspore/ccsrc/debug/data_dump/e2e_dump.h +++ b/mindspore/ccsrc/debug/data_dump/e2e_dump.h @@ -33,26 +33,26 @@ class E2eDump { public: 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. 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, - std::string *kernel_name, Debugger *debugger); + std::string *kernel_name, const Debugger *debugger); 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, - Debugger *debugger); + const Debugger *debugger); static void DumpGPUMemToFile(const std::string &file_path, const std::string &original_kernel_name, NotNull addr, const ShapeVector &int_shapes, const TypeId &type, bool trans_flag, size_t slot, const Debugger *debugger); static bool IsDeviceTargetGPU(); static void DumpSingleAnfNode(const AnfNodePtr &anf_node, const size_t output_index, const std::string &dump_path, - bool trans_flag, std::map *const_map, Debugger *debugger); + bool trans_flag, std::map *const_map, const Debugger *debugger); inline static unsigned int starting_graph_id = INT32_MAX; }; } // namespace mindspore diff --git a/mindspore/ccsrc/runtime/device/cpu/cpu_device_address.cc b/mindspore/ccsrc/runtime/device/cpu/cpu_device_address.cc index 1508d6de11..ba6cafa876 100644 --- a/mindspore/ccsrc/runtime/device/cpu/cpu_device_address.cc +++ b/mindspore/ccsrc/runtime/device/cpu/cpu_device_address.cc @@ -40,13 +40,7 @@ bool CPUDeviceAddress::DumpMemToFile(const std::string &filepath, const std::str std::string file_extension = ".bin"; std::string path = filepath + '_' + shape + '_' + TypeIdToType(type_id_)->ToString() + '_' + format_ + file_extension; MS_LOG(DEBUG) << "E2E Dump path is " << path; - auto host_tmp = std::vector(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; }