afe.load.importers.tensorflow ============================= .. py:module:: afe.load.importers.tensorflow Functions --------- .. autoapisummary:: afe.load.importers.tensorflow.convert_to_list afe.load.importers.tensorflow.import_tensorflow_model afe.load.importers.tensorflow.import_tensorflow2_model afe.load.importers.tensorflow.validate_input_parameters afe.load.importers.tensorflow.import_tensorflow_pb_to_tvm afe.load.importers.tensorflow.import_tensorflow2_pb_to_tvm Module Contents --------------- .. py:function:: convert_to_list(x) Taken from: https://github.com/apache/tvm/blob/main/python/tvm/relay/testing/tf.py#L72 .. py:function:: import_tensorflow_model(file_path: str, output_names: List[str]) 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 .. py:function:: import_tensorflow2_model(file_path: str) 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 .. py:function:: validate_input_parameters(pb_file_path: str, shape_dict: Dict[str, Tuple[int, Ellipsis]], output_names: List[str], layout: str) -> None 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 .. py:function:: 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: Optional[Dict[str, Callable]] = None) -> afe._tvm._defines.TVMIRModule 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. :return: TVM IR module. .. py:function:: 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: Optional[Dict[str, Callable]] = None) -> afe._tvm._defines.TVMIRModule 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. :return: TVM IR module.