--external_weight

Description

Externalizes the weights of the Const/Constant nodes on the original network and converts the node type to FileConstant during generation of the .om model file.

In the offline scenario, if the model weight is large and the environment has restrictions on the .om file size, you are advised to enable the external weight to save the weight separately to reduce the .om file size.

See Also

This option must be used together with --output. The generated weight file is saved in the weight directory at the same level as the .om file and is named as weight_+hash.

Argument

  • 0: Saves the weights in the .om model file. The default value is 0.
  • 1: externalizes the weights and flushes the weight files of all Const/Constant nodes on the network. The node type is converted to FileConstant. The weight files are named as weight_+hash.

Suggestions and Benefits

None

Example

The following uses the ONNX network model as an example:

atc --framework=5 --model=$HOME/module/resnet50.onnx --output=$HOME/module/out/onnx_resnet50 --soc_version=<soc_version>  --external_weight=1

Applicability

Atlas 200/300/500 Inference Product

Atlas Training Series Product

Dependencies and Restrictions

In the external weight scenario, when AscendCL APIs are used to develop inference applications and load models:

  • If the aclmdlLoadFromFile API is used to load a model, the weight file must be stored in the weight directory at the same level as the .om file.
  • If the aclmdlSetConfigOpt and aclmdlLoadWithConfig APIs are used to load a model, there is no requirement on the external weight directory. When the model is loaded later, use the aclmdlLoadWithConfig API to specify the external weight directory.

For details about the APIs, see Model Loading and Unloading.