
    [Th                     F   % S SK r S SKrS SKJrJr  S SKrS SKJr  / SQr\	\
   \S'   S\
S\4S jr\" \R                  S	5      (       Gd<  \" \R                  S
5      (       a   e\" \R                  S5      (       a   e\" \R                  S5      (       a   e\" \R                  S5      (       a   e\" \R                  S5      (       a   e\" S	5      \R                  R                  S	'   \" S
5      \R                  R                  S
'   \" S5      \R                  R                  S'   \" S5      \R                  R                  S'   \" S5      \R                  R                  S'   \" S5      \R                  R                  S'   S\SS4S jrS\SS4S jr " S S5      rg)    N)CallableOptional)Storage)gds_register_buffergds_deregister_bufferGdsFile__all__namereturnc                    ^  U 4S jnU$ )Nc                  "   > [        ST S35      e)Nz	torch._C.z" is not supported on this platform)RuntimeError)argskwargsr
   s     F/var/www/auris/envauris/lib/python3.13/site-packages/torch/cuda/gds.pyfn_dummy_fn.<locals>.fn   s    Ytf,NOPP     )r
   r   s   ` r   	_dummy_fnr      s    Q Ir   _gds_register_buffer_gds_deregister_buffer_gds_register_handle_gds_deregister_handle_gds_load_storage_gds_save_storagesc                 B    [         R                  R                  U 5        g)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   &   s     
HH!!!$r   c                 B    [         R                  R                  U 5        g)aS  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   6   s     
HH##A&r   c                   |    \ rS rSrSrS\S\4S jrSS jrSS	 jr	SS
 jr
SS\S\SS4S jjrSS\S\SS4S jjrSrg)r   G   a7  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                     [         R                  S:X  a  [        S5      eXl        X l        [
        R                  " X[
        R                  -  5      U l        S U l	        U R                  5         g )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__GdsFile.__init__g   sP    <<7"KLL 
''(BKK$78%)r   r   Nc                 ~    U R                   b  U R                  5         [        R                  " U R                  5        g )N)r/   deregister_handler+   closer.   r1   s    r   __del__GdsFile.__del__p   s(    ;;"""$
r   c                     U R                   b   S5       e[        R                  R                  U R                  5      U l         g)z`Registers file descriptor to cuFile Driver.

This is a wrapper around ``cuFileHandleRegister``.
Nz4Cannot register a handle that is already registered.)r/   r   r    r   r.   r7   s    r   r0   GdsFile.register_handleu   s:     KK	BA	Bhh33DGG<r   c                     U R                   c   S5       e[        R                  R                  U R                   5        SU l         g)zfDeregisters file descriptor from cuFile Driver.

This is a wrapper around ``cuFileHandleDeregister``.
Nz2Cannot deregister a handle that is not registered.)r/   r   r    r   r7   s    r   r5   GdsFile.deregister_handle   s=     KK#	@?	@#''4r   storageoffsetc                     U R                   c   S5       e[        R                  R                  U R                   X5        g)a=  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/   r   r    r   r1   r>   r?   s      r   load_storageGdsFile.load_storage   s8     KK#	BA	B#""4;;@r   c                     U R                   c   S5       e[        R                  R                  U R                   X5        g)a%  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/   r   r    r   rA   s      r   save_storageGdsFile.save_storage   s8     KK#	@?	@#""4;;@r   )r.   r%   r&   r/   )r   N)r   )__name__
__module____qualname____firstlineno____doc__strintr2   r8   r0   r5   r   rB   rE   __static_attributes__r   r   r   r   r   G   sk    > S 
=	AG AS A AAG AS A A Ar   r   )r+   r)   typingr   r   r   torch.typesr   r	   listrL   __annotations__r   hasattrr    __dict__r   r   r   r   r   r   <module>rU      s   	 
 %  c C H  uxx/00uxx!9::::uxx!78888uxx!9::::uxx!45555uxx!4555509:P0QEHH,-2;<T2UEHH./09:P0QEHH,-2;<T2UEHH./-67J-KEHH)*-67J-KEHH)*%7 %t % 'W ' '"_A _Ar   