From 48f5e0e63d1b954ca659a804f36237abd6dd45c1 Mon Sep 17 00:00:00 2001 From: gzhcv Date: Thu, 4 Mar 2021 11:11:38 +0800 Subject: [PATCH] Catch the host cpu data exception when returned data row to restful api --- mindinsight/profiler/analyser/cpu_analyser.py | 17 ++++++++++++++--- .../profiler/common/validator/validate.py | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/mindinsight/profiler/analyser/cpu_analyser.py b/mindinsight/profiler/analyser/cpu_analyser.py index 01284b0e..2bf4816f 100644 --- a/mindinsight/profiler/analyser/cpu_analyser.py +++ b/mindinsight/profiler/analyser/cpu_analyser.py @@ -15,6 +15,9 @@ """The cpu base analyser.""" from mindinsight.profiler.analyser.gpu_analyser import GpuAnalyser from mindinsight.profiler.common.validator import validate +from mindinsight.profiler.common.exceptions.exceptions import ProfilerRawFileException +from mindinsight.profiler.common.log import logger as log + class CpuOpTypeAnalyser(GpuAnalyser): """Cpu operation type analyser.""" @@ -32,7 +35,11 @@ class CpuOpTypeAnalyser(GpuAnalyser): Returns: list, the converted data. """ - return [row[0], int(row[1]), int(row[2]), float(row[3]), float(row[4]), float(row[5])*100] + try: + return [row[0], int(row[1]), int(row[2]), float(row[3]), float(row[4]), float(row[5])*100] + except IndexError as err: + log.exception(err) + raise ProfilerRawFileException('failed to get HOST CPU operator type data.') class CpuOpInfoAnalyser(GpuAnalyser): @@ -51,5 +58,9 @@ class CpuOpInfoAnalyser(GpuAnalyser): Returns: list, the converted data. """ - return [row[0], row[1], row[2], row[3], int(row[4]), float(row[5]), - float(row[6]), float(row[7]), row[8]] + try: + return [row[0], row[1], row[2], row[3], int(row[4]), float(row[5]), + float(row[6]), float(row[7]), row[8]] + except IndexError as err: + log.exception(err) + raise ProfilerRawFileException('failed to get HOST CPU operator detail data.') diff --git a/mindinsight/profiler/common/validator/validate.py b/mindinsight/profiler/common/validator/validate.py index e42e3725..21257cad 100644 --- a/mindinsight/profiler/common/validator/validate.py +++ b/mindinsight/profiler/common/validator/validate.py @@ -35,7 +35,7 @@ GPU_DETAIL_COL = ["op_side", "op_type", "op_name", "op_full_name", "op_occurrences", "op_total_time", "op_avg_time", "proportion", "cuda_activity_cost_time", "cuda_activity_call_count"] CPU_TYPE_COL = ["op_type", "type_occurrences", "execution_frequency", "total_compute_time", - "avg_time", "percent"] + "avg_time", "total_time_proportion"] CPU_DETAIL_COL = ["op_side", "op_type", "op_name", "full_op_name", "op_occurrences", "op_total_time", "op_avg_time", "total_time_proportion", "subgraph"] MINDDATA_PIPELINE_COL = [