Ë
    øÿæiÙ  ã                   ó<  — U d dl Z d dlZd dlmZ d dlZd dlmZ g d¢Zee	   e
d<   de	defd„Z eej                  d	«      �sA eej                  d
«      r ed«      ‚ eej                  d«      r ed«      ‚ eej                  d«      r ed«      ‚ eej                  d«      r ed«      ‚ eej                  d«      r ed«      ‚ ed	«      ej                  j                  d	<    ed
«      ej                  j                  d
<    ed«      ej                  j                  d<    ed«      ej                  j                  d<    ed«      ej                  j                  d<    ed«      ej                  j                  d<   deddfd„Zdeddfd„Z G d„ d«      Zy)é    N)ÚCallable)ÚStorage)Úgds_register_bufferÚgds_deregister_bufferÚGdsFileÚ__all__ÚnameÚreturnc                 ó   ‡ — ˆ fd„}|S )Nc                  ó"   •— t        d‰› d�«      ‚)Nz	torch._C.z" is not supported on this platform)ÚRuntimeError)ÚargsÚkwargsr	   s     €úc/Volumes/fast/ai/experiments/voice-extract-mac/.venv/lib/python3.12/site-packages/torch/cuda/gds.pyÚfnz_dummy_fn.<locals>.fn   s   ø€ Ü˜Y t fÐ,NÐOÓPÐPó    © )r	   r   s   ` r   Ú	_dummy_fnr      s   ø€ ôQð €Ir   Ú_gds_register_bufferÚ_gds_deregister_bufferz?_gds_deregister_buffer exists but _gds_register_buffer does notÚ_gds_register_handlez=_gds_register_handle exists but _gds_register_buffer does notÚ_gds_deregister_handlez?_gds_deregister_handle exists but _gds_register_buffer does notÚ_gds_load_storagez:_gds_load_storage exists but _gds_register_buffer does notÚ_gds_save_storagez:_gds_save_storage exists but _gds_register_buffer does notÚsc                 óB   — t         j                  j                  | «       y)a:  Registers a storage on a CUDA device as a cufile buffer.

    Example::

        >>> # xdoctest: +SKIP("gds filesystem requirements")
        >>> src = torch.randn(1024, device="cuda")
        >>> s = src.untyped_storage()
        >>> gds_register_buffer(s)

    Args:
        s (Storage): Buffer to register.
    N)ÚtorchÚ_Cr   ©r   s    r   r   r   5   s   € ô 
‡H�H×!Ñ! !Õ$r   c                 óB   — t         j                  j                  | «       y)aw  Deregisters a previously registered storage on a CUDA device as a cufile buffer.

    Example::

        >>> # xdoctest: +SKIP("gds filesystem requirements")
        >>> src = torch.randn(1024, device="cuda")
        >>> s = src.untyped_storage()
        >>> gds_register_buffer(s)
        >>> gds_deregister_buffer(s)

    Args:
        s (Storage): Buffer to register.
    N)r   r   r   r   s    r   r   r   E   s   € ô 
‡H�H×#Ñ# AÕ&r   c                   ód   — e Zd ZdZdedefd„Zdd„Zdd„Zdd	„Z	dd
e
deddfd„Zdd
e
deddfd„Zy)r   a“  Wrapper around cuFile.

    cuFile is a file-like interface to the GPUDirect Storage (GDS) API.

    See the `cufile docs <https://docs.nvidia.com/gpudirect-storage/api-reference-guide/index.html#cufile-io-api>`_
    for more details.

    Args:
        filename (str): Name of the file to open.
        flags (int): Flags to pass to ``os.open`` when opening the file. ``os.O_DIRECT`` will
            be added automatically.

    Example::

        >>> # xdoctest: +SKIP("gds filesystem requirements")
        >>> src1 = torch.randn(1024, device="cuda")
        >>> src2 = torch.randn(2, 1024, device="cuda")
        >>> file = torch.cuda.gds.GdsFile(f, os.O_CREAT | os.O_RDWR)
        >>> file.save_storage(src1.untyped_storage(), offset=0)
        >>> file.save_storage(src2.untyped_storage(), offset=src1.nbytes)
        >>> dest1 = torch.empty(1024, device="cuda")
        >>> dest2 = torch.empty(2, 1024, device="cuda")
        >>> file.load_storage(dest1.untyped_storage(), offset=0)
        >>> file.load_storage(dest2.untyped_storage(), offset=src1.nbytes)
        >>> torch.equal(src1, dest1)
        True
        >>> torch.equal(src2, dest2)
        True

    ÚfilenameÚflagsc                 óâ   — t         j                  dk(  rt        d«      ‚|| _        || _        t        j                  ||t
        j                  z  «      | _        d | _	        | j                  «        y )NÚwin32z*GdsFile is not supported on this platform.)ÚsysÚplatformr   r"   r#   ÚosÚopenÚO_DIRECTÚfdÚhandleÚregister_handle)Úselfr"   r#   s      r   Ú__init__zGdsFile.__init__v   sV   € Ü�<‰<˜7Ò"ÜÐKÓLÐLØ ˆŒØˆŒ
