U
    d                     @   sX   d dl Z d dlZd dlmZ d dlmZmZ dddZe Z	e Z
dd Zdd	d
ZdS )    N)Lock)coreextension_loaderTc                 C   s.   t j| std|  dS t| |d 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)trigger_lazy)ospathexistsprintformat
_init_impl)namer    r   8/tmp/pip-unpacked-wheel-ua33x9lu/caffe2/python/dyndep.pyInitOpsLibrary   s    r   c                   C   s   t S N)_IMPORTED_DYNDEPSr   r   r   r   GetImportedOpsLibraries*   s    r   c              
   C   sF   t 8 t|  t  t|  W 5 Q R X t| W 5 Q R X d S r   )	dll_lockr   addr   ZDlopenGuardctypesCDLLr   ZRefreshRegisteredOperators)r   r   r   r   r   r   .   s
    

r   )T)T)r   r   	threadingr   Zcaffe2.pythonr   r   r   setr   r   r   r   r   r   r   r   <module>   s   
