L idZddlmZmZddlZddlmZmZddlm Z ddeede e effd Z ddeede fd Zddeede fd Zddeeddfd Zgd Zy)zKThis package adds support for device memory management implemented in MTIA.)AnyOptionalN) _device_tis_initialized)_get_device_indexdevicereturncntsiStjjt |dS)aReturn a dictionary of MTIA memory allocator statistics for a given device. Args: device (torch.device, str, or int, optional) selected device. Returns statistics for the current device, given by current_device(), if device is None (default). Toptional)rtorch_C_mtia_memoryStatsrr s W/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/torch/mtia/memory.py memory_statsr s,   88 % %&7&N OOcntsyt|jddjddS)aReturn the maximum memory allocated in bytes for a given device. Args: device (torch.device, str, or int, optional) selected device. Returns statistics for the current device, given by current_device(), if device is None (default). rdram peak_bytesrrgetrs rmax_memory_allocatedrs2     # #FA . 2 2< CCrcntsyt|jddjddS)a?Return the current MTIA memory occupied by tensors in bytes for a given device. Args: device (torch.device or int or str, optional): selected device. Returns statistic for the current device, given by :func:`~torch.mtia.current_device`, if :attr:`device` is ``None`` (default). rrallocated_bytesrrs rmemory_allocatedr's3     # #FA . 2 23Da HHrcntsytjjt |dy)aReset the peak memory stats for a given device. Args: device (torch.device, str, or int, optional) selected device. Returns statistics for the current device, given by current_device(), if device is None (default). NTr )rrr_mtia_resetPeakMemoryStatsrrs rreset_peak_memory_statsr 4s'   HH''(9&4(PQr)rrrr )N)__doc__typingrrrrr_utilsrdictstrrintrrr __all__rrr*sS '% P), PS#X P D)!4 D D IXi0 IC I RHY$7 R4 R r