
    +j&                        d dl Z d dlZddlmZ ej        Zee j        gej        _        e j        ej        _	        e j        gej
        _        e j        ej
        _	        e j        gej        _        e j        ej        _	        e j        gej        _        e j        ej        _	        e j        gej        _         G d d          ZdS )    N   )controlc                   ,    e Zd Zd Zd Zd Zd Zd ZdS )	ModelMMAPc                 n   t           t          d          t          j        |          }t	          |t
                    r|}n:t          j        dk    r|                    d          }nt          j        |          }t           	                    |          | _
        | j
        st          d|           d S )Nzcomfy-aimdo is not initializedntzutf-8z ModelMMAP allocation failed for )libRuntimeErrorosfspath
isinstancebytesnameencodefsencodemodel_mmap_allocatestate)selffilepathnormalized_pathfilepath_bytess       Y/home/wildlama/comfy/ComfyUI/.venv/lib/python3.11/site-packages/comfy_aimdo/model_mmap.py__init__zModelMMAP.__init__   s    ;?@@@)H--ou-- 	:,NNW__,33G<<NN[99N,,^<<
z 	NL(LLMMM	N 	N    c                 @    t                               | j                  S N)r	   model_mmap_getr   r   s    r   getzModelMMAP.get)   s    !!$*---r   c                 Z    t          t                              | j                            S r   )intr	   model_mmap_get_file_handler   r   s    r   get_file_handlezModelMMAP.get_file_handle,   s     311$*==>>>r   c                 Z    t          t                              | j                            S r   )boolr	   model_mmap_bouncer   r   s    r   bouncezModelMMAP.bounce/   s     C))$*55666r   c                 d    t          | dd           }|rt                              |           d S d S )Nr   )getattrr	   model_mmap_deallocate)r   r   s     r   __del__zModelMMAP.__del__2   s?    gt,, 	-%%e,,,,,	- 	-r   N)__name__
__module____qualname__r   r   r#   r'   r+    r   r   r   r      sb        N N N . . .? ? ?7 7 7- - - - -r   r   )ctypesr    r   r	   c_char_pr   argtypesc_void_prestyper   r"   c_uint64r&   c_boolr*   r   r/   r   r   <module>r8      s     				      k?(.'8C$&,oC##)?"3C!'C/5.?C"+-3_C"*&,o%6C"$*MC!*0/):C&- - - - - - - - - -r   