a
    –¥»aý  ã                   @   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   úN/home/yuhw/wc/pochoir/venv/lib/python3.9/site-packages/caffe2/python/dyndep.pyÚInitOpsLibrary   s    r   c                   C   s   t S ©N)Ú_IMPORTED_DYNDEPSr   r   r   r   ÚGetImportedOpsLibraries*   s    r   c              	   C   sn   t �V t | ¡ t ¡ � t | ¡ W d   ƒ n1 s80    Y  t |¡ W d   ƒ n1 s`0    Y  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   
