parameters: (
      saved_model_dir: Union[str, os.PathLike],
      *,  # Require remaining arguments to be keyword-only.
      inference_input_type: tf.DType = tf.float32,
      inference_output_type: tf.DType = tf.float32,
      target: str = "arm",
      experimental_default_int8_range: Optional[Tuple[float, float]] = None,
  )
return_statement: return tflite_buffer
docstring: Converts a SavedModel to TFLite flatbuffer.
  
      !!! example
          ```python
          tflite_model = convert_saved_model(saved_model_dir)
          with open("/tmp/my_model.tflite", "wb") as f:
              f.write(tflite_model)
          ```
  
      # Arguments
          saved_model_dir: SavedModel directory to convert.
          inference_input_type: Data type of the input layer. Defaults to `tf.float32`,
              must be either `tf.float32` or `tf.int8`.
          inference_output_type: Data type of the output layer. Defaults to `tf.float32`,
              must be either `tf.float32` or `tf.int8`.
          target: Target hardware platform. Defaults to "arm", must be either "arm"
              or "xcore".
          experimental_default_int8_range: Tuple of integers representing `(min, max)`
              range values for all arrays without a specified range. Intended for
              experimenting with quantization via "dummy quantization". (default None)
  
      # Returns
          The converted data in serialized format.
docstring_summary: Converts a SavedModel to TFLite flatbuffer.
docstring_tokens: Converts a SavedModel to TFLite flatbuffer .
function: def convert_saved_model(
      saved_model_dir: Union[str, os.PathLike],
      *,  # Require remaining arguments to be keyword-only.
      inference_input_type: tf.DType = tf.float32,
      inference_output_type: tf.DType = tf.float32,
      target: str = "arm",
      experimental_default_int8_range: Optional[Tuple[float, float]] = None,
  ) -> bytes:
      """Converts a SavedModel to TFLite flatbuffer.
  
      !!! example
          ```python
          tflite_model = convert_saved_model(saved_model_dir)
          with open("/tmp/my_model.tflite", "wb") as f:
              f.write(tflite_model)
          ```
  
      # Arguments
          saved_model_dir: SavedModel directory to convert.
          inference_input_type: Data type of the input layer. Defaults to `tf.float32`,
              must be either `tf.float32` or `tf.int8`.
          inference_output_type: Data type of the output layer. Defaults to `tf.float32`,
              must be either `tf.float32` or `tf.int8`.
          target: Target hardware platform. Defaults to "arm", must be either "arm"
              or "xcore".
          experimental_default_int8_range: Tuple of integers representing `(min, max)`
              range values for all arrays without a specified range. Intended for
              experimenting with quantization via "dummy quantization". (default None)
  
      # Returns
          The converted data in serialized format.
      """
      if version.parse(tf.__version__) < version.parse("2.2"):
          raise RuntimeError(
              "TensorFlow 2.2 or newer is required for saved model conversion."
          )
      _validate_options(
          inference_input_type=inference_input_type,
          inference_output_type=inference_output_type,
          target=target,
          experimental_default_int8_range=experimental_default_int8_range,
      )
  
      saved_model_dir = str(saved_model_dir)
      saved_model_tags = [tf.saved_model.SERVING]
      saved_model_exported_names = [tf.saved_model.DEFAULT_SERVING_SIGNATURE_DEF_KEY]
  
      from tensorflow.python.saved_model import loader_impl
  
      saved_model_pb, _ = loader_impl.parse_saved_model_with_debug_info(saved_model_dir)
  
      saved_model_version = saved_model_pb.saved_model_schema_version
      if saved_model_version not in (1, 2):
          raise ValueError(
              f"SavedModel file format({saved_model_version}) is not supported"
          )
  
      tflite_buffer = convert_saved_model_to_tflite_flatbuffer(
          saved_model_dir,
          saved_model_tags,
          saved_model_exported_names,
          saved_model_version,
          target,
          experimental_default_int8_range,
      )
  
      if inference_input_type != tf.float32 or inference_output_type != tf.float32:
          tflite_buffer = modify_integer_quantized_model_io_type(
              tflite_buffer,
              inference_input_type=inference_input_type,
              inference_output_type=inference_output_type,
          )
  
      return tflite_buffer
function_tokens: def convert_saved_model ( saved_model_dir : Union [ str , os . PathLike ] , * , # Require remaining arguments to be keyword-only. inference_input_type : tf . DType = tf . float32 , inference_output_type : tf . DType = tf . float32 , target : str = "arm" , experimental_default_int8_range : Optional [ Tuple [ float , float ] ] = None , ) -> bytes : if version . parse ( tf . __version__ ) < version . parse ( "2.2" ) : raise RuntimeError ( "TensorFlow 2.2 or newer is required for saved model conversion." ) _validate_options ( inference_input_type = inference_input_type , inference_output_type = inference_output_type , target = target , experimental_default_int8_range = experimental_default_int8_range , ) saved_model_dir = str ( saved_model_dir ) saved_model_tags = [ tf . saved_model . SERVING ] saved_model_exported_names = [ tf . saved_model . DEFAULT_SERVING_SIGNATURE_DEF_KEY ] from tensorflow . python . saved_model import loader_impl saved_model_pb , _ = loader_impl . parse_saved_model_with_debug_info ( saved_model_dir ) saved_model_version = saved_model_pb . saved_model_schema_version if saved_model_version not in ( 1 , 2 ) : raise ValueError ( f"SavedModel file format({saved_model_version}) is not supported" ) tflite_buffer = convert_saved_model_to_tflite_flatbuffer ( saved_model_dir , saved_model_tags , saved_model_exported_names , saved_model_version , target , experimental_default_int8_range , ) if inference_input_type != tf . float32 or inference_output_type != tf . float32 : tflite_buffer = modify_integer_quantized_model_io_type ( tflite_buffer , inference_input_type = inference_input_type , inference_output_type = inference_output_type , ) return tflite_buffer