afe.load.loader

Attributes

TensorShape

InputMapping

NodeConversionMapping

Functions

load_tensorflow_model(→ Union[afe.ir.net.AwesomeNet, ...)

Loads a TensorFlow model into an AwesomeNet format. This function is deprecated;

load_tensorflow2_model(→ Union[afe.ir.net.AwesomeNet, ...)

Loads a TensorFlow model into an AwesomeNet format. This function is deprecated;

load_pytorch_model(→ Union[afe.ir.net.AwesomeNet, ...)

Loads a PyTorch model into an AwesomeNet format. This function is deprecated;

load_tflite_model(→ Union[afe.ir.net.AwesomeNet, ...)

Loads a TensorFlow Lite model into an AwesomeNet format. This function is deprecated;

load_onnx_model(→ Union[afe.ir.net.AwesomeNet, ...)

Loads a ONNX model into an AwesomeNet format. This function is deprecated;

load_keras_model(→ Union[afe.ir.net.AwesomeNet, ...)

Loads a Keras model into an AwesomeNet format. This function is deprecated;

load_caffe_model(→ Union[afe.ir.net.AwesomeNet, ...)

Loads a caffe model into an AwesomeNet format. This function is deprecated;

load_caffe2_model(→ Union[afe.ir.net.AwesomeNet, ...)

Loads a caffe2 model into an AwesomeNet format.

Module Contents

afe.load.loader.TensorShape[source]
afe.load.loader.InputMapping[source]
afe.load.loader.NodeConversionMapping[source]
afe.load.loader.load_tensorflow_model(pb_file_path: str, shape_dict: Dict[str, Tuple[int, Ellipsis]], output_names: List[str], layout: str = 'NHWC', convert_layout: bool = False, custom_convert_map: Dict[str, Callable] | None = None, return_irmod: bool = False, index_to_backend_dict: Dict[int, afe.backends.Backend] | None = None, is_quantized: bool = False) afe.ir.net.AwesomeNet | Tuple[afe.ir.net.AwesomeNet, afe._tvm._defines.TVMIRModule][source]

Loads a TensorFlow model into an AwesomeNet format. This function is deprecated; use import_and_transform instead.

Parameters:
  • pb_file_path – Path to a .pb TensorFlow model

  • shape_dict – Dictionary of input names to input shapes eg. {‘input’, (1,224,224,3)}

  • output_names – List of output names of the network eg. [‘output1’, ‘output2’]

  • layout – any variation of the characters NHWC representing Batch Size, Height, Width, and Channels

  • convert_layout – Set it to True to enable TVM ConvertLayout transformation

  • 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_irmod – bool. Default is False. If True, the function also returns TVM Relay IR Module representation of the Awesomenet

  • index_to_backend_dict – Optional[Dict[int, Backend]]. A dictionary of node indices to its targeted backend.

  • is_quantized – Whether the model is pre-quantized. Default is False

Returns:

An AwesomeNet

afe.load.loader.load_tensorflow2_model(pb_file_path: str, shape_dict: Dict[str, Tuple[int, Ellipsis]], output_names: List[str], layout: str = 'NHWC', convert_layout: bool = False, custom_convert_map: Dict[str, Callable] | None = None, return_irmod: bool = False, index_to_backend_dict: Dict[int, afe.backends.Backend] | None = None, is_quantized: bool = False) afe.ir.net.AwesomeNet | Tuple[afe.ir.net.AwesomeNet, afe._tvm._defines.TVMIRModule][source]

Loads a TensorFlow model into an AwesomeNet format. This function is deprecated; use import_and_transform instead.

Parameters:
  • pb_file_path – Path to a SavedModel dir.

  • shape_dict – Dictionary of input names to input shapes eg. {‘input’, (1,224,224,3)}

  • output_names – List of output names of the network eg. [‘output1’, ‘output2’]

  • layout – any variation of the characters NHWC representing Batch Size, Height, Width, and Channels

  • convert_layout – Set it to True to enable TVM ConvertLayout transformation

  • 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_irmod – bool. Default is False. If True, the function also returns TVM Relay IR Module representation of the Awesomenet

  • index_to_backend_dict – Optional[Dict[int, Backend]]. A dictionary of node indices to its targeted backend.

  • is_quantized – Whether the model is pre-quantized. Default is False

Returns:

An AwesomeNet

afe.load.loader.load_pytorch_model(pt_file_path: str, input_names: List[str], input_shapes: List[Tuple[int, Ellipsis]], input_dtypes: List[afe.ir.tensor_type.ScalarType] | None = None, layout: str = 'NCHW', convert_layout: bool = False, custom_convert_map: Dict[str, Callable] | None = None, return_irmod: bool = False, index_to_backend_dict: Dict[int, afe.backends.Backend] | None = None, is_quantized: bool = False) afe.ir.net.AwesomeNet | Tuple[afe.ir.net.AwesomeNet, afe._tvm._defines.TVMIRModule][source]

Loads a PyTorch model into an AwesomeNet format. This function is deprecated; use import_and_transform instead.

Parameters:
  • pt_file_path – Path to a PyTorch file (.pt) that contains the entire model

  • input_names – List of input names. eg [‘input’]

  • input_shapes – List of input shapes corresponding to input names. eg. [(1, 224, 224, 3)]

  • input_dtypes – List of input datatypes corresponding to input names. eg [‘float32’]

  • layout – Input data layout. Default is ‘NCHW’

  • convert_layout – Set it to True to enable TVM ConvertLayout transformation

  • 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 2 arguments:

    inputs = tvm relay expression inputs to operator. input_types = list of strings indicating the input types to the operator.

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

  • return_irmod – bool. Default is False. If True, the function also returns TVM Relay IR Module representation of the Awesomenet

  • index_to_backend_dict – Optional[Dict[int, Backend]]. A dictionary of node indices to its targeted backend.

  • is_quantized – Whether the model is pre-quantized. Default is False

Returns:

An AwesomeNet

afe.load.loader.load_tflite_model(tflite_file_path: str, shape_dict: Dict[str, Tuple[int, Ellipsis]], dtype_dict: Dict[str, afe.ir.tensor_type.ScalarType], layout: str = 'NHWC', convert_layout: bool = False, return_irmod: bool = False, index_to_backend_dict: Dict[int, afe.backends.Backend] | None = None, is_quantized: bool = False) afe.ir.net.AwesomeNet | Tuple[afe.ir.net.AwesomeNet, afe._tvm._defines.TVMIRModule][source]

Loads a TensorFlow Lite model into an AwesomeNet format. This function is deprecated; use import_and_transform instead.

Parameters:
  • tflite_file_path – Path to a .tflite file containing the TensorFlow Lite model

  • shape_dict – Dictionary of input names to input shapes eg. {‘input’, (1,224,224,3)}

  • dtype_dict – Dictionary of input names to input types eg. {‘input’, ‘float32’}

  • layout – Input data layout. Default is ‘NHWC’

  • convert_layout – Set it to True to enable TVM ConvertLayout transformation

  • return_irmod – bool. Default is False. If True, the function also returns TVM Relay IR Module representation of the Awesomenet

  • index_to_backend_dict – Optional[Dict[int, Backend]]. A dictionary of node indices to its targeted backend.

  • is_quantized – Whether the model is pre-quantized. Default is False

Returns:

An AwesomeNet

afe.load.loader.load_onnx_model(onnx_file_path: str, shape_dict: Dict[str, Tuple[int, Ellipsis]], dtype_dict: Dict[str, afe.ir.tensor_type.ScalarType], layout: str = 'NCHW', convert_layout: bool = False, custom_convert_map: Dict[str, Callable] | None = None, return_irmod: bool = False, index_to_backend_dict: Dict[int, afe.backends.Backend] | None = None, is_quantized: bool = False) afe.ir.net.AwesomeNet | Tuple[afe.ir.net.AwesomeNet, afe._tvm._defines.TVMIRModule][source]

Loads a ONNX model into an AwesomeNet format. This function is deprecated; use import_and_transform instead.

Parameters:
  • onnx_file_path – Path to a .onnx file containing the onnx model

  • shape_dict – Dictionary of input names to input shapes eg. {‘input’, (1,224,224,3)}

  • dtype_dict – Dictionary of input names to input types eg. {‘input’, ‘float32’}

  • layout – Input data layout. Default is ‘NCHW’

  • convert_layout – Set it to True to enable TVM ConvertLayout transformation

  • 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 3 arguments

    inputs = a tvm onnx_input object which contains a dictionary of tvm function inputs attr = a dictionary of operation attributes params = a dictionary of all the constants in the onnx network

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

  • return_irmod – bool. Default is False. If True, the function also returns TVM Relay IR Module representation of the Awesomenet

  • index_to_backend_dict – Optional[Dict[int, Backend]]. A dictionary of node indices to its targeted backend.

  • is_quantized – Whether the model is pre-quantized. Default is False

Returns:

An AwesomeNet

afe.load.loader.load_keras_model(keras_file_path: str, shape_dict: Dict[str, Tuple[int, Ellipsis]], layout: str = 'NCHW', convert_layout: bool = False, return_irmod: bool = False, index_to_backend_dict: Dict[int, afe.backends.Backend] | None = None, is_quantized: bool = False) afe.ir.net.AwesomeNet | Tuple[afe.ir.net.AwesomeNet, afe._tvm._defines.TVMIRModule][source]

Loads a Keras model into an AwesomeNet format. This function is deprecated; use import_and_transform instead.

Parameters:
  • keras_file_path – Path to a .h5 file containing the keras model

  • shape_dict – Dictionary of input names to input shapes eg. {‘input’, (1,224,224,3)}

  • layout – Input data layout. Default is ‘NCHW’

  • convert_layout – Set it to True to enable TVM ConvertLayout transformation

  • return_irmod – bool. Default is False. If True, the function also returns TVM Relay IR Module representation of the Awesomenet

  • index_to_backend_dict – Optional[Dict[int, Backend]]. A dictionary of node indices to its targeted backend.

  • is_quantized – Whether the model is pre-quantized. Default is False

Returns:

An AwesomeNet

afe.load.loader.load_caffe_model(prototxt_file_path: str, caffemodel_file_path: str, shape_dict: Dict[str, Tuple[int, Ellipsis]], dtype_dict: Dict[str, afe.ir.tensor_type.ScalarType], layout: str = 'NCHW', convert_layout: bool = False, return_irmod: bool = False, index_to_backend_dict: Dict[int, afe.backends.Backend] | None = None, is_quantized: bool = False) afe.ir.net.AwesomeNet | Tuple[afe.ir.net.AwesomeNet, afe._tvm._defines.TVMIRModule][source]

Loads a caffe model into an AwesomeNet format. This function is deprecated; use import_and_transform instead.

Parameters:
  • prototxt_file_path – filepath to the caffe .prototxt file

  • caffemodel_file_path – filepath to the caffe .caffemodel file

  • shape_dict – Dictionary of input names to input shapes eg. {‘input’, (1,224,224,3)}

  • dtype_dict – Dictionary of input names to input types eg. {‘input’, ‘float32’}

  • layout – Input data layout. Default is ‘NCHW’

  • convert_layout – Set it to True to enable TVM ConvertLayout transformation

  • return_irmod – bool. Default is False. If True, the function also returns TVM Relay IR Module representation of the Awesomenet

  • index_to_backend_dict – Optional[Dict[int, Backend]]. A dictionary of node indices to its targeted backend.

  • is_quantized – Whether the model is pre-quantized. Default is False

Returns:

An AwesomeNet

afe.load.loader.load_caffe2_model(init_net_file_path: str, predict_net_file_path: str, shape_dict: Dict[str, Tuple[int, Ellipsis]], dtype_dict: Dict[str, afe.ir.tensor_type.ScalarType], layout: str = 'NCHW', convert_layout: bool = False, return_irmod: bool = False, index_to_backend_dict: Dict[int, afe.backends.Backend] | None = None, is_quantized: bool = False) afe.ir.net.AwesomeNet | Tuple[afe.ir.net.AwesomeNet, afe._tvm._defines.TVMIRModule][source]

Loads a caffe2 model into an AwesomeNet format. :param init_net_file_path: filepath to the caffe2 .pb init_net file :param predict_net_file_path: filepath to the caffe2 .pb predict_net file :param shape_dict: Dictionary of input names to input shapes eg. {‘input’, (1,224,224,3)} :param dtype_dict: Dictionary of input names to input types eg. {‘input’, ‘float32’} :param layout: Input data layout. Default is ‘NCHW’ :param convert_layout: Set it to True to enable TVM ConvertLayout transformation :param return_irmod: bool. Default is False. If True, the function also returns TVM Relay IR Module representation

of the Awesomenet

Parameters:
  • index_to_backend_dict – Optional[Dict[int, Backend]]. A dictionary of node indices to its targeted backend.

  • is_quantized – Whether the model is pre-quantized. Default is False

Returns:

An AwesomeNet