auto_decomposition

Applicable Products

Product

Supported

Ascend 950PR&950DT products

x

Atlas A3 products

x

Atlas A2 products

x

Atlas 200I/500 A2 inference products

√

Atlas inference products

√

Atlas training products

√

Description

Generates a decomposed model file and its weight file from a given Caffe model file (.prototxt) and its weight file (.caffemodel).

Prototype

1
auto_decomposition(model_file,weights_file,new_model_file,new_weights_file)

Parameters

Parameter

Input/Output

Description

model_file

Input

Definition file (.prototxt) of the Caffe model.

Type: string

weights_file

Input

Weight file (.caffemodel) of the trained Caffe model.

Type: string

new_model_file

Output

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

Type: string

new_weights_file

Output

Caffe model weight file (.caffemodel) after tensor decomposition, for example, xx_tensor_decomposition.caffemodel.

Type: string

Returns

None

Constraints

  • Ensure that the input Caffe .prototxt file matches the input .caffemodel file.
  • Pass the path of the original model and the output path to the tensor decomposition API. This API automatically decomposes the convolutional layers that meet the decomposition conditions. For details about the decomposition conditions, see Restrictions.

Example

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')

Flush files:

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