torch dynamic profiling

This commit is contained in:
Vladimir Mandic
2024-05-16 18:40:18 -04:00
parent d63f35e298
commit 554e5c8224
19 changed files with 45 additions and 29 deletions
+11 -1
View File
@@ -89,8 +89,18 @@ def profile(profiler, msg: str):
def profile_torch(profiler, msg: str):
profiler.stop()
lines = profiler.key_averages().table(sort_by="cpu_time_total", row_limit=12)
lines = lines.split('\n')
lines = [x for x in lines if '/profiler' not in x and '---' not in x]
txt = '\n'.join(lines)
log.debug(f'Torch profile CPU-total {msg}: \n{txt}')
lines = profiler.key_averages().table(sort_by="self_cpu_time_total", row_limit=12)
lines = lines.split('\n')
lines = [x for x in lines if '/profiler' not in x and '---' not in x]
txt = '\n'.join(lines)
log.debug(f'Torch profile {msg}: \n{txt}')
log.debug(f'Torch profile CPU-self {msg}: \n{txt}')
lines = profiler.key_averages().table(sort_by="cuda_time_total", row_limit=12)
lines = lines.split('\n')
lines = [x for x in lines if '/profiler' not in x and '---' not in x]
txt = '\n'.join(lines)
log.debug(f'Torch profile CUDA {msg}: \n{txt}')