3
I4W^”(  ã            %   @   sö  d Z ddlZddlZddlZddlmZ ddlmZmZ ddl	m
Z
 ddlmZ dd	d
dddddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,g%ZddlZyddlZW n ek
rÆ   Y nX ejƒ d-k�r,d.d/„ Zejjejd0d1ƒZejjejjeƒd2ƒZeeeƒ ejd3 gZd4jeƒejd3< ndeed5ƒ �sHeed6ƒ �rvyddlZW n  ek
�rt   ddl j!ZY nX ej"ƒ Z#ej$ej%ej&B ƒ [dd7l'T ed8d9„ e(e)ƒD ƒ7 Zejƒ d-k�rÊej$e#ƒ [#d:d„ Z*d;d	„ Z+d<d
„ Z,d=d„ Z-d>d?„ Z.dd@l/m0Z0m1Z1m2Z2m3Z3m4Z4 ddAl5m6Z6m7Z7 ddBl8m9Z9 ddCl:m;Z; ddDl<m=Z= G dEd„ de)j>e=ƒZ?G dFd„ de)j@e=ƒZAG dGdH„ dHe)jBe=ƒZCG dId„ de)jDe=ƒZEG dJd„ de)jFe=ƒZGG dKd „ d e)jHe=ƒZIG dLd!„ d!e)jJe=ƒZKG dMd"„ d"e)jLe=ƒZMG dNd#„ d#e)jNe=ƒZOG dOdP„ dPe)jPe=ƒZQG dQdR„ dRe)jRe=ƒZSG dSdT„ dTe)jTe=ƒZUG dUdV„ dVe)jVe=ƒZWe?eAeEeGeIeKeMeCeOeSeUeWeQhZXeYƒ ZZdWdX„ Z[e)j\e[ƒ ƒ [[x6e(e)j]ƒD ](Z^e^j_dYƒ�r �qŒe`e)j]e^ƒeaƒ e^< �qŒW dd7lbT [>[@[D[F[H[J[L[N[R[PddlcZdddleZdddZlemfZfmgZgmhZh ddliZdddljZdddlkZdddllZdddlmZdddlnZdddloZdddlpZdddlqZdddlrZdddlsZdddltZdddluZdddlvZdddlwZdddlxZdddlyZdddlzZdddl{Zdddl|Zdddl}Zde)j~eedjXƒƒ dd[l€m�Z�m‚Z‚mƒZƒ [�[‚[ƒd\d]„ Z„dd^l…m†Z† dd_l‡mˆZˆ ddl‰ZddS )`a{  
The torch package contains data structures for multi-dimensional
tensors and mathematical operations over these are defined.
Additionally, it provides many utilities for efficient serializing of
Tensors and arbitrary types, and other useful utilities.

It has a CUDA counterpart, that enables you to run your tensor computations
on an NVIDIA GPU with compute capability >= 3.0.
é    Né   )Ú_import_dotted_name)Úget_file_pathÚ#prepare_multiprocessing_environment)Ú__version__)Ústring_classesÚtypenameÚ	is_tensorÚ
is_storageÚset_default_tensor_typeÚset_rng_stateÚget_rng_stateÚmanual_seedÚinitial_seedÚseedÚsaveÚloadÚset_printoptionsÚchunkÚsplitÚstackÚmatmulÚno_gradÚenable_gradZrandZrandnÚDoubleStorageÚFloatStorageÚLongStorageÚ
IntStorageÚShortStorageÚCharStorageÚByteStorageÚBoolStorageZDoubleTensorZFloatTensorZ
LongTensorZ	IntTensorZShortTensorZ
CharTensorZ
ByteTensorZ
BoolTensorÚTensorÚWindowsc              C   s0   t jddƒ} t jj| ƒr(t jj| ddƒS dS d S )NZNVTOOLSEXT_PATHz.C:\Program Files\NVIDIA Corporation\NvToolsExtÚbinZx64Ú )Ú	_dl_flagsÚgetenvÚpathÚexistsÚjoin)ZNVTOOLEXT_HOME© r+   ú//tmp/pip-build-e66j97b2/torch/torch/__init__.pyÚget_nvToolsExt_path2   s    r-   ÚLibraryr$   ÚlibÚPATHú;ÚRTLD_GLOBALÚ	RTLD_LAZY)Ú*c             C   s(   g | ] }|d  dkr|j dƒ r|‘qS )r   Ú_ZBase)Úendswith)Ú.0Únamer+   r+   r,   ú
<listcomp>S   s    r9   c             C   s‚   t | tjƒr| jƒ S d}d}t| dƒrN| jdkrN| jdkrN| jd k	rN| jd }t| dƒr`| j}nt| dƒrr| j}n| jj}|| S )Nr%   Ú
__module__ÚbuiltinsÚ__builtin__Ú.Ú__qualname__Ú__name__)	Ú
isinstanceÚtorchr"   ÚtypeÚhasattrr:   r>   r?   Ú	__class__)ÚoÚmoduleÚ
class_namer+   r+   r,   r   `   s    


