torch.xpu.memory.memory_stats#
- torch.xpu.memory.memory_stats(device=None)[source]#
返回給定裝置的 XPU 記憶體分配器統計資訊的字典。
此函式的返回值是一個統計字典,其中每個統計項都是一個非負整數。
核心統計資訊
"allocated_bytes.{all,large_pool,small_pool}.{current,peak,allocated,freed}": 已分配記憶體的大小。"reserved_bytes.{all,large_pool,small_pool}.{current,peak,allocated,freed}": 已預留記憶體的大小。"active_bytes.{all,large_pool,small_pool}.{current,peak,allocated,freed}": 活動記憶體的大小。"requested_bytes.{all,large_pool,small_pool}.{current,peak,allocated,freed}": 客戶端程式碼請求的記憶體,將其與 allocated_bytes 進行比較,以檢查分配舍入是否會增加過多開銷。
對於這些核心統計資訊,值按以下方式細分。
記憶體池型別
all: 所有記憶體池的組合統計資訊。large_pool: 大記憶體分配池(用於大小 >= 1MB 的分配)的統計資訊。small_pool: 小記憶體分配池(用於大小 < 1MB 的分配)的統計資訊。
指標型別
current:此指標的當前值。peak:此指標的最大值。allocated:此指標的歷史總增長量。freed:此指標的歷史總減少量。
- 引數
device (torch.device 或 int 或 str, 可選) – 選定的裝置。如果
device為None(預設值),則返回當前裝置(由current_device()指定)的統計資訊。- 返回型別