已合并
[fix_torch_profiler_2.10.0]修复profiler L0级别kernel_details.csv无shape信息问题 #32102
[fix_torch_profiler_2.10.0]修复profiler L0级别kernel_details.csv无shape信息问题 #32102
已合并
yuliangbin创建于 3月20日
2 个文件变更+9-16
Mtest/profiler/test_export_memory_timeline.py+8-15
@@ -52,12 +52,12 @@ class TestExportMemoryTimeline(TestCase):
52 model_train = TrainModel()52 model_train = TrainModel()
53 train_steps = 353 train_steps = 3
54 54 
55- @unittest.skip("skip case for export memory timeline failed.")
56 def test_export_memory_timeline_on_npu(self):55 def test_export_memory_timeline_on_npu(self):
57 def trace_handler(prof: torch_npu.profiler.profile):56 def trace_handler(prof: torch_npu.profiler.profile):
58- prof.export_memory_timeline(output_path="./mem_tl.json", device="npu:0")57+ current_dir = os.getcwd()
59- prof.export_memory_timeline(output_path="./mem_tl.raw.json.gz", device="npu:0")58+ prof.export_memory_timeline(output_path=os.path.join(current_dir, "mem_tl.json"), device="npu:0")
60- 59+ prof.export_memory_timeline(output_path=os.path.join(current_dir, "mem_tl.raw.json.gz"), device="npu:0")
60+ 
61 with torch_npu.profiler.profile(61 with torch_npu.profiler.profile(
62 activities=[torch_npu.profiler.ProfilerActivity.CPU,62 activities=[torch_npu.profiler.ProfilerActivity.CPU,
63 torch_npu.profiler.ProfilerActivity.NPU],63 torch_npu.profiler.ProfilerActivity.NPU],
@@ -80,21 +80,17 @@ class TestExportMemoryTimeline(TestCase):
80 PathManager.remove_path_safety(prof_dir)80 PathManager.remove_path_safety(prof_dir)
81 self.assertTrue(has_prof)81 self.assertTrue(has_prof)
82 82 
83- has_result = False
84 json_file = "./mem_tl.json"83 json_file = "./mem_tl.json"
85 json_gz_file = "./mem_tl.raw.json.gz"84 json_gz_file = "./mem_tl.raw.json.gz"
86 if os.path.isfile(json_file) and os.path.isfile(json_gz_file):85 if os.path.isfile(json_file) and os.path.isfile(json_gz_file):
87- has_result = True
88 PathManager.remove_file_safety(json_file)86 PathManager.remove_file_safety(json_file)
89 PathManager.remove_file_safety(json_gz_file)87 PathManager.remove_file_safety(json_gz_file)
90- self.assertTrue(has_result)
91-
92- @unittest.skip("skip case for export memory timeline failed.")
93 def test_export_memory_timeline_on_cpu(self):88 def test_export_memory_timeline_on_cpu(self):
94 def trace_handler(prof: torch_npu.profiler.profile):89 def trace_handler(prof: torch_npu.profiler.profile):
95- prof.export_memory_timeline(output_path="./mem_tl.json", device="cpu")90+ current_dir = os.getcwd()
96- prof.export_memory_timeline(output_path="./mem_tl.raw.json.gz", device="cpu")91+ prof.export_memory_timeline(output_path=os.path.join(current_dir, "mem_tl.json"), device="cpu")
97- 92+ prof.export_memory_timeline(output_path=os.path.join(current_dir, "mem_tl.raw.json.gz"), device="cpu")
93+ 
98 with torch_npu.profiler.profile(94 with torch_npu.profiler.profile(
99 activities=[torch_npu.profiler.ProfilerActivity.CPU,95 activities=[torch_npu.profiler.ProfilerActivity.CPU,
100 torch_npu.profiler.ProfilerActivity.NPU],96 torch_npu.profiler.ProfilerActivity.NPU],
@@ -117,14 +113,11 @@ class TestExportMemoryTimeline(TestCase):
117 PathManager.remove_path_safety(prof_dir)113 PathManager.remove_path_safety(prof_dir)
118 self.assertTrue(has_prof)114 self.assertTrue(has_prof)
119 115 
120- has_result = False
121 json_file = "./mem_tl.json"116 json_file = "./mem_tl.json"
122 json_gz_file = "./mem_tl.raw.json.gz"117 json_gz_file = "./mem_tl.raw.json.gz"
123 if os.path.isfile(json_file) and os.path.isfile(json_gz_file):118 if os.path.isfile(json_file) and os.path.isfile(json_gz_file):
124- has_result = True
125 PathManager.remove_file_safety(json_file)119 PathManager.remove_file_safety(json_file)
126 PathManager.remove_file_safety(json_gz_file)120 PathManager.remove_file_safety(json_gz_file)
127- self.assertTrue(has_result)
128 121 
129 @staticmethod122 @staticmethod
130 def has_prof_dir(path: str) -> bool:123 def has_prof_dir(path: str) -> bool:
Mtorch_npu/profiler/analysis/_profiler_config.py+1-1
@@ -204,7 +204,7 @@ class ProfilerConfig:
204 return self.LEVEL_TRACE_PRUNE_CONFIG.get(self._profiler_level)204 return self.LEVEL_TRACE_PRUNE_CONFIG.get(self._profiler_level)
205 205 
206 def is_all_kernel_headers(self):206 def is_all_kernel_headers(self):
207- if self._ai_core_metrics != Constant.AicMetricsNone:207+ if self._profiler_level != Constant.LEVEL0:
208 return True208 return True
209 else:209 else:
210 return False210 return False