diff --git a/mindinsight/profiler/parser/aicpu_data_parser.py b/mindinsight/profiler/parser/aicpu_data_parser.py index 04038f771d8a49e7a8d040803a709ccae4699272..0e32d629e39e27907ae074d0bb039cf15243504a 100644 --- a/mindinsight/profiler/parser/aicpu_data_parser.py +++ b/mindinsight/profiler/parser/aicpu_data_parser.py @@ -35,8 +35,9 @@ class DataPreProcessParser: _source_file_target = 'DATA_PREPROCESS.dev.AICPU.' _dst_file_title = 'title:DATA_PREPROCESS AICPU' - _dst_file_column_title = ['serial_number', 'node_type_name', 'total_time(us)', - 'dispatch_time(us)', 'run_start', 'run_end'] + _dst_file_column_title = ['serial_number', 'node_type_name', 'total_time(ms)', + 'dispatch_time(ms)', 'run_start', 'run_end'] + _ms_unit = 1000 def __init__(self, input_path, output_filename): self._input_path = input_path @@ -71,8 +72,8 @@ class DataPreProcessParser: run_start = node_list[1].split(':')[-1].split(' ')[0] run_end = node_list[run_end_index].split(':')[-1].split(' ')[0] - total_time = thread_list[-1].split('=')[-1].split()[0] - dispatch_time = thread_list[-2].split('=')[-1].split()[0] + total_time = float(thread_list[-1].split('=')[-1].split()[0]) / self._ms_unit + dispatch_time = float(thread_list[-2].split('=')[-1].split()[0]) / self._ms_unit return [number, node_type_name, total_time, dispatch_time, run_start, run_end] @@ -112,7 +113,7 @@ class DataPreProcessParser: result_list.append(result) # Calculate the total time. total_time = result[2] - ai_cpu_total_time_summary += int(total_time) + ai_cpu_total_time_summary += total_time # Increase node serial number. serial_number += 1 elif "Node" in node_line and "Thread" not in thread_line: @@ -120,7 +121,8 @@ class DataPreProcessParser: logger.warning("The node type:%s cannot find thread data", node_type_name) if result_list: - result_list.append(["AI CPU Total Time(us):", ai_cpu_total_time_summary]) + ai_cpu_total_time = format(ai_cpu_total_time_summary, '.6f') + result_list.append(["AI CPU Total Time(ms):", ai_cpu_total_time]) fwrite_format(self._output_filename, data_source=self._dst_file_title, is_print=True, is_start=True) fwrite_format(self._output_filename, diff --git a/tests/utils/resource/JOB_AICPU/expect/output_data_preprocess_aicpu_0.txt b/tests/utils/resource/JOB_AICPU/expect/output_data_preprocess_aicpu_0.txt index 072eb79083c8840235f06ceac3cc5d414906f56d..8ffb402765713eb9f56431a254b639deecc2d869 100644 --- a/tests/utils/resource/JOB_AICPU/expect/output_data_preprocess_aicpu_0.txt +++ b/tests/utils/resource/JOB_AICPU/expect/output_data_preprocess_aicpu_0.txt @@ -1,6 +1,6 @@ -serial_number node_type_name total_time(us) dispatch_time(us) run_start run_end +serial_number node_type_name total_time(ms) dispatch_time(ms) run_start run_end ---------------------- ---------------- ---------------- ------------------- ----------- ---------- -1 InitData 1567 100 2298200409 2298200538 -2 GetNext 989 87 2302769932 2302769980 -3 TruncatedNormal 1566 105 4098200409 4098200538 -AI CPU Total Time(us): 4122 +1 InitData 1.567 0.1 2298200409 2298200538 +2 GetNext 0.989 0.087 2302769932 2302769980 +3 TruncatedNormal 1.566 0.105 4098200409 4098200538 +AI CPU Total Time(ms): 4.122000