Browse Source

update the display column name in ui

tags/v0.5.0-beta
chenchao99 5 years ago
parent
commit
6c4dbf01e8
4 changed files with 52 additions and 30 deletions
  1. +20
    -3
      mindinsight/profiler/analyser/analyser.py
  2. +4
    -3
      tests/st/func/profiler/test_op_analyser.py
  3. +14
    -12
      tests/ut/profiler/analyser/test_analyser_aicore_detail.py
  4. +14
    -12
      tests/ut/profiler/analyser/test_analyser_aicore_type.py

+ 20
- 3
mindinsight/profiler/analyser/analyser.py View File

@@ -34,6 +34,8 @@ class AicoreTypeAnalyser(BaseAnalyser):
ProfilerPathErrorException: If the profiling dir is invalid.
"""
_col_names = ['op_type', 'execution_time', 'execution_frequency', 'percent']
_col_names_in_result = ['op_type', 'execution_time (ms)',
'execution_frequency', 'percent']
_file_name_aicore_type_time = 'aicore_intermediate_{}_type.csv'

def _load(self):
@@ -72,6 +74,7 @@ class AicoreTypeAnalyser(BaseAnalyser):
"""
for item in self._result:
item[1] = float(format(item[1], '.6f'))
self._display_col_names = self._col_names_in_result[:]
return super()._organize_query_result()

def _convert_field_type(self, row):
@@ -101,6 +104,8 @@ class AicoreDetailAnalyser(BaseAnalyser):
"""
_col_names = ['op_name', 'op_type', 'avg_execution_time', 'subgraph',
'full_op_name', 'op_info']
_col_names_in_result = ['op_name', 'op_type', 'avg_execution_time (ms)',
'subgraph', 'full_op_name', 'op_info']
_file_name_aicore_detail_time = 'aicore_intermediate_{}_detail.csv'
_file_name_framework_info = 'framework_raw_{}.csv'

@@ -226,11 +231,11 @@ class AicoreDetailAnalyser(BaseAnalyser):
is_display_full_op_name (bool): Whether to display the operator full
name.
"""
self._display_col_names = self._col_names[0:4]
self._display_col_names = self._col_names_in_result[0:4]
if is_display_full_op_name:
self._display_col_names.append(self._col_names[4])
self._display_col_names.append(self._col_names_in_result[4])
if is_display_detail:
self._display_col_names.append(self._col_names[5])
self._display_col_names.append(self._col_names_in_result[5])

def _convert_framework_field_type(self, row):
"""
@@ -275,6 +280,8 @@ class AicpuAnalyser(BaseAnalyser):
"""
_col_names = ['serial_number', 'op_type', 'total_time', 'dispatch_time',
'run_start', 'run_end']
_col_names_in_result = ['serial_number', 'op_type', 'total_time (ms)',
'dispatch_time (ms)', 'run_start', 'run_end']
_file_name_aicpu_time = 'aicpu_intermediate_{}.csv'

def _load(self):
@@ -305,6 +312,16 @@ class AicpuAnalyser(BaseAnalyser):
return self._default_filter(item, filter_condition)
self._result = list(filter(_inner_filter, self._data))

def _organize_query_result(self):
"""
Organize the query result.

Returns:
dict, the query result.
"""
self._display_col_names = self._col_names_in_result[:]
return super()._organize_query_result()

