Merge pull request !3238 from caifubi/clean-codex
pull/3238/MERGE
mindspore-ci-bot 5 years ago committed by Gitee
commit 6b9a61ea82

@ -80,9 +80,9 @@ bool Common::CreateNotExistDirs(const std::string &path) {
char tmp_char = temp_path[i]; char tmp_char = temp_path[i];
temp_path[i] = '\0'; temp_path[i] = '\0';
std::string path_handle(temp_path); std::string path_handle(temp_path);
if (!fs->FileExist(temp_path)) { if (!fs->FileExist(path_handle)) {
MS_LOG(INFO) << "Dir " << path_handle << " does not exit, creating..."; MS_LOG(INFO) << "Dir " << path_handle << " does not exit, creating...";
if (!fs->CreateDir(temp_path)) { if (!fs->CreateDir(path_handle)) {
MS_LOG(ERROR) << "Create " << path_handle << " dir error"; MS_LOG(ERROR) << "Create " << path_handle << " dir error";
return false; return false;
} }

@ -34,7 +34,7 @@ void DataDumpParser::ResetParam() {
bool DataDumpParser::DumpEnabled() const { bool DataDumpParser::DumpEnabled() const {
auto enable_dump = std::getenv(kEnableDataDump); auto enable_dump = std::getenv(kEnableDataDump);
if (!enable_dump) { if (enable_dump == nullptr) {
MS_LOG(INFO) << "[DataDump] enable dump is null. Please export ENABLE_DATA_DUMP"; MS_LOG(INFO) << "[DataDump] enable dump is null. Please export ENABLE_DATA_DUMP";
return false; return false;
} }
@ -55,13 +55,15 @@ bool DataDumpParser::DumpEnabled() const {
std::optional<std::string> DataDumpParser::GetDumpPath() const { std::optional<std::string> DataDumpParser::GetDumpPath() const {
auto dump_path = std::getenv(kDataDumpPath); auto dump_path = std::getenv(kDataDumpPath);
if (!dump_path) { if (dump_path == nullptr) {
MS_LOG(ERROR) << "[DataDump] dump path is null. Please export DATA_DUMP_PATH"; MS_LOG(ERROR) << "[DataDump] dump path is null. Please export DATA_DUMP_PATH";
return {}; return {};
} }
std::string dump_path_str(dump_path); std::string dump_path_str(dump_path);
if (!std::all_of(dump_path_str.begin(), dump_path_str.end(), ::isalpha)) { if (!std::all_of(dump_path_str.begin(), dump_path_str.end(),
MS_LOG(EXCEPTION) << "[DataDump] dump path only support alphas, but got:" << dump_path_str; [](char c) { return ::isalpha(c) || ::isdigit(c) || c == '-' || c == '_' || c == '/'; })) {
MS_LOG(EXCEPTION) << "[DataDump] dump path only support alphabets, digit or {'-', '_', '/'}, but got:"
<< dump_path_str;
} }
return dump_path_str; return dump_path_str;
} }

@ -242,6 +242,11 @@ void DumpKernelOutput(const CNodePtr &kernel, void *args, NotNull<aicpu::dump::T
} }
output.set_original_output_format(GetGeFormat(output_format, output_shape.size())); output.set_original_output_format(GetGeFormat(output_format, output_shape.size()));
output.set_address(static_cast<uint64_t>(reinterpret_cast<uintptr_t>(args)) + offset); output.set_address(static_cast<uint64_t>(reinterpret_cast<uintptr_t>(args)) + offset);
// device address data size
auto address = AnfAlgo::GetOutputAddr(kernel, i);
MS_EXCEPTION_IF_NULL(address);
output.set_size(address->GetSize());
MS_LOG(INFO) << "[DataDump] output " << i << " address size:" << output.size();
MS_EXCEPTION_IF_NULL(task->mutable_output()); MS_EXCEPTION_IF_NULL(task->mutable_output());
task->mutable_output()->Add(std::move(output)); task->mutable_output()->Add(std::move(output));
offset += sizeof(void *); offset += sizeof(void *);
@ -272,6 +277,11 @@ void DumpKernelInput(const CNodePtr &kernel, void *args, NotNull<aicpu::dump::Ta
input.mutable_shape()->add_dim(dim); input.mutable_shape()->add_dim(dim);
} }
input.set_address(static_cast<uint64_t>(reinterpret_cast<uintptr_t>(args)) + offset); input.set_address(static_cast<uint64_t>(reinterpret_cast<uintptr_t>(args)) + offset);
// device address data size
auto address = AnfAlgo::GetPrevNodeOutputAddr(kernel, i);
MS_EXCEPTION_IF_NULL(address);
input.set_size(address->GetSize());
MS_LOG(INFO) << "[DataDump] input " << i << " address size:" << input.size();
MS_EXCEPTION_IF_NULL(task->mutable_input()); MS_EXCEPTION_IF_NULL(task->mutable_input());
task->mutable_input()->Add(std::move(input)); task->mutable_input()->Add(std::move(input));
offset += sizeof(void *); offset += sizeof(void *);

@ -144,17 +144,17 @@ bool ProfilingManager::StartupProfiling(uint32_t device_id) {
nlohmann::json startCfg; nlohmann::json startCfg;
startCfg["startCfg"] = devices; startCfg["startCfg"] = devices;
if (!ProfStartUp(NOT_NULL(&startCfg))) { if (!ProfStartUp(startCfg)) {
MS_LOG(ERROR) << "ProfMgrStartUp failed."; MS_LOG(ERROR) << "ProfMgrStartUp failed.";
return false; return false;
} }
return true; return true;
} }
bool ProfilingManager::ProfStartUp(NotNull<nlohmann::json *> startCfg) { bool ProfilingManager::ProfStartUp(const nlohmann::json &startCfg) {
// convert json to string // convert json to string
std::stringstream ss; std::stringstream ss;
ss << *startCfg; ss << startCfg;
std::string cfg = ss.str(); std::string cfg = ss.str();
MS_LOG(INFO) << "profiling config " << cfg; MS_LOG(INFO) << "profiling config " << cfg;
auto ret = rtProfilerStart(); auto ret = rtProfilerStart();

@ -49,7 +49,7 @@ class ProfilingManager {
~ProfilingManager() { prof_handle_ = nullptr; } ~ProfilingManager() { prof_handle_ = nullptr; }
private: private:
bool ProfStartUp(NotNull<nlohmann::json *> json); bool ProfStartUp(const nlohmann::json &json);
std::shared_ptr<ProfilingEngineImpl> engine_0_; std::shared_ptr<ProfilingEngineImpl> engine_0_;
uint32_t device_id_; uint32_t device_id_;
void *prof_handle_; void *prof_handle_;

Loading…
Cancel
Save