Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
4ad4d583
M
mindspore
项目概览
magicwindyyd
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindspore
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
4ad4d583
编写于
7月 17, 2020
作者:
C
caifubi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix Security Bug
上级
1bcbbb08
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
49 addition
and
9 deletion
+49
-9
mindspore/ccsrc/debug/common.cc
mindspore/ccsrc/debug/common.cc
+4
-0
mindspore/ccsrc/debug/data_dump_parser.cc
mindspore/ccsrc/debug/data_dump_parser.cc
+36
-5
mindspore/ccsrc/debug/data_dump_parser.h
mindspore/ccsrc/debug/data_dump_parser.h
+4
-3
mindspore/ccsrc/runtime/device/ascend/ascend_kernel_runtime.cc
...pore/ccsrc/runtime/device/ascend/ascend_kernel_runtime.cc
+3
-0
mindspore/ccsrc/runtime/device/ascend/dump/data_dumper.cc
mindspore/ccsrc/runtime/device/ascend/dump/data_dumper.cc
+2
-1
未找到文件。
mindspore/ccsrc/debug/common.cc
浏览文件 @
4ad4d583
...
...
@@ -120,6 +120,10 @@ std::optional<std::string> Common::GetConfigFile(const std::string &env) {
MS_LOG
(
ERROR
)
<<
dump_config_file
<<
" not exist."
;
return
{};
}
auto
suffix
=
dump_config_file
.
substr
(
dump_config_file
.
find_last_of
(
'.'
)
+
1
);
if
(
suffix
!=
"json"
)
{
MS_LOG
(
EXCEPTION
)
<<
"[DataDump] dump config file suffix only support json! But got:."
<<
suffix
;
}
return
dump_config_file
;
}
}
// namespace mindspore
mindspore/ccsrc/debug/data_dump_parser.cc
浏览文件 @
4ad4d583
...
...
@@ -29,7 +29,7 @@ void DataDumpParser::ResetParam() {
net_name_
.
clear
();
dump_mode_
=
0
;
dump_step_
=
0
;
kernel_
set
_
.
clear
();
kernel_
map
_
.
clear
();
}
bool
DataDumpParser
::
DumpEnabled
()
const
{
...
...
@@ -60,9 +60,18 @@ std::optional<std::string> DataDumpParser::GetDumpPath() const {
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
;
}
return
dump_path_str
;
}
std
::
string
GetIfstreamString
(
const
std
::
ifstream
&
ifstream
)
{
std
::
stringstream
buffer
;
buffer
<<
ifstream
.
rdbuf
();
return
buffer
.
str
();
}
void
DataDumpParser
::
ParseDumpConfig
()
{
std
::
lock_guard
<
std
::
mutex
>
guard
(
lock_
);
MS_LOG
(
INFO
)
<<
"[DataDump] parse start"
;
...
...
@@ -84,7 +93,12 @@ void DataDumpParser::ParseDumpConfig() {
}
nlohmann
::
json
j
;
json_file
>>
j
;
try
{
json_file
>>
j
;
}
catch
(
nlohmann
::
json
::
parse_error
&
e
)
{
MS_LOG
(
ERROR
)
<<
"[DataDump] json contents:"
<<
GetIfstreamString
(
json_file
);
MS_LOG
(
EXCEPTION
)
<<
"[DataDump] parse json failed, error:"
<<
e
.
what
();
}
if
(
j
.
find
(
"DumpSettings"
)
==
j
.
end
())
{
MS_LOG
(
EXCEPTION
)
<<
"[DataDump] DumpSettings is not exist."
;
}
...
...
@@ -111,8 +125,8 @@ bool DataDumpParser::NeedDump(const std::string &op_full_name) const {
if
(
dump_mode_
==
0
)
{
return
true
;
}
auto
iter
=
kernel_
set
_
.
find
(
op_full_name
);
return
iter
!=
kernel_
set
_
.
end
();
auto
iter
=
kernel_
map
_
.
find
(
op_full_name
);
return
iter
!=
kernel_
map
_
.
end
();
}
bool
DataDumpParser
::
IsConfigExist
(
const
nlohmann
::
json
&
dump_settings
)
const
{
...
...
@@ -145,8 +159,25 @@ bool DataDumpParser::ParseDumpSetting(const nlohmann::json &dump_settings) {
auto
kernel_str
=
kernel
.
dump
();
kernel_str
.
erase
(
std
::
remove
(
kernel_str
.
begin
(),
kernel_str
.
end
(),
'\"'
),
kernel_str
.
end
());
MS_LOG
(
INFO
)
<<
"[DataDump] Need dump kernel:"
<<
kernel_str
;
kernel_
set_
.
insert
(
kernel_str
);
kernel_
map_
.
insert
({
kernel_str
,
0
}
);
}
return
true
;
}
void
DataDumpParser
::
MatchKernel
(
const
std
::
string
&
kernel_name
)
{
auto
iter
=
kernel_map_
.
find
(
kernel_name
);
if
(
iter
==
kernel_map_
.
end
())
{
return
;
}
iter
->
second
=
iter
->
second
+
1
;
MS_LOG
(
INFO
)
<<
"Match dump kernel:"
<<
iter
->
first
<<
" match times:"
<<
iter
->
second
;
}
void
DataDumpParser
::
PrintUnusedKernel
()
{
for
(
const
auto
&
iter
:
kernel_map_
)
{
if
(
iter
.
second
==
0
)
{
MS_LOG
(
WARNING
)
<<
"[DataDump] Unused Kernel in json:"
<<
iter
.
first
;
}
}
}
}
// namespace mindspore
mindspore/ccsrc/debug/data_dump_parser.h
浏览文件 @
4ad4d583
...
...
@@ -18,7 +18,7 @@
#define MINDSPORE_MINDSPORE_CCSRC_DEBUG_ASYNC_DUMP_JSON_PARE_H_
#include <string>
#include <
set
>
#include <
map
>
#include <mutex>
#include <optional>
#include "nlohmann/json.hpp"
...
...
@@ -39,7 +39,8 @@ class DataDumpParser {
const
std
::
string
&
net_name
()
const
{
return
net_name_
;
}
uint32_t
dump_mode
()
const
{
return
dump_mode_
;
}
uint32_t
dump_step
()
const
{
return
dump_step_
;
}
const
std
::
set
<
std
::
string
>
&
kernel_set
()
const
{
return
kernel_set_
;
}
void
MatchKernel
(
const
std
::
string
&
kernel_name
);
void
PrintUnusedKernel
();
private:
DataDumpParser
()
=
default
;
...
...
@@ -55,7 +56,7 @@ class DataDumpParser {
std
::
string
net_name_
;
uint32_t
dump_mode_
{
0
};
uint32_t
dump_step_
{
0
};
std
::
set
<
std
::
string
>
kernel_set
_
;
std
::
map
<
std
::
string
,
uint32_t
>
kernel_map
_
;
};
}
// namespace mindspore
#endif // MINDSPORE_MINDSPORE_CCSRC_DEBUG_ASYNC_DUMP_JSON_PARE_H_
mindspore/ccsrc/runtime/device/ascend/ascend_kernel_runtime.cc
浏览文件 @
4ad4d583
...
...
@@ -100,6 +100,9 @@ void AscendKernelRuntime::ClearGraphModelMap() {
iter
.
second
->
UnloadDumpInfo
();
}
graph_data_dumper_
.
clear
();
// tell users which dump kernel name not used
DataDumpParser
::
GetInstance
().
PrintUnusedKernel
();
for
(
auto
&
iter
:
graph_model_map_
)
{
MS_LOG
(
INFO
)
<<
"Ge UnloadModel "
<<
iter
.
first
;
auto
ret
=
ModelRunner
::
Instance
().
UnloadModel
(
iter
.
first
);
...
...
mindspore/ccsrc/runtime/device/ascend/dump/data_dumper.cc
浏览文件 @
4ad4d583
...
...
@@ -62,6 +62,7 @@ void DataDumper::LoadDumpInfo() {
}
MS_LOG
(
INFO
)
<<
"[DataDump] LoadDumpInfo kernel:"
<<
kernel
->
fullname_with_scope
();
dump_kernel_names_
.
emplace_back
(
kernel
->
fullname_with_scope
());
DataDumpParser
::
GetInstance
().
MatchKernel
(
kernel
->
fullname_with_scope
());
aicpu
::
dump
::
Task
task
;
ConstructDumpTask
(
NOT_NULL
(
kernel
),
NOT_NULL
(
&
task
));
...
...
@@ -84,7 +85,7 @@ void DataDumper::SetOpMappingInfo(NotNull<aicpu::dump::OpMappingInfo *> dump_inf
MS_LOG
(
EXCEPTION
)
<<
"Dump path invalid"
;
}
auto
device_id
=
context_ptr
->
device_id
();
dump_info
->
set_dump_path
(
dump_path
.
value
()
+
"_"
+
std
::
to_string
(
device_id
)
+
"/"
);
dump_info
->
set_dump_path
(
"/"
+
dump_path
.
value
()
+
"_"
+
std
::
to_string
(
device_id
)
+
"/"
);
MS_LOG
(
INFO
)
<<
"[DataDump] dump_path:"
<<
dump_path
.
value
();
dump_info
->
set_model_name
(
DataDumpParser
::
GetInstance
().
net_name
()
+
"_"
+
std
::
to_string
(
kernel_graph_
->
graph_id
()));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录