afe.load.importers.tensorflow

Functions

convert_to_list(x)

Taken from: https://github.com/apache/tvm/blob/main/python/tvm/relay/testing/tf.py#L72

import_tensorflow_model(file_path, output_names)

Load a Tensorflow model from a pb filepath and a list of output names

import_tensorflow2_model(file_path)

Load a Tensorflow model from a pb filepath and a list of output names

validate_input_parameters(→ None)

Validates the user supplied input. Given a .pb file we should be able to discern the shape_dict and dtype_dict

import_tensorflow_pb_to_tvm(...)

Use TVM frontend to import a tensorflow pb model into TVM Relay IR

import_tensorflow2_pb_to_tvm(...)

Use TVM frontend to import a tensorflow pb model into TVM Relay IR

Module Contents

afe.load.importers.tensorflow.convert_to_list(x)[source]

Taken from: https://github.com/apache/tvm/blob/main/python/tvm/relay/testing/tf.py#L72

afe.load.importers.tensorflow.import_tensorflow_model(file_path: str, output_names: List[str])[source]

Load a Tensorflow model from a pb filepath and a list of output names :param file_path: str. File path to the tensorflow .pb file :param output_names: List[str]. List of output tensor names (really only applies to tensorflow imports.) :return: A Tensorflow graph

afe.load.importers.tensorflow.import_tensorflow2_model(file_path: str)[source]

Load a Tensorflow model from a pb filepath and a list of output names :param file_path: str. File path to the tensorflow SavedModel dir. :return: A Tensorflow graph

afe.load.importers.tensorflow.validate_input_parameters(pb_file_path: str, shape_dict: Dict[str, Tuple[int, Ellipsis]], output_names: List[str], layout: str) None[source]

Validates the user supplied input. Given a .pb file we should be able to discern the shape_dict and dtype_dict automatically and we can validate the user supplied output_names. The layout of the network must be given by the user. If the user has supplied their own input, this function will validate the input. If data cannot be discerned and the user has not supplied input this function will raise errors. :param pb_file_path: filepath to the tensorflow .pb file :param shape_dict: dictionary of input names to input shapes (eg. (1,224,224,3)) :param output_names: list of output tensor names (really only applies to tensorflow imports.) :param layout: any variation of the characters NHWC representing Batch Size, Height, Width, and Channels

afe.load.importers.tensorflow.import_tensorflow_pb_to_tvm(pb_file_path: str, shape_dict: Dict[str, Tuple[int, Ellipsis]], output_names: List[str], layout: str, custom_convert_map: Dict[str, Callable] | None = None) afe._tvm._defines.TVMIRModule[source]

Use TVM frontend to import a tensorflow pb model into TVM Relay IR :param pb_file_path: filepath to the tensorflow .pb file :param shape_dict: dictionary of input names to input shapes (eg. (1,224,224,3)) :param output_names: list of output tensor names (really only applies to tensorflow imports.) :param layout: any variation of the characters NHWC representing Batch Size, Height, Wdith, and Channels :param custom_convert_map: A custom op conversion map that maps operation names to functions. Whenever an operator

with a name found in the custom_convert_map is found in TVM, the function is called with 4 arguments:

inputs = tvm relay expression inputs to operator. attr = list of strings to operation attributes. params = list of strings to tvm runtime arrays that are constants in the network. mod = The tvm irmodule containing subgraphs it uses to help construct the main graph

from tensorflow.

The function then returns the tvm relay IR expression that is inserted into the model wherever the operation occurs.

Returns:

TVM IR module.

afe.load.importers.tensorflow.import_tensorflow2_pb_to_tvm(saved_model_path: str, shape_dict: Dict[str, Tuple[int, Ellipsis]], output_names: List[str], layout: str, custom_convert_map: Dict[str, Callable] | None = None) afe._tvm._defines.TVMIRModule[source]

Use TVM frontend to import a tensorflow pb model into TVM Relay IR :param saved_model_path: path to the tensorflow SavedModel directory. :param shape_dict: dictionary of input names to input shapes (eg. (1,224,224,3)) :param output_names: list of output tensor names (really only applies to tensorflow imports.) :param layout: any variation of the characters NHWC representing Batch Size, Height, Wdith, and Channels :param custom_convert_map: A custom op conversion map that maps operation names to functions. Whenever an operator

with a name found in the custom_convert_map is found in TVM, the function is called with 4 arguments:

inputs = tvm relay expression inputs to operator. attr = list of strings to operation attributes. params = list of strings to tvm runtime arrays that are constants in the network. mod = The tvm irmodule containing subgraphs it uses to help construct the main graph

from tensorflow.

The function then returns the tvm relay IR expression that is inserted into the model wherever the operation occurs.

Returns:

TVM IR module.