
    Yh                         d Z ddlmZmZ ddlZddlmZmZ ddlm	Z	 ddee         de
eef         fd	Zddee         defd
Zddee         ddfdZg dZdS )zKThis package adds support for device memory management implemented in MTIA.    )AnyOptionalN   )	_device_tis_initialized)_get_device_indexdevicereturnc                 ~    t                      si S t          j                            t	          | d                    S )a  Return 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).
    Toptional)r   torch_C_mtia_memoryStatsr   r	   s    c/var/www/tools.fuzzalab.pt/emblema-extractor/venv/lib/python3.11/site-packages/torch/mtia/memory.pymemory_statsr      s;      	8%%&7&N&N&NOOO    c                     t                      sdS t          |                               dd                              dd          S )a  Return 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).
    r   dram
peak_bytes)r   r   getr   s    r   max_memory_allocatedr      sE      q##FA..22<CCCr   c                     t                      sdS t          j                            t	          | d                     dS )a  Reset 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   )r   r   r   _mtia_resetPeakMemoryStatsr   r   s    r   reset_peak_memory_statsr   '   sA      	H''(9&4(P(P(PQQQQQr   )r   r   r   )N)__doc__typingr   r   r    r   r   _utilsr   dictstrr   intr   r   __all__ r   r   <module>r&      s   S R                  ' ' ' ' ' ' ' ' % % % % % %
P 
P), 
PS#X 
P 
P 
P 
P
D 
D)!4 
D 
D 
D 
D 
DR RHY$7 R4 R R R R  r   