
    0;ji                     8   d dl mZ d dlmZ d dlmZ d dlmZ	 d dl
mZ d dlmZ d dlmZmZ d dlmZ  ed	g d
          Z G d de          Zej        Z ej        e          d             Z ej                      e            Z eeej                   [dS )    )
namedtuple)finalize)	nrtdynmod)binding)global_compiler_lock)typeof_impl)typesconfig)_nrt_python
nrt_mstatsallocfreemi_allocmi_freec                   p    e Zd Zd Zed             Zd Zed             Ze	d             Z
d ZddZd	 Zd
S )_Runtimec                     d| _         d S )NF)_initselfs    P/root/voice-cloning/.venv/lib/python3.11/site-packages/numba/core/runtime/nrt.py__init__z_Runtime.__init__   s    


    c                 <   | j         rdS t          j        rt          j                     t          j        D ]F}|                    d          r|}nd|z   }t          j        |         }t          j        ||           Gt          j
        |          | _        d| _         dS )zInitializes the NRT

        Must be called before any actual call to the NRT API.
        Safe to be called multiple times.
        N_NRT_T)r   r
   	NRT_STATS_nrtmemsys_enable_stats	c_helpers
startswithll
add_symbolr   compile_nrt_functions_library)r   ctxpy_namec_name	c_addresss        r   
initializez_Runtime.initialize   s     : 	F  	'$&&& ~ 	- 	-G!!#&& * ')w/IM&),,,, "7<<


r   c                 6    | j         sd}t          |          d S )Nz'Runtime must be initialized before use.)r   RuntimeError)r   msgs     r   _init_guardz_Runtime._init_guard0   s)    z 	$;Cs###	$ 	$r   c                  ,    t          j                     dS )ze
        Shutdown the NRT
        Safe to be called without calling Runtime.initialize first
        N)r   memsys_shutdown r   r   shutdownz_Runtime.shutdown5   s     	r   c                 8    |                                   | j        S )zQ
        Return the Library object containing the various NRT functions.
        )r/   r&   r   s    r   libraryz_Runtime.library=   s    
 	}r   c                 r    |                                   t          j        ||          }t          |          S )z
        Returns a MemInfo object that tracks memory at `data` owned by `pyobj`.
        MemInfo will acquire a reference on `pyobj`.
        The release of MemInfo will release a reference on `pyobj`.
        )r/   r   meminfo_newMemInfo)r   datapyobjmis       r   r7   z_Runtime.meminfo_newE   s4     	dE**r{{r   Fc                 
   |                                   |dk     rd| d}t          |          |rt          j        |          }nt          j        |          }|dk    rd| d}t          |          t          |          S )a  
        Allocate a new memory of `size` bytes and returns a MemInfo object
        that tracks the allocation.  When there is no more reference to the
        MemInfo object, the underlying memory will be deallocated.

        If `safe` flag is True, the memory is allocated using the `safe` scheme.
        This is used for debugging and testing purposes.
        See `NRT_MemInfo_alloc_safe()` in "nrt.h" for details.
        r   z,Cannot allocate a negative number of bytes: .zRequested allocation of z bytes failed.)r/   
ValueErrorr   meminfo_alloc_safememinfo_allocMemoryErrorr8   )r   sizesafer.   r;   s        r   r@   z_Runtime.meminfo_allocO   s     	!88HHHHCS//! 	*(..BB#D))B77ATAAACc"""r{{r   c                     t          t          j                    t          j                    t          j                    t          j                              S )zw
        Returns a namedtuple of (alloc, free, mi_alloc, mi_free) for count of
        each memory operations.
        r   )_nrt_mstatsr   memsys_get_stats_allocmemsys_get_stats_freememsys_get_stats_mi_allocmemsys_get_stats_mi_freer   s    r   get_allocation_statsz_Runtime.get_allocation_statsf   sN     !<!>!> $ : < <$($B$D$D#'#@#B#BD D D 	Dr   N)F)__name__
__module____qualname__r   r   r+   r/   staticmethodr3   propertyr5   r7   r@   rJ   r2   r   r   r   r      s             8$ $ $
   \   X     .	D 	D 	D 	D 	Dr   r   c                 >    t          j        t           j                  S )N)r	   MemInfoPointervoidptr)valcs     r   typeof_meminforU   v   s    ...r   N)collectionsr   weakrefr   	_finalizenumba.core.runtimer   llvmliter   r#   numba.core.compiler_lockr   numba.core.typing.typeofr   
numba.corer	   r
   r   r   rE   objectr   _MemInfor8   registerrU   memsys_use_cpython_allocatorrtsysr3   r2   r   r   <module>rc      s^   " " " " " " ) ) ) ) ) ) ( ( ( ( ( ( " " " " " " 9 9 9 9 9 9 0 0 0 0 0 0 $ $ $ $ $ $ $ $ 2 2 2 2 2 2j'O'O'OPP`D `D `D `D `Dv `D `D `DH - g/ / /
 " ! # # #

 
	%" # # # HHr   