
    piS                         U d dl mZ d dlmZmZ d dlZd dlmZ	 g dZ
defdZedefd       Zed	ed
edefd       Zedd
edefd       Zedefd       Zedefd       Zdaee	   ed<   ddZy)    )	lru_cache)OptionalTYPE_CHECKINGN)Library)get_core_countget_nameis_builtis_availableis_macos13_or_neweris_macos_or_newerreturnc                  6    t         j                  j                  S )zReturn whether PyTorch is built with MPS support.

    Note that this doesn't necessarily mean MPS is available; just that
    if this PyTorch binary were run a machine with working MPS drivers
    and devices, we would be able to use it.
    )torch_C_has_mps     ]/opt/services/ai/voice_agent/venv/lib/python3.12/site-packages/torch/backends/mps/__init__.pyr	   r	      s     88r   c                  >    t         j                  j                         S )z7Return a bool indicating if MPS is currently available.)r   r   _mps_is_availabler   r   r   r
   r
      s     88%%''r   majorminorc                 B    t         j                  j                  | |      S )zHReturn a bool indicating whether MPS is running on given MacOS or newer.r   r   _mps_is_on_macos_or_newer)r   r   s     r   r   r   "   s     88--eU;;r   c                 B    t         j                  j                  d|       S )zEReturn a bool indicating whether MPS is running on MacOS 13 or newer.   r   )r   s    r   r   r   (   s     88--b%88r   c                  >    t         j                  j                         S )zReturn Metal device name)r   r   _mps_get_namer   r   r   r   r   .   s     88!!##r   c                  >    t         j                  j                         S )zReturn GPU core count.

    According to the documentation, one core is comprised of 16 Execution Units.
    One execution Unit has 8 ALUs.
    And one ALU can run 24 threads, i.e. one core is capable of executing 3072 threads concurrently.
    )r   r   _mps_get_core_countr   r   r   r   r   4   s     88''))r   _libc                      t         
t               syddlm}  ddlm} t        dd      a t         j                  d|d       t         j                  d	| d       y)
z<Register prims as implementation of var_mean and group_norm.Nr   )native_group_norm_backward)native_group_normatenIMPLr%   MPSr$   )r"   r	   torch._decomp.decompositionsr$   torch._refsr%   _Libraryimpl)r$   r%   s     r   _initr-   B   sG     xzG-FF#DII!#4e<II*,FNr   )r   )r   N)	functoolsr   
_lru_cachetypingr   r   r   torch.libraryr   r+   __all__boolr	   r
   intr   r   strr   r   r"   __annotations__r-   r   r   r   <module>r7      s    - *  -$  (d ( (
 <S < < < <
 9s 94 9 9
 $# $ $
 * * *  hx Or   