Type TFLiteConverter
Namespace tensorflow.lite
Parent TFLiteConverterBase
Interfaces ITFLiteConverter
Convert a TensorFlow model into `output_format`. This is used to convert from a TensorFlow GraphDef, SavedModel or tf.keras
model into either a TFLite FlatBuffer or graph visualization.
Methods
- from_frozen_graph_dyn<TClass>
- from_frozen_graph<TClass>
- from_keras_model_file_dyn<TClass>
- from_keras_model_file<TClass>
- from_saved_model_dyn<TClass>
- from_saved_model<TClass>
- from_session_dyn<TClass>
- from_session<TClass>
- get_input_arrays
- get_input_arrays_dyn
Properties
- allow_custom_ops
- change_concat_input_ranges
- default_ranges_stats
- drop_control_dependency
- dump_graphviz_dir
- dump_graphviz_video
- experimental_enable_mlir_converter
- inference_input_type
- inference_output_type
- inference_type
- optimizations
- output_format
- PythonObject
- quantized_input_stats
- reorder_across_fake_quant
- representative_dataset
- target_spec
Public instance methods
IList<object> get_input_arrays()
Returns a list of the names of the input tensors.
Returns
-
IList<object> - List of strings.
object get_input_arrays_dyn()
Returns a list of the names of the input tensors.
Returns
-
object - List of strings.
Public static methods
object from_frozen_graph_dyn<TClass>(object graph_def_file, object input_arrays, object output_arrays, object input_shapes)
Creates a TFLiteConverter class from a file containing a frozen GraphDef.
Parameters
-
objectgraph_def_file - Full filepath of file containing frozen GraphDef.
-
objectinput_arrays - List of input tensors to freeze graph with.
-
objectoutput_arrays - List of output tensors to freeze graph with.
-
objectinput_shapes - Dict of strings representing input tensor names to list of integers representing input shapes (e.g., {"foo" : [1, 16, 16, 3]}). Automatically determined when input shapes is None (e.g., {"foo" : None}). (default None)
Returns
-
object - TFLiteConverter class.
TClass from_frozen_graph<TClass>(string graph_def_file, IEnumerable<string> input_arrays, IEnumerable<string> output_arrays, IDictionary<string, IEnumerable<int>> input_shapes)
Creates a TFLiteConverter class from a file containing a frozen GraphDef.
Parameters
-
stringgraph_def_file - Full filepath of file containing frozen GraphDef.
-
IEnumerable<string>input_arrays - List of input tensors to freeze graph with.
-
IEnumerable<string>output_arrays - List of output tensors to freeze graph with.
-
IDictionary<string, IEnumerable<int>>input_shapes - Dict of strings representing input tensor names to list of integers representing input shapes (e.g., {"foo" : [1, 16, 16, 3]}). Automatically determined when input shapes is None (e.g., {"foo" : None}). (default None)
Returns
-
TClass - TFLiteConverter class.
object from_keras_model_file_dyn<TClass>(object model_file, object input_arrays, object input_shapes, object output_arrays, object custom_objects)
Creates a TFLiteConverter class from a tf.keras model file.
Parameters
-
objectmodel_file - Full filepath of HDF5 file containing the tf.keras model.
-
objectinput_arrays - List of input tensors to freeze graph with. Uses input arrays from SignatureDef when none are provided. (default None)
-
objectinput_shapes - Dict of strings representing input tensor names to list of integers representing input shapes (e.g., {"foo" : [1, 16, 16, 3]}). Automatically determined when input shapes is None (e.g., {"foo" : None}). (default None)
-
objectoutput_arrays - List of output tensors to freeze graph with. Uses output arrays from SignatureDef when none are provided. (default None)
-
objectcustom_objects - Dict mapping names (strings) to custom classes or functions to be considered during model deserialization. (default None)
Returns
-
object - TFLiteConverter class.
TClass from_keras_model_file<TClass>(string model_file, IEnumerable<string> input_arrays, IDictionary<string, IEnumerable<int>> input_shapes, IEnumerable<string> output_arrays, IDictionary<string, PythonClassContainer> custom_objects)
Creates a TFLiteConverter class from a tf.keras model file.
Parameters
-
stringmodel_file - Full filepath of HDF5 file containing the tf.keras model.
-
IEnumerable<string>input_arrays - List of input tensors to freeze graph with. Uses input arrays from SignatureDef when none are provided. (default None)
-
IDictionary<string, IEnumerable<int>>input_shapes - Dict of strings representing input tensor names to list of integers representing input shapes (e.g., {"foo" : [1, 16, 16, 3]}). Automatically determined when input shapes is None (e.g., {"foo" : None}). (default None)
-
IEnumerable<string>output_arrays - List of output tensors to freeze graph with. Uses output arrays from SignatureDef when none are provided. (default None)
-
IDictionary<string, PythonClassContainer>custom_objects - Dict mapping names (strings) to custom classes or functions to be considered during model deserialization. (default None)
Returns
-
TClass - TFLiteConverter class.
object from_saved_model_dyn<TClass>(object saved_model_dir, object input_arrays, object input_shapes, object output_arrays, object tag_set, object signature_key)
Creates a TFLiteConverter class from a SavedModel.
Parameters
-
objectsaved_model_dir - SavedModel directory to convert.
-
objectinput_arrays - List of input tensors to freeze graph with. Uses input arrays from SignatureDef when none are provided. (default None)
-
objectinput_shapes - Dict of strings representing input tensor names to list of integers representing input shapes (e.g., {"foo" : [1, 16, 16, 3]}). Automatically determined when input shapes is None (e.g., {"foo" : None}). (default None)
-
objectoutput_arrays - List of output tensors to freeze graph with. Uses output arrays from SignatureDef when none are provided. (default None)
-
objecttag_set - Set of tags identifying the MetaGraphDef within the SavedModel to analyze. All tags in the tag set must be present. (default set("serve"))
-
objectsignature_key - Key identifying SignatureDef containing inputs and outputs. (default DEFAULT_SERVING_SIGNATURE_DEF_KEY)
Returns
-
object - TFLiteConverter class.
TClass from_saved_model<TClass>(object saved_model_dir, IEnumerable<string> input_arrays, IDictionary<string, IEnumerable<int>> input_shapes, object output_arrays, object tag_set, object signature_key)
Creates a TFLiteConverter class from a SavedModel.
Parameters
-
objectsaved_model_dir - SavedModel directory to convert.
-
IEnumerable<string>input_arrays - List of input tensors to freeze graph with. Uses input arrays from SignatureDef when none are provided. (default None)
-
IDictionary<string, IEnumerable<int>>input_shapes - Dict of strings representing input tensor names to list of integers representing input shapes (e.g., {"foo" : [1, 16, 16, 3]}). Automatically determined when input shapes is None (e.g., {"foo" : None}). (default None)
-
objectoutput_arrays - List of output tensors to freeze graph with. Uses output arrays from SignatureDef when none are provided. (default None)
-
objecttag_set - Set of tags identifying the MetaGraphDef within the SavedModel to analyze. All tags in the tag set must be present. (default set("serve"))
-
objectsignature_key - Key identifying SignatureDef containing inputs and outputs. (default DEFAULT_SERVING_SIGNATURE_DEF_KEY)
Returns
-
TClass - TFLiteConverter class.
object from_session_dyn<TClass>(object sess, object input_tensors, object output_tensors)
Creates a TFLiteConverter class from a TensorFlow Session.
Parameters
-
objectsess - TensorFlow Session.
-
objectinput_tensors - List of input tensors. Type and shape are computed using `foo.shape` and `foo.dtype`.
-
objectoutput_tensors - List of output tensors (only.name is used from this).
Returns
-
object - TFLiteConverter class.
TClass from_session<TClass>(Session sess, IEnumerable<IGraphNodeBase> input_tensors, IEnumerable<object> output_tensors)
Creates a TFLiteConverter class from a TensorFlow Session.
Parameters
-
Sessionsess - TensorFlow Session.
-
IEnumerable<IGraphNodeBase>input_tensors - List of input tensors. Type and shape are computed using `foo.shape` and `foo.dtype`.
-
IEnumerable<object>output_tensors - List of output tensors (only.name is used from this).
Returns
-
TClass - TFLiteConverter class.