parameters: (self,
                 input_saved_model_dir=None,
                 input_saved_model_tags=None,
                 input_saved_model_signature_key=None,
                 input_graph_def=None,
                 nodes_blacklist=None,
                 session_config=None,
                 max_batch_size=1,
                 max_workspace_size_bytes=DEFAULT_TRT_MAX_WORKSPACE_SIZE_BYTES,
                 precision_mode=TrtPrecisionMode.FP32,
                 minimum_segment_size=3,
                 is_dynamic_op=False,
                 maximum_cached_engines=1,
                 use_calibration=True)
docstring: Initialize the converter.
  
      Args:
        input_saved_model_dir: the directory to load the SavedModel which contains
          the input graph to transforms. Used only when input_graph_def is None.
        input_saved_model_tags: list of tags to load the SavedModel.
        input_saved_model_signature_key: the key of the signature to optimize the
          graph for.
        input_graph_def: a GraphDef object containing a model to be transformed.
          If set to None, the graph will be read from the SavedModel loaded from
          input_saved_model_dir.
        nodes_blacklist: list of node names to prevent the converter from
          touching.
        session_config: the ConfigProto used to create a Session. It's also used
          as a template to create a TRT-enabled ConfigProto for conversion. If not
          specified, a default ConfigProto will be used.
        max_batch_size: max size for the input batch.
        max_workspace_size_bytes: the maximum GPU temporary memory which the TRT
          engine can use at execution time. This corresponds to the
          'workspaceSize' parameter of nvinfer1::IBuilder::setMaxWorkspaceSize().
        precision_mode: one of TrtPrecisionMode.supported_precision_modes().
        minimum_segment_size: the minimum number of nodes required for a subgraph
          to be replaced by TRTEngineOp.
        is_dynamic_op: whether to generate dynamic TRT ops which will build the
          TRT network and engine at run time.
        maximum_cached_engines: max number of cached TRT engines in dynamic TRT
          ops. If the number of cached engines is already at max but none of them
          can serve the input, the TRTEngineOp will fall back to run the TF
          function based on which the TRTEngineOp is created.
        use_calibration: this argument is ignored if precision_mode is not INT8.
          If set to True, a calibration graph will be created to calibrate the
          missing ranges. The calibration graph must be converted to an inference
          graph by running calibration with calibrate(). If set to False,
          quantization nodes will be expected for every tensor in the graph
          (exlcuding those which will be fused). If a range is missing, an error
          will occur. Please note that accuracy may be negatively affected if
          there is a mismatch between which tensors TRT quantizes and which
          tensors were trained with fake quantization.
  
      Raises:
        ValueError: if the combination of the parameters is invalid.
        RuntimeError: if this class is used in TF 2.0.
