
    BVhe                         d Z ddlZej                  j                  e      d   j                  ej                  j                  dd            sddlmZ ddl	m
Z ddlmZ n	ddlm
Z d Z ed	       G d
 d             Zy)z+This tool analyzes a TensorFlow Lite graph.    Ntflite_runtimeanalyzer)wrap_converter)_pywrap_analyzer_wrapper)	tf_exportc                      ~ ~d S )Nc                     | S )N )xs    O/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/lite/python/analyzer.py<lambda>z_tf_export.<locals>.<lambda>    s    Q     r
   )r   kwargss     r   
_tf_exportr      s    	6r   zlite.experimental.Analyzerc                   (    e Zd ZdZe	 	 	 dd       Zy)ModelAnalyzerup  Provides a collection of TFLite model analyzer tools.

  Example:

  ```python
  model = tf.keras.applications.MobileNetV3Large()
  fb_model = tf.lite.TFLiteConverterV2.from_keras_model(model).convert()
  tf.lite.experimental.Analyzer.analyze(model_content=fb_model)
  # === TFLite ModelAnalyzer ===
  #
  # Your TFLite model has ‘1’ subgraph(s). In the subgraph description below,
  # T# represents the Tensor numbers. For example, in Subgraph#0, the MUL op
  # takes tensor #0 and tensor #19 as input and produces tensor #136 as output.
  #
  # Subgraph#0 main(T#0) -> [T#263]
  #   Op#0 MUL(T#0, T#19) -> [T#136]
  #   Op#1 ADD(T#136, T#18) -> [T#137]
  #   Op#2 CONV_2D(T#137, T#44, T#93) -> [T#138]
  #   Op#3 HARD_SWISH(T#138) -> [T#139]
  #   Op#4 DEPTHWISE_CONV_2D(T#139, T#94, T#24) -> [T#140]
  #   ...
  ```

  WARNING: Experimental interface, subject to change.
  Nc                    | s|st        d      | rt        d|  d       | }d}nt        d       |}d}|j                  dd      r t        t        j                  ||             yt        t        j                  |||             y)	a  Analyzes the given tflite_model with dumping model structure.

    This tool provides a way to understand users' TFLite flatbuffer model by
    dumping internal graph structure. It also provides additional features
    like checking GPU delegate compatibility.

    WARNING: Experimental interface, subject to change.
             The output format is not guaranteed to stay stable, so don't
             write scripts to this.

    Args:
      model_path: TFLite flatbuffer model path.
      model_content: TFLite flatbuffer model object.
      gpu_compatibility: Whether to check GPU delegate compatibility.
      **kwargs: Experimental keyword arguments to analyze API.

    Returns:
      Print analyzed report via console output.
    z4neither `model_path` nor `model_content` is providedz=== z ===
Tz=== TFLite ModelAnalyzer ===
Fexperimental_use_mlirN)
ValueErrorprintgetr    wrapped_flat_buffer_file_to_mlir_analyzer_wrapperr   )
model_pathmodel_contentgpu_compatibilityr   tflite_modelinput_is_filepaths         r   analyzezModelAnalyzer.analyze?   s    0 mMNNd:,f%&l,-"lzz)51

9
9- 

)
),8I*;=>r   )NNF)__name__
__module____qualname____doc__staticmethodr   r
   r   r   r   r   #   s$    4   %+> +>r   r   )r#   ospathsplitext__file__endswithjoin$tensorflow.compiler.mlir.lite.pythonr   'tensorflow.lite.python.analyzer_wrapperr   r    tensorflow.python.util.tf_exportr   r   r   r   r
   r   r   <module>r.      s}    2 	 
ww!!$--GGLL!:.0 BcF K
 ()G> G> *G>r   