--external_weight

Applicability

Product

Supported (Yes/No)

Atlas 350 Accelerator Card

Atlas A3 training product / Atlas A3 inference product

Atlas A2 training product / Atlas A2 inference product

Atlas 200I/500 A2 inference product

Atlas inference product

Atlas training product

Description

Sets whether to externalize the weights of the Const/Constant nodes on the original network and converts the node type to FileConstant when the OM offline model file is generated.

In the offline scenario, if the model weight is large and the environment has restrictions on the OM offline model file size, you are advised to enable the external weight and 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 offline model file.

Argument

  • 0 (default): The weights are not externalized and are directly saved in the OM offline model file.
  • 1: The weights are externalized but not normalized. The weight files of all Const/Constant nodes on the network are flushed to the disk, and the node type is converted to FileConstant. Weights of different nodes are stored in different files named as weight_<hash>.
  • 2: The weight is externalized and normalized. The weight files of all Const/Constant nodes on the network are flushed to disks, and the node type is converted to FileConstant. All weights are saved in the same file named in the format of File name specified by --output_weight_combined.

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

Dependencies and Restrictions

In the external weight scenario, when developing inference applications and loading models:

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

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