Ü—'‘'˜( E¬B¯K©KÑ$7Ó8ˆŒØ"&ˆŒØ×ÑÕr   r
   Nc                 óz   — | j                   �| j                  «        t        j                  | j                  «       y )N)r,   Úderegister_handler(   Úcloser+   ©r.   s    r   Ú__del__zGdsFile.__del__   s(   € Ø�;‰;Ð"Ø×"Ñ"Ô$Ü
�‰�—‘Õr   c                 óŽ   — | j                   �t        d«      ‚t        j                  j	                  | j
                  «      | _         y)zpRegisters file descriptor to cuFile Driver.

        This is a wrapper around ``cuFileHandleRegister``.
        Nz4Cannot register a handle that is already registered.)r,   ÚAssertionErrorr   r   r   r+   r3   s    r   r-   zGdsFile.register_handle„   s4   € ð
 �;‰;Ð"Ü Ð!WÓXÐXÜ—h‘h×3Ñ3°D·G±GÓ<ˆ�r   c                 ó’   — | j                   €t        d«      ‚t        j                  j	                  | j                   «       d| _         y)zvDeregisters file descriptor from cuFile Driver.

        This is a wrapper around ``cuFileHandleDeregister``.
        Nz2Cannot deregister a handle that is not registered.)r,   r6   r   r   r   r3   s    r   r1   zGdsFile.deregister_handle�   s7   € ð
 �;‰;ÐÜ Ð!UÓVÐVÜ�‰×'Ñ'¨¯©Ô4Øˆ�r   ÚstorageÚoffsetc                 óˆ   — | j                   €t        d«      ‚t        j                  j	                  | j                   ||«       y)am  Loads data from the file into the storage.

        This is a wrapper around ``cuFileRead``. ``storage.nbytes()`` of data
        will be loaded from the file at ``offset`` into the storage.

        Args:
            storage (Storage): Storage to load data into.
            offset (int, optional): Offset into the file to start loading from. (Default: 0)
        Nz4Cannot load data from a file that is not registered.)r,   r6   r   r   r   ©r.   r8   r9   s      r   Úload_storagezGdsFile.load_storage—   s4   € ð �;‰;ÐÜ Ð!WÓXÐXÜ�‰×"Ñ" 4§;¡;°¸Õ@r   c                 óˆ   — | j                   €t        d«      ‚t        j                  j	                  | j                   ||«       y)aU  Saves data from the storage into the file.

        This is a wrapper around ``cuFileWrite``. All bytes of the storage
        will be written to the file at ``offset``.

        Args:
            storage (Storage): Storage to save data from.
            offset (int, optional): Offset into the file to start saving to. (Default: 0)
        Nz2Cannot save data to a file that is not registered.)r,   r6   r   r   r   r;   s      r   Úsave_storagezGdsFile.save_storage¥   s4   € ð �;‰;ÐÜ Ð!UÓVÐVÜ�‰×"Ñ" 4§;¡;°¸Õ@r   )r
   N)r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚstrÚintr/   r4   r-   r1   r   r<   r>   r   r   r   r   r   V   se   „ ñð> ð ¨Só óó
=óñA Gð A°Sð AÀó AñA Gð A°Sð AÀô Ar   r   )r(   r&   Úcollections.abcr   r   Útorch.typesr   r   ÚlistrC   Ú__annotations__r   Úhasattrr   r6   Ú__dict__r   r   r   r   r   r   Ú<module>rK      sÅ  ðÜ 	Û 
Ý $ã Ý ò€ˆˆc‰ó ð�Cð ˜Hó ñ ˆu�x‰xÐ/Õ0Ùˆu�x‰xÐ1Ô2ÙØMó
ð 	
ñ ˆu�x‰xÐ/Ô0ÙØKó
ð 	
ñ ˆu�x‰xÐ1Ô2ÙØMó
ð 	
ñ ˆu�x‰xÐ,Ô-ÙØHó
ð 	
ñ ˆu�x‰xÐ,Ô-ÙØHó
ð 	
ñ 1:Ð:PÓ0Q€E‡H�H×ÑÐ,Ñ-Ù2;Ð<TÓ2U€E‡H�H×ÑÐ.Ñ/Ù09Ð:PÓ0Q€E‡H�H×ÑÐ,Ñ-Ù2;Ð<TÓ2U€E‡H�H×ÑÐ.Ñ/Ù-6Ð7JÓ-K€E‡H�H×ÑÐ)Ñ*Ù-6Ð7JÓ-K€E‡H�H×ÑÐ)Ñ*ð%˜7ð % tó %ð '˜Wð '¨ó '÷"[Aò [Ar   