o
    ?e"                     @   s   d Z ddlZddlZddlZddlZddlZddlZddlmZ	 ddl
mZ ddlmZ ddlmZ ddlmZ edd	d Zejdd
dedgddd Zdd Zeddd Zdd Zeddd ZdS )z(Function for loading TensorFlow plugins.    N)pywrap_tf_session)context)_pywrap_python_op_gen)deprecation)	tf_exportload_op_libraryc              	   C   s   t | }ztt |}W t | nt | w t| }|t	j
v r,t	j
| S tj|d}tj|}t||j t|dd |t	j
|< |S )aC  Loads a TensorFlow plugin, containing custom ops and kernels.

  Pass "library_filename" to a platform-specific mechanism for dynamically
  loading a library. The rules for determining the exact location of the
  library are platform-specific and are not documented here. When the
  library is loaded, ops and kernels registered in the library via the
  `REGISTER_*` macros are made available in the TensorFlow process. Note
  that ops with the same name as an existing op are rejected and not
  registered with the process.

  Args:
    library_filename: Path to the plugin.
      Relative or absolute filesystem path to a dynamic library file.

  Returns:
    A python module containing the Python wrappers for Ops defined in
    the plugin.

  Raises:
    RuntimeError: when unable to load the library or get the python wrappers.
  NZ_IS_TENSORFLOW_PLUGINT)py_tfTF_LoadLibraryr   ZGetPythonWrappersZTF_GetOpListZTF_DeleteLibraryHandlehashlibsha1	hexdigestsysmodules	importlib	machinery
ModuleSpecutilmodule_from_specexec__dict__setattr)library_filenameZ
lib_handlewrappersmodule_nameZmodule_specmodule r   i/home/www/facesmatcher.com/pyenv/lib/python3.10/site-packages/tensorflow/python/framework/load_library.pyr      s   



zUse `tf.load_library` instead.)dateZinstructionsload_file_system_library)v1c                 C   s   t |  dS )a  Loads a TensorFlow plugin, containing file system implementation.

  Pass `library_filename` to a platform-specific mechanism for dynamically
  loading a library. The rules for determining the exact location of the
  library are platform-specific and are not documented here.

  Args:
    library_filename: Path to the plugin.
      Relative or absolute filesystem path to a dynamic library file.

  Returns:
    None.

  Raises:
    RuntimeError: when unable to load the library.
  N)r   r	   )r   r   r   r   r   M   s   c                 C   sp   t  dkr | drdS | d}|dkrdS | |d   S t  dkr+| d	S t  d
kr6| dS dS )zECheck the file to see if it is a shared object, only using extension.Linuxz.soTz.so.F   Darwinz.dylibWindowsz.dll)platformsystemendswithrfind	isdecimal)filenameindexr   r   r   _is_shared_objectd   s   



r,   load_libraryc                    sb   t j r*t j rt  } fdd|D }n g}|D ]}t| q dS ttj	d )ar  Loads a TensorFlow plugin.

  "library_location" can be a path to a specific shared object, or a folder.
  If it is a folder, all shared objects that are named "libtfkernel*" will be
  loaded. When the library is loaded, kernels registered in the library via the
  `REGISTER_*` macros are made available in the TensorFlow process.

  Args:
    library_location: Path to the plugin or the folder of plugins.
      Relative or absolute filesystem path to a dynamic library file or folder.

  Returns:
    None

  Raises:
    OSError: When the file to be loaded is not found.
    RuntimeError: when unable to load the library.
  c                    "   g | ]}t |rtj |qS r   r,   ospathjoin.0flibrary_locationr   r   
<listcomp>   s    z load_library.<locals>.<listcomp>z@The file or folder to load kernel libraries from does not exist.N)
r0   r1   existsisdirlistdirr   r	   OSErrorerrnoENOENT)r7   directory_contentsZkernel_librarieslibr   r6   r   r-   x   s   

c                    sn   t j r0t j rt  } fdd|D }n g}|D ]}t| q t   dS t	t
jd )am  Loads a TensorFlow PluggableDevice plugin.

  "library_location" can be a path to a specific shared object, or a folder.
  If it is a folder, all shared objects will be loaded. when the library is
  loaded, devices/kernels registered in the library via StreamExecutor C API
  and Kernel/Op Registration C API are made available in TensorFlow process.

  Args:
    library_location: Path to the plugin or folder of plugins. Relative or
      absolute filesystem path to a dynamic library file or folder.

  Raises:
    OSError: When the file to be loaded is not found.
    RuntimeError: when unable to load the library.
  c                    r.   r   r/   r3   r6   r   r   r8      s    z1load_pluggable_device_library.<locals>.<listcomp>zJThe file or folder to load pluggable device libraries from does not exist.N)r0   r1   r9   r:   r;   r   ZTF_LoadPluggableDeviceLibraryr   Zreinitialize_physical_devicesr<   r=   r>   )r7   r?   Zpluggable_device_librariesr@   r   r6   r   load_pluggable_device_library   s   

rA   z'experimental.register_filesystem_pluginc                 C   s(   t j| rt|  dS ttjd| )a0  Loads a TensorFlow FileSystem plugin.

  Args:
    plugin_location: Path to the plugin. Relative or absolute filesystem plugin
      path to a dynamic library file.

  Returns:
    None

  Raises:
    OSError: When the file to be loaded is not found.
    RuntimeError: when unable to load the library.
  z8The file to load file system plugin from does not exist.N)r0   r1   r9   r   ZTF_RegisterFilesystemPluginr<   r=   r>   )Zplugin_locationr   r   r   register_filesystem_plugin   s   rB   )__doc__r=   r
   r   r0   r%   r   Ztensorflow.python.clientr   r   Ztensorflow.python.eagerr   Ztensorflow.python.frameworkr   Ztensorflow.python.utilr   Z tensorflow.python.util.tf_exportr   r   
deprecatedr   r,   r-   rA   rB   r   r   r   r   <module>   s2   
-

''