o
    ?ev                     @   s   d 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	 dd Z
d	d
 Zee_dd Zee_dd Zee_e	dgddd ZdS )z*Extending CheckpointReader for TensorFlow.    )dtypes)errors_impl)compat)CheckpointReader)	tf_exportc                 C   s   t | }d|v sd|v rtdd|d|v sd|v r"tdd|d|v r-tdd|d|v r8tdd|d|v s@d	|v rGtdd|tdd|tj)
z,Translate the tensor_slice_reader.cc errors.znot found in checkpointz%Failed to find any matching files forNz$Sliced checkpoints are not supportedzData type not supportedzFailed to get matching files onzUnable to open table filez&Failed to find the saved tensor slicesznot convertible to numpy dtype)	strr   ZNotFoundErrorZUnimplementedErrorZInvalidArgumentErrorZDataLossErrorZInternalErrorZOpErrorUNKNOWN)eerror_message r   p/home/www/facesmatcher.com/pyenv/lib/python3.10/site-packages/tensorflow/python/training/py_checkpoint_reader.pyerror_translator   s(   r   c                 C   s   dd |    D S )Nc                 S   s   i | ]
\}}|t |qS r   )r   ZDType).0nameZ	type_enumr   r   r   
<dictcomp>1   s    
z-get_variable_to_dtype_map.<locals>.<dictcomp>)Z_GetVariableToDataTypeMapitems)selfr   r   r   get_variable_to_dtype_map0   s   
r   c                 C   s   |  t|S )N)Z
_HasTensorr   as_bytes)r   
tensor_strr   r   r   
has_tensor9   s   r   c              
   C   sD   z
t | t|W S  ty! } zt| W Y d}~dS d}~ww )z*Get the tensor from the Checkpoint object.N)r   ZCheckpointReader_GetTensorr   r   RuntimeErrorr   )r   r   r	   r   r   r   
get_tensor?   s   
r   ztrain.NewCheckpointReader)v1c              
   C   s@   zt t| W S  ty } zt| W Y d}~dS d}~ww )zA function that returns a CheckPointReader.

  Args:
    filepattern: The filename.

  Returns:
    A CheckpointReader object.
  N)r   r   r   r   r   )Zfilepatternr	   r   r   r   NewCheckpointReaderQ   s   
r   N)__doc__Ztensorflow.python.frameworkr   r   Ztensorflow.python.utilr   Z0tensorflow.python.util._pywrap_checkpoint_readerr   Z tensorflow.python.util.tf_exportr   r   r   r   r   r   r   r   r   r   <module>   s   
