Unverified Commit 14d03b8d authored by 7. Sun's avatar 7. Sun Committed by GitHub
Browse files

[Perf] Cache xpu_get_mem_info() result to avoid duplicate calls (#32983)


Signed-off-by: default avatar7. Sun <jhao.sun@gmail.com>
parent d0cbac58
......@@ -107,7 +107,8 @@ class XPUWorker(Worker):
torch.xpu.empty_cache()
torch_allocated_bytes = torch.xpu.memory_stats()["allocated_bytes.all.current"]
total_allocated_bytes = self.xpu_get_mem_info()[1] - self.xpu_get_mem_info()[0]
free_mem, total_mem = self.xpu_get_mem_info()
total_allocated_bytes = total_mem - free_mem
non_torch_allocations = total_allocated_bytes - torch_allocated_bytes
if non_torch_allocations > 0:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment