3
I4W^A  ã               @   s„   d dl mZ d dl mZ d dl mZ d dl mZ d dlZd dlZd dlmZ d dl	m
Z
mZ dd	„ Zeƒ Zeƒ Zd
d„ Zdd„ ZdS )é    )Úabsolute_import)Údivision)Úprint_function)Úunicode_literalsN)ÚLock)ÚcoreÚextension_loaderc             C   s*   t jj| ƒstdj| ƒƒ dS t| ƒ dS )aO  Loads a dynamic library that contains custom operators into Caffe2.

    Since Caffe2 uses static variable registration, you can optionally load a
    separate .so file that contains custom operators and registers that into
    the caffe2 core binary. In C++, this is usually done by either declaring
    dependency during compilation time, or via dynload. This allows us to do
    registration similarly on the Python side.

    Args:
        name: a name that ends in .so, such as "my_custom_op.so". Otherwise,
            the command will simply be ignored.
    Returns:
        None
    z&Ignoring {} as it is not a valid file.N)ÚosÚpathÚexistsÚprintÚformatÚ
_init_impl)Úname© r   ú5/tmp/pip-build-e66j97b2/torch/caffe2/python/dyndep.pyÚInitOpsLibrary   s    r   c               C   s   t S )N)Ú_IMPORTED_DYNDEPSr   r   r   r   ÚGetImportedOpsLibraries*   s    r   c             C   sD   t �6 tj| ƒ tjƒ � tj| ƒ W d Q R X tjƒ  W d Q R X d S )N)	Údll_lockr   Úaddr   ZDlopenGuardÚctypesÚCDLLr   ZRefreshRegisteredOperators)r
   r   r   r   r   .   s
    

r   )Ú
__future__r   r   r   r   r   r	   Ú	threadingr   Zcaffe2.pythonr   r   r   Úsetr   r   r   r   r   r   r   r   Ú<module>   s   