
    AVh                        d Z ddlmZ ddlmZ  ed      	 dd       Z ed      	 	 dd       Z ed      	 dd	       Z ed
      	 	 dd       Z ed      dd       Z	 ed      d        Z
 ed      	 	 	 dd       Zy)zDmlir is an experimental library that provides support APIs for MLIR.    )pywrap_mlir)	tf_exportz#mlir.experimental.convert_graph_defc                 0    t        j                  | ||      S )aK  Import a GraphDef and convert it to a textual MLIR module.

  This API is only intended for inspecting the internals of TensorFlow and the
  string returned is at the moment intended for debugging purposes.

  Args:
    graph_def: An object of type graph_pb2.GraphDef or a textual proto
      representation of a valid GraphDef.
    pass_pipeline: A textual description of an MLIR Pass Pipeline to run on the
      module, see MLIR documentation for the [textual pass pipeline
      syntax](https://mlir.llvm.org/docs/PassManagement/#textual-pass-pipeline-specification).
    show_debug_info: Whether to include locations in the emitted textual form.

  Returns:
    A textual representation of the MLIR module corresponding to the graphdef.

  Raises:
    InvalidArgumentError: if graph_def is invalid or cannot be converted to
      MLIR.
  )r   import_graphdef)	graph_defpass_pipelineshow_debug_infos      T/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/python/compiler/mlir/mlir.pyconvert_graph_defr      s    0 
	$	$Y	OO    z"mlir.experimental.convert_functionc                 0    t        j                  | ||      S )a  Import a ConcreteFunction and convert it to a textual MLIR module.

  This API is only intended for inspecting the internals of TensorFlow and the
  string returned is at the moment intended for debugging purposes.

  A [tf.function](https://www.tensorflow.org/api_docs/python/tf/function) can be
  imported and converted from TensorFlow to TensorFlow MLIR with this API by
  extracting its ConcreteFunction (eagerly-executing wrapper around a
  [tf.Graph](https://www.tensorflow.org/api_docs/python/tf/Graph)).

  For example:
  >>> @tf.function
  ... def add(a, b):
  ...   return a + b

  >>> concrete_function = add.get_concrete_function(
  ...     tf.TensorSpec(None, tf.dtypes.float32),
  ...     tf.TensorSpec(None, tf.dtypes.float32))
  >>> tf.mlir.experimental.convert_function(concrete_function)
  '...module attributes {...} {...}...'

  Args:
    concrete_function: An object of type ConcreteFunction.
    pass_pipeline: A textual description of an MLIR Pass Pipeline to run on the
      module, see MLIR documentation for the [textual pass pipeline
      syntax](https://mlir.llvm.org/docs/PassManagement/#textual-pass-pipeline-specification).
    show_debug_info: Whether to include locations in the emitted textual form.

  Returns:
    A textual representation of the MLIR module corresponding to the
    ConcreteFunction.

  Raises:
    InvalidArgumentError: if concrete_function is invalid or cannot be converted
      to MLIR.
  )r   import_function)concrete_functionr   r	   s      r
   convert_functionr   0   s    T 
	$	$
 r   z%mlir.experimental.convert_saved_modelc                 0    t        j                  | ||      S )a0  Converts a SavedModel to MLIR module.

  Args:
    saved_model_path: Path to SavedModel.
    exported_names: Names to export.
    show_debug_info: Whether to include locations in the emitted textual form.

  Returns:
    A textual representation of the MLIR module corresponding to the
    SavedModel.
  )r   (experimental_convert_saved_model_to_mlir)saved_model_pathexported_namesr	   s      r
   convert_saved_modelr   _   s     
	=	=
 r   z(mlir.experimental.convert_saved_model_v1c           	      8    t        j                  | ||||||      S )ax  Converts a v1 SavedModel to MLIR module.

  Args:
    saved_model_path: Path to SavedModel.
    exported_names: Names to export.
    tags: MetaGraphDef to be loaded is identified by the supplied tags.
    lift_variables: Whether to promote tf.VarHandleOp to resource arguments.
    include_variables_in_initializers: Keeps the variables in initializers
      before lifting variables.
    upgrade_legacy: Functionalize the input graph before importing.
    show_debug_info: Whether to include locations in the emitted textual form.

  Returns:
    A textual representation of the MLIR module corresponding to the
    SavedModule.
  )r   +experimental_convert_saved_model_v1_to_mlir)r   r   tagslift_variables!include_variables_in_initializersupgrade_legacyr	   s          r
   convert_saved_model_v1r   s   s,    4 
	@	@
'
 r   z#mlir.experimental.run_pass_pipelinec                 0    t        j                  | ||      S )aR  Runs a pipeline over input module.

  Args:
    mlir_txt: Textual representation of the MLIR module.
    pass_pipeline: Pass pipeline to run on module.
    show_debug_info: Whether to include locations in the emitted textual form.

  Returns:
    A textual representation of the MLIR module corresponding to the
    transformed module.
  )r   experimental_run_pass_pipeline)mlir_txtr   r	   s      r
   run_pass_pipeliner       s     
	3	3
 r   z mlir.experimental.write_bytecodec                 0    t        j                  | |       y)zWrites an MLIR module out as bytecode.

  Args:
    filename: The filename to write to.
    mlir_txt: The MLIR module in textual format.
  N)r   experimental_write_bytecode)filenamer   s     r
   r"   r"      s     ))(H=r   z)mlir.experimental.tflite_to_tosa_bytecodeNc                 6    t        j                  | ||||       y)a  Converts TFLite flatbuffer to TOSA dialect in MLIR bytecode.

  Args:
    flatbuffer: Path to flatbuffer.
    bytecode: Path to output bytecode.
    use_external_constant: Whether to create `tfl.external_const` instead of
      `tfl.const`.
    ordered_input_arrays:
    ordered_output_arrays: If ordered_output_arrays is not empty, then the
      function will only return nodes in ordered_output_arrays in the same order
  N)r   $experimental_tflite_to_tosa_bytecode)
flatbufferbytecodeuse_external_constantordered_input_arraysordered_output_arrayss        r
   tflite_to_tosa_bytecoder+      s!    & 22r   )ztf-standard-pipelineF)F)TF)FNN)__doc__tensorflow.pythonr    tensorflow.python.util.tf_exportr   r   r   r   r   r    r"   r+    r   r
   <module>r0      s    K ) 6 01EJP 2P4 /0 )+ 1+\ 236; 4& 56 ! 7!H 01 2" -.> /> 67   8r   