forked from mindspore-Ecosystem/mindspore
commit
6b9a61ea82
|
@ -80,9 +80,9 @@ bool Common::CreateNotExistDirs(const std::string &path) {
|
|||
char tmp_char = temp_path[i];
|
||||
temp_path[i] = '\0';
|
||||
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...";
|
||||
if (!fs->CreateDir(temp_path)) {
|
||||
if (!fs->CreateDir(path_handle)) {
|
||||
MS_LOG(ERROR) << "Create " << path_handle << " dir error";
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ void DataDumpParser::ResetParam() {
|
|||
|
||||
bool DataDumpParser::DumpEnabled() const {
|
||||
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";
|
||||
return false;
|
||||
}
|
||||
|
@ -55,13 +55,15 @@ bool DataDumpParser::DumpEnabled() const {
|
|||
|
||||
std::optional<std::string> DataDumpParser::GetDumpPath() const {
|
||||
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";
|
||||
return {};
|
||||
}
|
||||
std::string dump_path_str(dump_path);
|
||||
if (!std::all_of(dump_path_str.begin(), dump_path_str.end(), ::isalpha)) {
|
||||
MS_LOG(EXCEPTION) << "[DataDump] dump path only support alphas, but got:" << dump_path_str;
|
||||
if (!std::all_of(dump_path_str.begin(), dump_path_str.end(),
|
||||
[](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;
|
||||
}
|
||||
|
|
|
@ -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_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());
|
||||
task->mutable_output()->Add(std::move(output));
|
||||
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.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());
|
||||
task->mutable_input()->Add(std::move(input));
|
||||
offset += sizeof(void *);
|
||||
|
|
|
@ -144,17 +144,17 @@ bool ProfilingManager::StartupProfiling(uint32_t device_id) {
|
|||
nlohmann::json startCfg;
|
||||
startCfg["startCfg"] = devices;
|
||||
|
||||
if (!ProfStartUp(NOT_NULL(&startCfg))) {
|
||||
if (!ProfStartUp(startCfg)) {
|
||||
MS_LOG(ERROR) << "ProfMgrStartUp failed.";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProfilingManager::ProfStartUp(NotNull<nlohmann::json *> startCfg) {
|
||||
bool ProfilingManager::ProfStartUp(const nlohmann::json &startCfg) {
|
||||
// convert json to string
|
||||
std::stringstream ss;
|
||||
ss << *startCfg;
|
||||
ss << startCfg;
|
||||
std::string cfg = ss.str();
|
||||
MS_LOG(INFO) << "profiling config " << cfg;
|
||||
auto ret = rtProfilerStart();
|
||||
|
|
|
@ -49,7 +49,7 @@ class ProfilingManager {
|
|||
~ProfilingManager() { prof_handle_ = nullptr; }
|
||||
|
||||
private:
|
||||
bool ProfStartUp(NotNull<nlohmann::json *> json);
|
||||
bool ProfStartUp(const nlohmann::json &json);
|
||||
std::shared_ptr<ProfilingEngineImpl> engine_0_;
|
||||
uint32_t device_id_;
|
||||
void *prof_handle_;
|
||||
|
|
Loading…
Reference in New Issue