auto_decomposition

Function Usage

Call auto_decomposition to perform tensor decomposition on the source Caffe model, generating a new model file and a new weight file.

Constraints

  • You need to provide the original Caffe model for conversion. Ensure that the .prototxt file matches the Caffe model.
  • Pass the directory of the source model and the output directory to the API call to the tensor decomposition API. The API automatically decomposes any convolution layer that meets the decomposition conditions. For details about the decomposition conditions, see Restrictions.

Prototype

auto_decomposition(model_file,weights_file,new_model_file,new_weights_file)

Parameter Description

Option

Input/Return

Description

Restriction

model_file

Input

Definition file of the Caffe model (.prototxt).

A string

weights_file

Input

Weight file of the Caffe model (.caffemodel).

A string

new_model_file

Input

Caffe model definition file (.prototxt) after tensor decomposition, for example, xx_tensor_decomposition.prototxt

A string

new_weights_file

Input

Caffe model weight file after tensor decomposition, in .caffemodel format, for example, xx_tensor_decomposition.caffemodel

A string

Return Value

None

Outputs

  • Model definition file (.prototxt) after tensor decomposition.
  • Model weight file (.caffemodel) after tensor decomposition.

Examples

1
2
3
4
5
from amct_caffe.tensor_decompose import auto_decomposition
auto_decomposition(model_file='ResNet-50-deploy.prototxt',
                  weights_file='ResNet-50-weights.caffemodel',
                  new_model_file='ResNet-50-deploy_tensor_decomposition.prototxt',
                  new_weights_file='ResNet-50-deploy_tensor_decomposition.caffemodel')