Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MindSpore
mindinsight
提交
f9d5fa3b
M
mindinsight
项目概览
MindSpore
/
mindinsight
通知
8
Star
4
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindinsight
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f9d5fa3b
编写于
6月 20, 2020
作者:
A
askmiao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add and modify ut case
上级
fcf0df34
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
82 addition
and
3 deletion
+82
-3
tests/ut/profiler/parser/test_aicpu_parser.py
tests/ut/profiler/parser/test_aicpu_parser.py
+74
-0
tests/ut/profiler/proposer/test_proposer.py
tests/ut/profiler/proposer/test_proposer.py
+3
-3
tests/utils/resource/JOB_AICPU/data/DATA_PREPROCESS.dev.AICPU.0.slice_0
...source/JOB_AICPU/data/DATA_PREPROCESS.dev.AICPU.0.slice_0
+0
-0
tests/utils/resource/JOB_AICPU/expect/output_data_preprocess_aicpu_0.txt
...ource/JOB_AICPU/expect/output_data_preprocess_aicpu_0.txt
+5
-0
未找到文件。
tests/ut/profiler/parser/test_aicpu_parser.py
0 → 100644
浏览文件 @
f9d5fa3b
# Copyright 2020 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
"""Test the aicpu parser."""
import
os
import
tempfile
import
shutil
from
unittest
import
TestCase
from
mindinsight.profiler.parser.aicpu_data_parser
import
DataPreProcessParser
def
get_result
(
file_path
):
"""
Get result from the aicpu file.
Args:
file_path (str): The aicpu file path.
Returns:
list[list], the parsed aicpu information.
"""
result
=
[]
try
:
file
=
open
(
file_path
,
'r'
)
result
.
append
(
file
.
read
())
return
result
finally
:
if
file
:
file
.
close
()
class
TestAicpuParser
(
TestCase
):
"""Test the class of Aicpu Parser."""
def
setUp
(
self
)
->
None
:
"""Initialization before test case execution."""
self
.
profiling_dir
=
os
.
path
.
realpath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'../../../utils/resource/'
'JOB_AICPU/data'
))
self
.
expect_dir
=
os
.
path
.
realpath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'../../../utils/resource/'
'JOB_AICPU/data'
))
self
.
output_path
=
tempfile
.
mkdtemp
(
prefix
=
'output_data_preprocess_aicpu_'
)
self
.
output_file
=
os
.
path
.
join
(
self
.
output_path
,
'output_data_preprocess_aicpu_0.txt'
)
self
.
expect_file
=
os
.
path
.
join
(
self
.
output_path
,
'output_data_preprocess_aicpu_0.txt'
)
def
test_aicpu_parser
(
self
):
"""Test the class of Aicpu Parser."""
data
=
DataPreProcessParser
(
self
.
profiling_dir
,
self
.
output_file
)
data
.
execute
()
expect_result
=
get_result
(
self
.
expect_file
)
result
=
get_result
(
self
.
output_file
)
shutil
.
rmtree
(
self
.
output_path
)
assert
expect_result
==
result
def
test_aicpu_parser_file_not_exist
(
self
):
"""Test the class of Aicpu Parser."""
profiling_dir
=
os
.
path
.
realpath
(
os
.
path
.
join
(
self
.
profiling_dir
,
'data'
))
data
=
DataPreProcessParser
(
profiling_dir
,
self
.
output_file
)
data
.
execute
()
shutil
.
rmtree
(
self
.
output_path
)
tests/ut/profiler/proposer/test_proposer.py
浏览文件 @
f9d5fa3b
...
...
@@ -28,7 +28,7 @@ class TestPropose(TestCase):
"""Initialization before test case execution."""
self
.
profiling_dir
=
os
.
path
.
realpath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'../../../utils/resource/profiler'
))
self
.
device_id
=
0
self
.
device_id
=
"0"
self
.
common_proposal_dict
=
OrderedDict
()
self
.
common_proposal_dict
[
"common-profiler_tutorial"
]
=
None
self
.
step_trace_proposal_dict
=
OrderedDict
()
...
...
@@ -41,7 +41,7 @@ class TestPropose(TestCase):
proposal_dict
.
update
(
self
.
step_trace_proposal_dict
)
proposal_dict
[
"common-proposer_type_label"
]
=
None
proposal_dict
.
update
(
self
.
common_proposal_dict
)
type_list
=
[
'step_trace'
,
'common'
]
type_list
=
[
'step_trace'
,
'
minddata'
,
'minddata_pipeline'
,
'
common'
]
condition
=
{
"filter_condition"
:
{
'mode'
:
"proc"
,
"proc_name"
:
"iteration_interval"
,
"step_id"
:
0
}}
...
...
@@ -53,7 +53,7 @@ class TestPropose(TestCase):
def
test_propose_compose_exception
(
self
):
"""Test the class of ComposeProposal."""
profiling_dir
=
os
.
path
.
realpath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'../../../utils/resource/
test
'
))
'../../../utils/resource/'
))
proposal_dict
=
OrderedDict
()
proposal_dict
[
"common-proposer_type_label"
]
=
None
proposal_dict
.
update
(
self
.
common_proposal_dict
)
...
...
tests/utils/resource/JOB_AICPU/data/DATA_PREPROCESS.dev.AICPU.0.slice_0
0 → 100644
浏览文件 @
f9d5fa3b
文件已添加
tests/utils/resource/JOB_AICPU/expect/output_data_preprocess_aicpu_0.txt
0 → 100644
浏览文件 @
f9d5fa3b
serial_number node_type_name total_time(us) dispatch_time(us) run_start run_end
---------------------- ---------------- ---------------- ------------------- ----------- ----------
1 InitData 1567 100 2298200409 2298200538
2 GetNext 989 87 2302769932 2302769980
AI CPU Total Time(us): 2556
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录