[Perf] Cache xpu_get_mem_info() result to avoid duplicate calls (#32983)
Signed-off-by: 7. Sun <jhao.sun@gmail.com>
This commit is contained in:
@@ -107,7 +107,8 @@ class XPUWorker(Worker):
|
|||||||
|
|
||||||
torch.xpu.empty_cache()
|
torch.xpu.empty_cache()
|
||||||
torch_allocated_bytes = torch.xpu.memory_stats()["allocated_bytes.all.current"]
|
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
|
non_torch_allocations = total_allocated_bytes - torch_allocated_bytes
|
||||||
if non_torch_allocations > 0:
|
if non_torch_allocations > 0:
|
||||||
|
|||||||
Reference in New Issue
Block a user