def _convert_field_type(self, row):
"""
Convert the field type to the specific type.


+ 4
- 3
tests/st/func/profiler/test_op_analyser.py View File

@@ -32,7 +32,8 @@ from tests.ut.profiler import RAW_DATA_BASE

OP_GATHER_V2_INFO = {
'col_name': [
'op_name', 'op_type', 'avg_execution_time', 'subgraph', 'full_op_name', 'op_info'
'op_name', 'op_type', 'avg_execution_time (ms)', 'subgraph', 'full_op_name',
'op_info'
],
'object': [
[
@@ -124,7 +125,7 @@ class TestOpAnalyser:
def test_query_aicore_type_1(self):
"""Test the function of querying AICORE operator type infomation."""
expect_result = {
'col_name': ['op_type', 'execution_time', 'execution_frequency', 'percent'],
'col_name': ['op_type', 'execution_time (ms)', 'execution_frequency', 'percent'],
'object': [
['UnsortedSegmentSum', 44.607826, 2, 35.28],
['GatherV2', 43.155441, 2, 34.13],
@@ -176,7 +177,7 @@ class TestOpAnalyser:
def test_query_aicore_type_2(self):
"""Test the function of querying AICORE operator type infomation."""
expect_result = {
'col_name': ['op_type', 'execution_time', 'execution_frequency', 'percent'],
'col_name': ['op_type', 'execution_time (ms)', 'execution_frequency', 'percent'],
'object': [
['MatMul', 1.936681, 15, 1.53],
['Mul', 1.902949, 32, 1.51]


+ 14
- 12
tests/ut/profiler/analyser/test_analyser_aicore_detail.py View File

@@ -23,6 +23,8 @@ from tests.ut.profiler import PROFILER_DIR

COL_NAMES = ['op_name', 'op_type', 'avg_execution_time', 'subgraph',
'full_op_name', 'op_info']
COL_NAMES_IN_RESULT = ['op_name', 'op_type', 'avg_execution_time (ms)',
'subgraph', 'full_op_name', 'op_info']


def get_detail_infos(indexes=None, sort_name=None, sort_type=True):
@@ -75,7 +77,7 @@ class TestAicoreDetailAnalyser(TestCase):
def test_query_success_1(self):
"""Test the success of the querying function."""
expect_result = {
'col_name': COL_NAMES,
'col_name': COL_NAMES_IN_RESULT,
'object': get_detail_infos(),
'size': 10
}
@@ -88,7 +90,7 @@ class TestAicoreDetailAnalyser(TestCase):
def test_query_success_2(self):
"""Test the success of the querying function."""
expect_result = {
'col_name': COL_NAMES,
'col_name': COL_NAMES_IN_RESULT,
'object': get_detail_infos(indexes=[9]),
'size': 1
}
@@ -125,7 +127,7 @@ class TestAicoreDetailAnalyser(TestCase):
def test_query_success_3(self):
"""Test the success of the querying function."""
expect_result = {
'col_name': COL_NAMES,
'col_name': COL_NAMES_IN_RESULT,
'object': get_detail_infos(sort_name='avg_execution_time', sort_type=True),
'size': 10
}
@@ -139,7 +141,7 @@ class TestAicoreDetailAnalyser(TestCase):
self.assertDictEqual(expect_result, result)

expect_result = {
'col_name': COL_NAMES,
'col_name': COL_NAMES_IN_RESULT,
'object': get_detail_infos(sort_name='op_name', sort_type=False),
'size': 10
}
@@ -155,7 +157,7 @@ class TestAicoreDetailAnalyser(TestCase):
def test_query_success_4(self):
"""Test the success of the querying function."""
expect_result = {
'col_name': COL_NAMES,
'col_name': COL_NAMES_IN_RESULT,
'object': get_detail_infos(indexes=[2, 3]),
'size': 10
}
@@ -169,7 +171,7 @@ class TestAicoreDetailAnalyser(TestCase):
self.assertDictEqual(expect_result, result)

expect_result = {
'col_name': COL_NAMES,
'col_name': COL_NAMES_IN_RESULT,
'object': [],
'size': 10
}
@@ -185,7 +187,7 @@ class TestAicoreDetailAnalyser(TestCase):
def test_query_success_5(self):
"""Test the success of the querying function."""
expect_result = {
'col_name': COL_NAMES,
'col_name': COL_NAMES_IN_RESULT,
'object': get_detail_infos(
indexes=[1, 2], sort_name='avg_execution_time', sort_type=True
),
@@ -209,7 +211,7 @@ class TestAicoreDetailAnalyser(TestCase):
self.assertDictEqual(expect_result, result)

expect_result = {
'col_name': COL_NAMES,
'col_name': COL_NAMES_IN_RESULT,
'object': get_detail_infos(
indexes=[0, 1, 2, 8], sort_name='avg_execution_time', sort_type=True
),
@@ -236,7 +238,7 @@ class TestAicoreDetailAnalyser(TestCase):
detail_infos = get_detail_infos(indexes=[9])

expect_result = {
'col_name': COL_NAMES[0:5],
'col_name': COL_NAMES_IN_RESULT[0:5],
'object': [item[0:5] for item in detail_infos],
'size': 1
}
@@ -252,7 +254,7 @@ class TestAicoreDetailAnalyser(TestCase):
self.assertDictEqual(expect_result, result)

expect_result = {
'col_name': COL_NAMES[0:4],
'col_name': COL_NAMES_IN_RESULT[0:4],
'object': [item[0:4] for item in detail_infos],
'size': 1
}
@@ -272,7 +274,7 @@ class TestAicoreDetailAnalyser(TestCase):
"""Test the success of the querying and sorting function by operator type."""
detail_infos = get_detail_infos(indexes=[9, 0, 2, 1, 5, 3, 4])
expect_result = {
'col_name': COL_NAMES[0:4],
'col_name': COL_NAMES_IN_RESULT[0:4],
'object': [item[0:4] for item in detail_infos]
}

@@ -294,7 +296,7 @@ class TestAicoreDetailAnalyser(TestCase):
"""Test the success of the querying and sorting function by operator type."""
detail_infos = get_detail_infos(indexes=[9, 0, 2, 1, 3, 4, 8, 6])
expect_result = {
'col_name': COL_NAMES[0:4],
'col_name': COL_NAMES_IN_RESULT[0:4],
'object': [item[0:4] for item in detail_infos]
}



+ 14
- 12
tests/ut/profiler/analyser/test_analyser_aicore_type.py View File

@@ -21,6 +21,8 @@ from mindinsight.profiler.analyser.analyser_factory import AnalyserFactory
from tests.ut.profiler import PROFILER_DIR

COL_NAMES = ['op_type', 'execution_time', 'execution_frequency', 'percent']
COL_NAMES_IN_RESULT = ['op_type', 'execution_time (ms)', 'execution_frequency',
'percent']


def get_type_infos(indexes=None, sort_name=None, sort_type=True):
@@ -72,7 +74,7 @@ class TestAicoreTypeAnalyser(TestCase):
def test_query_success_1(self):
"""Test the success of the querying function."""
expect_result = {
'col_name': COL_NAMES,
'col_name': COL_NAMES_IN_RESULT,
'object': get_type_infos(),
'size': 5
}
@@ -86,7 +88,7 @@ class TestAicoreTypeAnalyser(TestCase):
def test_query_success_2(self):
"""Test the success of the querying function."""
expect_result = {
'col_name': COL_NAMES,
'col_name': COL_NAMES_IN_RESULT,
'object': get_type_infos(indexes=[1]),
'size': 1
}
@@ -101,7 +103,7 @@ class TestAicoreTypeAnalyser(TestCase):
self.assertDictEqual(expect_result, result)

expect_result = {
'col_name': COL_NAMES,
'col_name': COL_NAMES_IN_RESULT,
'object': get_type_infos(indexes=[0, 2, 3, 4]),
'size': 4
}
@@ -116,7 +118,7 @@ class TestAicoreTypeAnalyser(TestCase):
self.assertDictEqual(expect_result, result)

expect_result = {
'col_name': COL_NAMES,
'col_name': COL_NAMES_IN_RESULT,
'object': get_type_infos(indexes=[0, 1, 3]),
'size': 3
}
@@ -133,7 +135,7 @@ class TestAicoreTypeAnalyser(TestCase):
def test_query_success_3(self):
"""Test the success of the querying function."""
expect_result = {
'col_name': COL_NAMES,
'col_name': COL_NAMES_IN_RESULT,
'object': get_type_infos(indexes=[1, 3]),
'size': 2
}
@@ -148,7 +150,7 @@ class TestAicoreTypeAnalyser(TestCase):
self.assertDictEqual(expect_result, result)

expect_result = {
'col_name': COL_NAMES,
'col_name': COL_NAMES_IN_RESULT,
'object': get_type_infos(indexes=[0, 2, 4]),
'size': 3
}
@@ -163,7 +165,7 @@ class TestAicoreTypeAnalyser(TestCase):
self.assertDictEqual(expect_result, result)

expect_result = {
'col_name': COL_NAMES,
'col_name': COL_NAMES_IN_RESULT,
'object': get_type_infos(indexes=[2, 3]),
'size': 2
}
@@ -180,7 +182,7 @@ class TestAicoreTypeAnalyser(TestCase):
def test_query_success_4(self):
"""Test the success of the querying function."""
expect_result = {
'col_name': COL_NAMES,
'col_name': COL_NAMES_IN_RESULT,
'object': get_type_infos(sort_name='op_type', sort_type=True),
'size': 5}
condition = {
@@ -193,7 +195,7 @@ class TestAicoreTypeAnalyser(TestCase):
self.assertDictEqual(expect_result, result)

expect_result = {
'col_name': COL_NAMES,
'col_name': COL_NAMES_IN_RESULT,
'object': get_type_infos(sort_name='execution_time', sort_type=False),
'size': 5
}
@@ -209,7 +211,7 @@ class TestAicoreTypeAnalyser(TestCase):
def test_query_success_5(self):
"""Test the success of the querying function."""
expect_result = {
'col_name': COL_NAMES,
'col_name': COL_NAMES_IN_RESULT,
'object': get_type_infos(indexes=[0, 1]),
'size': 5
}
@@ -223,7 +225,7 @@ class TestAicoreTypeAnalyser(TestCase):
self.assertDictEqual(expect_result, result)

expect_result = {
'col_name': COL_NAMES,
'col_name': COL_NAMES_IN_RESULT,
'object': get_type_infos(indexes=[3, 4]),
'size': 5
}
@@ -239,7 +241,7 @@ class TestAicoreTypeAnalyser(TestCase):
def test_query_success_6(self):
"""Test the success of the querying function."""
expect_result = {
'col_name': COL_NAMES,
'col_name': COL_NAMES_IN_RESULT,
'object': get_type_infos(
indexes=[1, 3], sort_name='execution_time', sort_type=True
),


Loading…
Cancel
Save