diff --git a/mindinsight/profiler/analyser/analyser.py b/mindinsight/profiler/analyser/analyser.py index 2c1db35037a23915b25dc870e6d1a98bfd8a8681..92738e27a66a3efe0ba4ce20dc99caae9444c8e5 100644 --- a/mindinsight/profiler/analyser/analyser.py +++ b/mindinsight/profiler/analyser/analyser.py @@ -63,6 +63,17 @@ class AicoreTypeAnalyser(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. + """ + for item in self._result: + item[1] = float(format(item[1], '.6f')) + return super()._organize_query_result() + def _convert_field_type(self, row): """ Convert the field type to the specific type. diff --git a/mindinsight/profiler/analyser/base_analyser.py b/mindinsight/profiler/analyser/base_analyser.py index 8b4d31c885678210f5af89420bda1628867065c5..8ed5e52315272b2ee26c8989d9e898954776f5e2 100644 --- a/mindinsight/profiler/analyser/base_analyser.py +++ b/mindinsight/profiler/analyser/base_analyser.py @@ -97,11 +97,7 @@ class BaseAnalyser(ABC): self._sort(sort_condition) if group_condition: self._group(group_condition) - return { - 'col_name': self._display_col_names, - 'object': self._result, - 'size': self._size - } + return self._organize_query_result() @abstractmethod def _load(self): @@ -244,3 +240,16 @@ class BaseAnalyser(ABC): except ValidationError: raise ProfilerPathErrorException('The profiling dir is invalid.') return normalized_profiling_dir + + def _organize_query_result(self): + """ + Organize the query result. + + Returns: + dict, the query result. + """ + return { + 'col_name': self._display_col_names, + 'object': self._result, + 'size': self._size + } diff --git a/tests/st/func/profiler/test_op_analyser.py b/tests/st/func/profiler/test_op_analyser.py index 7e32a58a079ce81fb22bd9ad2cdbaf201883ee0e..5c069c174cd3c3dcfa919c497c905a8f1fcce7f8 100644 --- a/tests/st/func/profiler/test_op_analyser.py +++ b/tests/st/func/profiler/test_op_analyser.py @@ -126,34 +126,34 @@ class TestOpAnalyser: expect_result = { 'col_name': ['op_type', 'execution_time', 'execution_frequency', 'percent'], 'object': [ - ['UnsortedSegmentSum', 44.60782642857142, 2, 35.28], - ['GatherV2', 43.15544147619047, 2, 34.13], - ['Slice', 20.376314999999998, 16, 16.12], - ['Concat', 5.80845380952381, 4, 4.59], - ['Split', 2.7142774761904764, 2, 2.15], - ['MatMul', 1.9366814285714287, 15, 1.53], - ['Mul', 1.9029486666666666, 32, 1.51], - ['StridedSliceGrad', 1.5068342857142858, 2, 1.19], - ['TransData', 1.1151575238095237, 30, 0.88], - ['ReluGrad', 0.8540685714285714, 5, 0.68], - ['Cast', 0.4846848571428572, 15, 0.38], - ['ReLU', 0.48328214285714277, 5, 0.38], - ['RealDiv', 0.4228071904761905, 15, 0.33], - ['StridedSlice', 0.3455687619047618, 2, 0.27], - ['Adam', 0.2859357142857143, 11, 0.23], - ['BiasAdd', 0.18966285714285713, 5, 0.15], - ['BiasAddGrad', 0.07168142857142856, 5, 0.06], - ['Tile', 0.04415833333333334, 4, 0.03], - ['ReduceSum', 0.030764857142857142, 5, 0.02], - ['ApplyFtrl', 0.025453571428571426, 2, 0.02], - ['AtomicAddrClean', 0.019368666666666666, 8, 0.02], - ['AddN', 0.012836428571428572, 1, 0.01], - ['Square', 0.009799333333333334, 1, 0.01], - ['SigmoidCrossEntropyWithLogitsGrad', 0.009582142857142859, 2, 0.01], - ['TensorAdd', 0.009218380952380952, 3, 0.01], - ['SigmoidCrossEntropyWithLogits', 0.004808571428571428, 1, 0.0], - ['ReduceMean', 0.004534999999999999, 1, 0.0], - ['Assign', 0.0024766666666666665, 2, 0.0], + ['UnsortedSegmentSum', 44.607826, 2, 35.28], + ['GatherV2', 43.155441, 2, 34.13], + ['Slice', 20.376315, 16, 16.12], + ['Concat', 5.808454, 4, 4.59], + ['Split', 2.714277, 2, 2.15], + ['MatMul', 1.936681, 15, 1.53], + ['Mul', 1.902949, 32, 1.51], + ['StridedSliceGrad', 1.506834, 2, 1.19], + ['TransData', 1.115158, 30, 0.88], + ['ReluGrad', 0.854069, 5, 0.68], + ['Cast', 0.484685, 15, 0.38], + ['ReLU', 0.483282, 5, 0.38], + ['RealDiv', 0.422807, 15, 0.33], + ['StridedSlice', 0.345569, 2, 0.27], + ['Adam', 0.285936, 11, 0.23], + ['BiasAdd', 0.189663, 5, 0.15], + ['BiasAddGrad', 0.071681, 5, 0.06], + ['Tile', 0.044158, 4, 0.03], + ['ReduceSum', 0.030765, 5, 0.02], + ['ApplyFtrl', 0.025454, 2, 0.02], + ['AtomicAddrClean', 0.019369, 8, 0.02], + ['AddN', 0.012836, 1, 0.01], + ['Square', 0.009799, 1, 0.01], + ['SigmoidCrossEntropyWithLogitsGrad', 0.009582, 2, 0.01], + ['TensorAdd', 0.009218, 3, 0.01], + ['SigmoidCrossEntropyWithLogits', 0.004809, 1, 0.0], + ['ReduceMean', 0.004535, 1, 0.0], + ['Assign', 0.002477, 2, 0.0], ['AssignAdd', 0.001688, 1, 0.0] ], 'size': 29 @@ -178,8 +178,8 @@ class TestOpAnalyser: expect_result = { 'col_name': ['op_type', 'execution_time', 'execution_frequency', 'percent'], 'object': [ - ['MatMul', 1.9366814285714287, 15, 1.53], - ['Mul', 1.9029486666666666, 32, 1.51] + ['MatMul', 1.936681, 15, 1.53], + ['Mul', 1.902949, 32, 1.51] ], 'size': 2 }