From a74f32201083122a0be702255dbe5b00bc9a837f Mon Sep 17 00:00:00 2001 From: Mrtutu Date: Tue, 23 Jan 2024 00:34:42 +0800 Subject: [PATCH] fix kernel bug --- .../cluster_advice/kernel_cluster_advice.py | 17 +++++++++++++++-- .../common_func_advisor/constant.py | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/profiler/advisor/advisor_backend/cluster_advice/kernel_cluster_advice.py b/profiler/advisor/advisor_backend/cluster_advice/kernel_cluster_advice.py index 587c40f949..644d46714e 100644 --- a/profiler/advisor/advisor_backend/cluster_advice/kernel_cluster_advice.py +++ b/profiler/advisor/advisor_backend/cluster_advice/kernel_cluster_advice.py @@ -20,7 +20,12 @@ class KernelClusterAdvice(ClusterAdviceBase): return self.calculate_data() def load_kernel_details_data(self): - data_map = PytorchDataPreprocessor(self.collection_path).get_data_map() + prof_dirs = self.get_prof_dirs(self.collection_path) + if not prof_dirs: + msg = "[ERROR] There is no profile in this collection path, terminate analysis." + raise RuntimeError(msg) + + data_map = PytorchDataPreprocessor(prof_dirs).get_data_map() self.all_kernel_data = pd.DataFrame() for rank_id, profiling_dir_path in data_map.items(): kernel_file = os.path.join(profiling_dir_path, Constant.SINGLE_OUTPUT, Constant.KERNEL_DETAILS_CSV) @@ -36,7 +41,7 @@ class KernelClusterAdvice(ClusterAdviceBase): df = df_temp[columns_to_keep] df.insert(loc=0, column='rank id', value=rank_id) # 将数据添加到最终的数据框中 - self.all_kernel_data = self.all_kernel_data._append(df, ignore_index=True) + self.all_kernel_data = pd.concat([self.all_kernel_data, df], ignore_index=True) def calculate_data(self): # 存储所有合并后的数据 @@ -46,3 +51,11 @@ class KernelClusterAdvice(ClusterAdviceBase): view_data = self.all_kernel_data.groupby(group_col).agg(calculate_dict).reset_index() view_data.columns = [''.join(col) if col[1] == "" else '_'.join(col) for col in view_data.columns] return view_data + + def get_prof_dirs(self, collection_path): + prof_dirs = [] + for prof_dir in os.listdir(collection_path): + if prof_dir.endswith(Constant.PT_PROF_SUFFIX): + prof_dirs.append(os.path.join(collection_path, prof_dir)) + + return prof_dirs \ No newline at end of file diff --git a/profiler/advisor/advisor_backend/common_func_advisor/constant.py b/profiler/advisor/advisor_backend/common_func_advisor/constant.py index 2267d69dbc..932edb0a7f 100644 --- a/profiler/advisor/advisor_backend/common_func_advisor/constant.py +++ b/profiler/advisor/advisor_backend/common_func_advisor/constant.py @@ -38,6 +38,7 @@ class Constant: OPTIM = "optimizer" OP_SCHE = "op_schedule" + PT_PROF_SUFFIX = "ascend_pt" COLLECTION_PATH = "collection_path" CLUSTER_ANALYSIS_OUTPUT = "cluster_analysis_output" CLUSTER_STEP_TIME_CSV = "cluster_step_trace_time.csv" -- Gitee