docstring_summary: Initialize the converter.
docstring_tokens: Initialize the converter .
function: def __init__(self,
                 input_saved_model_dir=None,
                 input_saved_model_tags=None,
                 input_saved_model_signature_key=None,
                 input_graph_def=None,
                 nodes_blacklist=None,
                 session_config=None,
                 max_batch_size=1,
                 max_workspace_size_bytes=DEFAULT_TRT_MAX_WORKSPACE_SIZE_BYTES,
                 precision_mode=TrtPrecisionMode.FP32,
                 minimum_segment_size=3,
                 is_dynamic_op=False,
                 maximum_cached_engines=1,
                 use_calibration=True):
      """Initialize the converter.
  
      Args:
        input_saved_model_dir: the directory to load the SavedModel which contains
          the input graph to transforms. Used only when input_graph_def is None.
        input_saved_model_tags: list of tags to load the SavedModel.
        input_saved_model_signature_key: the key of the signature to optimize the
          graph for.
        input_graph_def: a GraphDef object containing a model to be transformed.
          If set to None, the graph will be read from the SavedModel loaded from
          input_saved_model_dir.
        nodes_blacklist: list of node names to prevent the converter from
          touching.
        session_config: the ConfigProto used to create a Session. It's also used
          as a template to create a TRT-enabled ConfigProto for conversion. If not
          specified, a default ConfigProto will be used.
        max_batch_size: max size for the input batch.
        max_workspace_size_bytes: the maximum GPU temporary memory which the TRT
          engine can use at execution time. This corresponds to the
          'workspaceSize' parameter of nvinfer1::IBuilder::setMaxWorkspaceSize().
        precision_mode: one of TrtPrecisionMode.supported_precision_modes().
        minimum_segment_size: the minimum number of nodes required for a subgraph
          to be replaced by TRTEngineOp.
        is_dynamic_op: whether to generate dynamic TRT ops which will build the
          TRT network and engine at run time.
        maximum_cached_engines: max number of cached TRT engines in dynamic TRT
          ops. If the number of cached engines is already at max but none of them
          can serve the input, the TRTEngineOp will fall back to run the TF
          function based on which the TRTEngineOp is created.
        use_calibration: this argument is ignored if precision_mode is not INT8.
          If set to True, a calibration graph will be created to calibrate the
          missing ranges. The calibration graph must be converted to an inference
          graph by running calibration with calibrate(). If set to False,
          quantization nodes will be expected for every tensor in the graph
          (exlcuding those which will be fused). If a range is missing, an error
          will occur. Please note that accuracy may be negatively affected if
          there is a mismatch between which tensors TRT quantizes and which
          tensors were trained with fake quantization.
  
      Raises:
        ValueError: if the combination of the parameters is invalid.
        RuntimeError: if this class is used in TF 2.0.
      """
      if context.executing_eagerly():
        raise RuntimeError("Please use TrtGraphConverterV2 in TF 2.0.")
  
      if input_graph_def and input_saved_model_dir:
        raise ValueError(
            "Can only specify one of input_graph_def and input_saved_model_dir")
      if not input_graph_def and not input_saved_model_dir:
        raise ValueError("Must specify one of input_graph_def and "
                         "input_saved_model_dir")
      _check_trt_version_compatibility()
  
      self._input_graph_def = input_graph_def
      self._nodes_blacklist = nodes_blacklist
  
      self._input_saved_model_dir = input_saved_model_dir
      self._converted = False
      self._grappler_meta_graph_def = None
  
      self._input_saved_model_tags = (
          input_saved_model_tags or [tag_constants.SERVING])
      self._input_saved_model_signature_key = (
          input_saved_model_signature_key or
          signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY)
      self._session_config = session_config or config_pb2.ConfigProto()
  
      # For calibration usage.
      self._calibration_graph = None
      self._calibration_data_collected = False
      self._need_calibration = (
          precision_mode == TrtPrecisionMode.INT8 and use_calibration)
      if self._need_calibration and not is_dynamic_op:
        tf_logging.warn(
            "INT8 precision mode with calibration is supported with "
            "dynamic TRT ops only. Disregarding is_dynamic_op parameter.")
        is_dynamic_op = True
  
      # TODO(laigd):
      # - Verify in int8 mode that maximum_cached_engines is set properly.
      # - If it fails to build the int8 engine it should return error.
      rewriter_config_template = None
      if (session_config and session_config.HasField("graph_options") and
          session_config.graph_options.HasField("rewrite_options")):
        rewriter_config_template = session_config.graph_options.rewrite_options
  
      self._conversion_params = TrtConversionParams(
          rewriter_config_template=rewriter_config_template,
          max_workspace_size_bytes=max_workspace_size_bytes,
          precision_mode=precision_mode,
          minimum_segment_size=minimum_segment_size,
          is_dynamic_op=is_dynamic_op,
          maximum_cached_engines=maximum_cached_engines,
          use_calibration=use_calibration,
          max_batch_size=max_batch_size)
      _check_conversion_params(self._conversion_params)
function_tokens: def __init__ ( self , input_saved_model_dir = None , input_saved_model_tags = None , input_saved_model_signature_key = None , input_graph_def = None , nodes_blacklist = None , session_config = None , max_batch_size = 1 , max_workspace_size_bytes = DEFAULT_TRT_MAX_WORKSPACE_SIZE_BYTES , precision_mode = TrtPrecisionMode . FP32 , minimum_segment_size = 3 , is_dynamic_op = False , maximum_cached_engines = 1 , use_calibration = True ) : if context . executing_eagerly ( ) : raise RuntimeError ( "Please use TrtGraphConverterV2 in TF 2.0." ) if input_graph_def and input_saved_model_dir : raise ValueError ( "Can only specify one of input_graph_def and input_saved_model_dir" ) if not input_graph_def and not input_saved_model_dir : raise ValueError ( "Must specify one of input_graph_def and " "input_saved_model_dir" ) _check_trt_version_compatibility ( ) self . _input_graph_def = input_graph_def self . _nodes_blacklist = nodes_blacklist self . _input_saved_model_dir = input_saved_model_dir self . _converted = False self . _grappler_meta_graph_def = None self . _input_saved_model_tags = ( input_saved_model_tags or [ tag_constants . SERVING ] ) self . _input_saved_model_signature_key = ( input_saved_model_signature_key or signature_constants . DEFAULT_SERVING_SIGNATURE_DEF_KEY ) self . _session_config = session_config or config_pb2 . ConfigProto ( ) # For calibration usage. self . _calibration_graph = None self . _calibration_data_collected = False self . _need_calibration = ( precision_mode == TrtPrecisionMode . INT8 and use_calibration ) if self . _need_calibration and not is_dynamic_op : tf_logging . warn ( "INT8 precision mode with calibration is supported with " "dynamic TRT ops only. Disregarding is_dynamic_op parameter." ) is_dynamic_op = True # TODO(laigd): # - Verify in int8 mode that maximum_cached_engines is set properly. # - If it fails to build the int8 engine it should return error. rewriter_config_template = None if ( session_config and session_config . HasField ( "graph_options" ) and session_config . graph_options . HasField ( "rewrite_options" ) ) : rewriter_config_template = session_config . graph_options . rewrite_options self . _conversion_params = TrtConversionParams ( rewriter_config_template = rewriter_config_template , max_workspace_size_bytes = max_workspace_size_bytes , precision_mode = precision_mode , minimum_segment_size = minimum_segment_size , is_dynamic_op = is_dynamic_op , maximum_cached_engines = maximum_cached_engines , use_calibration = use_calibration , max_batch_size = max_batch_size ) _check_conversion_params ( self . _conversion_params )