modify profiler ai_cpu ut and st

This commit is contained in:
臧庆香 2021-12-22 18:29:34 +08:00
parent 9971fd1ac0
commit fcd3fface0
5 changed files with 105 additions and 13 deletions

View File

@ -162,15 +162,14 @@ class TestProfiler:
self._train_with_profiler(device_target="GPU")
self._check_gpu_profiling_file()
# TODO
# @pytest.mark.level0
# @pytest.mark.platform_arm_ascend_training
# @pytest.mark.platform_x86_ascend_training
# @pytest.mark.env_onecard
# @security_off_wrap
# def test_ascend_profiler(self):
# self._train_with_profiler(device_target="Ascend")
# self._check_d_profiling_file()
@pytest.mark.level0
@pytest.mark.platform_arm_ascend_training
@pytest.mark.platform_x86_ascend_training
@pytest.mark.env_onecard
@security_off_wrap
def test_ascend_profiler(self):
self._train_with_profiler(device_target="Ascend")
self._check_d_profiling_file()
def _train_with_profiler(self, device_target):
context.set_context(mode=context.GRAPH_MODE, device_target=device_target)

View File

@ -1,5 +1,42 @@
serial_number node_type_name total_time(ms) dispatch_time(ms) execution_time(ms) run_start run_end
1 InitData 1.567 0.1 0.129 2298200409.0 2298200538.0
2 GetNext 0.989 0.087 0.048 2302769932.0 2302769980.0
3 TruncatedNormal 1.566 0.105 0.129 4098200409.0 4098200538.0
AI CPU Total Time(ms): 4.122000
1 DropoutGenMask-op281 4.288 0.265 1.545 77282784881.5 77282786426.77
2 DropoutGenMask-op280 1.544 0.086 1.342 77282787106.8 77282788448.34
3 DropoutGenMask-op281 1.486 0.093 1.32 77282827197.54 77282828517.0
4 DropoutGenMask-op280 1.736 0.067 1.592 77282828908.26 77282830500.72
5 DropoutGenMask-op281 1.66 0.079 1.477 77282860066.47 77282861543.0
6 DropoutGenMask-op280 1.529 0.078 1.255 77282861976.47 77282863231.41
7 DropoutGenMask-op281 1.607 0.079 1.446 77282887089.12 77282888535.67
8 DropoutGenMask-op280 1.676 0.075 1.459 77282888940.05 77282890399.81
9 DropoutGenMask-op281 1.638 0.083 1.319 77282914603.2 77282915922.3
10 DropoutGenMask-op280 1.664 0.07 1.42 77282916477.05 77282917897.94
11 DropoutGenMask-op281 1.669 0.081 1.477 77282941875.22 77282943352.61
12 DropoutGenMask-op280 1.629 0.076 1.303 77282943753.39 77282945056.46
13 DropoutGenMask-op281 1.587 0.081 1.347 77282970597.33 77282971944.53
14 DropoutGenMask-op280 1.741 0.07 1.515 77282972425.58 77282973940.53
15 DropoutGenMask-op281 1.689 0.073 1.501 77282997580.92 77282999081.89
16 DropoutGenMask-op280 1.566 0.069 1.302 77282999468.69 77283000770.66
17 DropoutGenMask-op281 1.694 0.141 1.436 77283030792.78 77283032228.68
18 DropoutGenMask-op280 1.759 0.075 1.434 77283032619.71 77283034053.66
19 DropoutGenMask-op281 1.627 0.078 1.46 77283079322.08 77283080782.26
20 DropoutGenMask-op280 1.69 0.078 1.446 77283081215.54 77283082661.47
21 DropoutGenMask-op281 1.664 0.084 1.407 77283107635.82 77283109042.62
22 DropoutGenMask-op280 1.552 0.092 1.346 77283109570.09 77283110916.25
23 DropoutGenMask-op281 1.85 0.079 1.687 77283134509.55 77283136196.69
24 DropoutGenMask-op280 1.63 0.072 1.317 77283136611.86 77283137928.48
25 DropoutGenMask-op281 1.602 0.079 1.374 77283162262.85 77283163636.8
26 DropoutGenMask-op280 1.681 0.077 1.525 77283164113.56 77283165638.23
27 DropoutGenMask-op281 1.722 0.079 1.533 77283189373.34 77283190906.4
28 DropoutGenMask-op280 1.626 0.069 1.464 77283191344.38 77283192808.16
29 DropoutGenMask-op281 1.772 0.112 1.576 77283217078.13 77283218654.15
30 DropoutGenMask-op280 1.576 0.074 1.182 77283219009.32 77283220191.81
31 DropoutGenMask-op281 1.825 0.151 1.473 77283265621.42 77283267094.13
32 DropoutGenMask-op280 1.615 0.078 1.3 77283267514.25 77283268814.07
33 DropoutGenMask-op281 1.602 0.088 1.422 77283314872.95 77283316294.32
34 DropoutGenMask-op280 1.647 0.073 1.355 77283316722.29 77283318077.02
35 DropoutGenMask-op281 1.516 0.078 1.315 77283342271.36 77283343586.03
36 DropoutGenMask-op280 1.74 0.074 1.557 77283344041.98 77283345598.93
37 DropoutGenMask-op281 1.556 0.077 1.385 77283367845.47 77283369230.35
38 DropoutGenMask-op280 1.705 0.077 1.512 77283369665.8 77283371177.36
39 DropoutGenMask-op281 1.676 0.079 1.425 77283393068.39 77283394493.96
40 DropoutGenMask-op280 1.537 0.073 1.17 77283394986.16 77283396156.48
AI CPU Total Time(ms): 68.573000

View File

@ -0,0 +1,56 @@
# 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 mindspore.profiler.parser.aicpu_data_parser import DataPreProcessParser
class TestAicpuParser:
"""Test the class of Aicpu Parser."""
def setup_class(self):
"""Initialization before test case execution."""
self.profiling_dir = os.path.realpath(os.path.join(os.path.dirname(__file__),
'../../../data/profiler_data/'
'JOB_AICPU/data'))
self.expect_dir = os.path.realpath(os.path.join(os.path.dirname(__file__),
'../../../data/profiler_data/'
'JOB_AICPU/expect'))
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.expect_dir, 'output_data_preprocess_aicpu_0.txt')
self.op_task_dict = {
"22_2": "Default/network-_VirtualDatasetCell/_backbone-WithLossCell/_backbone-AlexNet/dropout-Dropout/"
"DropoutGenMask-op281",
"22_4": "Default/network-_VirtualDatasetCell/_backbone-WithLossCell/_backbone-AlexNet/dropout-Dropout/"
"DropoutGenMask-op280"
}
def teardown_method(self) -> None:
"""Clear output file."""
if os.path.exists(self.output_path):
shutil.rmtree(self.output_path)
def test_aicpu_parser(self):
"""Test the class of Aicpu Parser."""
data = DataPreProcessParser(self.profiling_dir, self.output_file, self.op_task_dict)
data.execute()
with open(self.expect_file, 'r') as fp:
expect_result = fp.read()
with open(self.output_file, 'r') as fp:
result = fp.read()
assert expect_result == result