
    BVh"                     "   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	        Z ej&                  dd
       edg      d               Zd Z ed      d        Zd Z ed      d        Zy)z(Function for loading TensorFlow plugins.    N)pywrap_tf_session)context)_pywrap_python_op_gen)deprecation)	tf_exportload_op_libraryc                 Z   t        j                  |       }	 t        j                  t        j                  |            }t        j
                  |       t        j                  |      j                         }|t        j                  v rt        j                  |   S t        j                  j                  |d      }t        j                  j                  |      }t!        ||j"                         t%        |dd       |t        j                  |<   |S # t        j
                  |       w xY w)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.
  N_IS_TENSORFLOW_PLUGINT)py_tfTF_LoadLibraryr   GetPythonWrappersTF_GetOpListTF_DeleteLibraryHandlehashlibsha1	hexdigestsysmodules	importlib	machinery
ModuleSpecutilmodule_from_specexec__dict__setattr)library_filename
lib_handlewrappersmodule_namemodule_specmodules         X/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/python/framework/load_library.pyr   r      s    . ##$45*-$66:&(H
 
  , X&002+CKK;;{####..{DA+>>**;7&x!	&)40##++k	- 
  ,s   (D D*zUse `tf.load_library` instead.)dateinstructionsload_file_system_library)v1c                 .    t        j                  |        y)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   s    r#   r&   r&   M   s    ( '(    c                 P   t        j                         dk(  r?| j                  d      ry| j                  d      }|dk(  ry| |dz      j	                         S t        j                         dk(  r| j                  d	      S t        j                         d
k(  r| j                  d      S y)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indexs     r#   _is_shared_objectr7   d   s    __'!nnV$e	" 	",,..H$X&&I%V$$r)   load_libraryc                    t         j                  j                  |       rt         j                  j                  |       rNt        j                  |       }|D cg c]-  }t        |      r t         j                  j                  | |      / }}n| g}|D ]  }t        j                  |        yt        t        j                  d|       c c}w )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.
  z@The file or folder to load kernel libraries from does not exist.N)ospathexistsisdirlistdirr7   joinr   r   OSErrorerrnoENOENT)library_locationdirectory_contentsfkernel_librarieslibs        r#   r8   r8   x   s    ( WW^^$%	ww}}%&::&67 6H#01q! '',,'
+# # ++  3  J #s   2Cc                    t         j                  j                  |       rt         j                  j                  |       rNt        j                  |       }|D cg c]-  }t        |      r t         j                  j                  | |      / }}n| g}|D ]  }t        j                  |        t        j                         j                          yt        t        j                  d|       c c}w )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.
  zJThe file or folder to load pluggable device libraries from does not exist.N)r:   r;   r<   r=   r>   r7   r?   r   TF_LoadPluggableDeviceLibraryr   reinitialize_physical_devicesr@   rA   rB   )rC   rD   rE   pluggable_device_librariesrG   s        r#   load_pluggable_device_libraryrL      s      WW^^$%	ww}}%&::&67 &$q! '',,'
+$  $ %5#5 ) /))#./ OO335
	"$ $$s   2C*z'experimental.register_filesystem_pluginc                     t         j                  j                  |       rt        j                  |        y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)r:   r;   r<   r   TF_RegisterFilesystemPluginr@   rA   rB   )plugin_locations    r#   register_filesystem_pluginrP      s=     WW^^O$	%%o6 %,,L!# #r)   )__doc__rA   r   r   r:   r0   r   tensorflow.python.clientr   r   tensorflow.python.eagerr   tensorflow.python.frameworkr   tensorflow.python.utilr    tensorflow.python.util.tf_exportr   r   
deprecatedr&   r7   r8   rL   rP    r)   r#   <module>rY      s     /    	  
 ? + = . 6 * *Z T%EG
)*+) ,G)(( >$ $N$$N 45# 6#r)   