c             C   s   t | tjƒS )z_Returns True if `obj` is a PyTorch tensor.

    Args:
        obj (Object): Object to test
    )r@   rA   r"   )Úobjr+   r+   r,   r	   t   s    c             C   s   t | ƒtkS )zgReturns True if `obj` is a PyTorch storage object.

    Args:
        obj (Object): Object to test
    )rB   Ú_storage_classes)rH   r+   r+   r,   r
   }   s    c             C   s    t | tƒrt| ƒ} tj| ƒ dS )aˆ  Sets the default ``torch.Tensor`` type to floating point tensor type
    ``t``. This type will also be used as default floating point type for
    type inference in :func:`torch.tensor`.

    The default floating point tensor type is initially ``torch.FloatTensor``.

    Args:
        t (type or string): the floating point tensor type or its name

    Example::

        >>> torch.tensor([1.2, 3]).dtype    # initial default for floating point is torch.float32
        torch.float32
        >>> torch.set_default_tensor_type(torch.DoubleTensor)
        >>> torch.tensor([1.2, 3]).dtype    # a new floating point tensor
        torch.float64

    N)r@   Ú_string_classesr   Ú_CZ_set_default_tensor_type)Útr+   r+   r,   r   †   s    
c             C   s   t j| ƒ dS )al  Sets the default floating point dtype to :attr:`d`. This type will be
    used as default floating point type for type inference in
    :func:`torch.tensor`.

    The default floating point dtype is initially ``torch.float32``.

    Args:
        d (:class:`torch.dtype`): the floating point dtype to make the default

    Example::

        >>> torch.tensor([1.2, 3]).dtype           # initial default for floating point is torch.float32
        torch.float32
        >>> torch.set_default_dtype(torch.float64)
        >>> torch.tensor([1.2, 3]).dtype           # a new floating point tensor
        torch.float64

    N)rK   Z_set_default_dtype)Údr+   r+   r,   Úset_default_dtypež   s    rN   )r   r   r   r   r   )r   r   )r   )r"   )Ú_StorageBasec               @   s   e Zd ZdS )r   N)r?   r:   r>   r+   r+   r+   r,   r   À   s   c               @   s   e Zd ZdS )r   N)r?   r:   r>   r+   r+   r+   r,   r   Ä   s   c               @   s   e Zd ZdS )ÚHalfStorageN)r?   r:   r>   r+   r+   r+   r,   rP   È   s   rP   c               @   s   e Zd ZdS )r   N)r?   r:   r>   r+   r+   r+   r,   r   Ì   s   c               @   s   e Zd ZdS )r   N)r?   r:   r>   r+   r+   r+   r,   r   Ð   s   c               @   s   e Zd ZdS )r   N)r?   r:   r>   r+   r+   r+   r,   r   Ô   s   c               @   s   e Zd ZdS )r   N)r?   r:   r>   r+   r+   r+   r,   r   Ø   s   c               @   s   e Zd ZdS )r    N)r?   r:   r>   r+   r+   r+   r,   r    Ü   s   c               @   s   e Zd ZdS )r!   N)r?   r:   r>   r+   r+   r+   r,   r!   à   s   c               @   s   e Zd ZdS )ÚBFloat16StorageN)r?   r:   r>   r+   r+   r+   r,   rQ   ä   s   rQ   c               @   s   e Zd ZdS )ÚQUInt8StorageN)r?   r:   r>   r+   r+   r+   r,   rR   è   s   rR   c               @   s   e Zd ZdS )ÚQInt8StorageN)r?   r:   r>   r+   r+   r+   r,   rS   ë   s   rS   c               @   s   e Zd ZdS )ÚQInt32StorageN)r?   r:   r>   r+   r+   r+   r,   rT   î   s   rT   c              C   sJ   t jƒ dkrdS tdddƒ} ttdƒƒ tjj| ƒs@td|  ƒ‚| jdƒS )Nr#   ó    rA   r$   Ztorch_shm_managerz$Unable to find torch_shm_manager at zutf-8)	ÚplatformÚsystemr   r   Úosr(   r)   ÚRuntimeErrorÚencode)r(   r+   r+   r,   Úmanager_path   s    r[   Ú__)r   r   Úset_grad_enabled)Ú_torch_docsÚ_tensor_docsÚ_storage_docsc               C   s   t jS )z?Returns whether PyTorch was built with _GLIBCXX_USE_CXX11_ABI=1)rK   Z_GLIBCXX_USE_CXX11_ABIr+   r+   r+   r,   Úcompiled_with_cxx11_abiN  s    ra   )Úops)Úclasses)ŠÚ__doc__rX   ÚsysrV   Ú_utilsr   Z_utils_internalr   r   Úversionr   Z_sixr   rJ   Ú__all__r&   ZnumpyZ_npÚImportErrorrW   r-   r(   r*   Úexec_prefixZpy_dll_pathÚdirnameÚ__file__Zth_dll_pathÚenvironZ	dll_pathsrC   ZDLFCNZ	torch._dlZ_dlÚgetdlopenflagsZ	old_flagsÚsetdlopenflagsr2   r3   Ztorch._CÚdirrK   r   r	   r
   r   rN   Úrandomr   r   r   r   r   Zserializationr   r   Z_tensor_strr   Ztensorr"   ZstoragerO   ZDoubleStorageBaser   ZFloatStorageBaser   ZHalfStorageBaserP   ZLongStorageBaser   ZIntStorageBaser   ZShortStorageBaser   ZCharStorageBaser   ZByteStorageBaser    ZBoolStorageBaser!   ZBFloat16StorageBaserQ   ZQUInt8StorageBaserR   ZQInt8StorageBaserS   ZQInt32StorageBaserT   rI   ÚsetZ_tensor_classesr[   Z_initExtensionZ_VariableFunctionsr8   Ú
startswithÚgetattrÚglobalsZ
functionalZ
torch.cudarA   Ztorch.autogradr   r   r]   Ztorch.nnZtorch.nn.intrinsicZtorch.nn.quantizedZtorch.optimZtorch.multiprocessingZtorch.sparseZtorch.utils.backcompatZ
torch.onnxZ	torch.jitZ	torch.hubZtorch.randomZtorch.distributionsZtorch.testingZtorch.backends.cudaZtorch.backends.mklZtorch.backends.openmpZtorch.backends.quantizedZtorch.quantizationZtorch.utils.dataZtorch.__config__Ztorch.__future__Z_init_namesÚlistr%   r^   r_   r`   ra   Z
torch._opsrb   Ztorch._classesrc   Ztorch.quasirandomr+   r+   r+   r,   Ú<module>   sæ   


		
