--external_weight
Applicability
|
Product |
Supported |
|---|---|
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
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 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 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, 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>.
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 acl APIs are used to develop inference applications and load 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 APIs, see ""Model Loading and Unloading"".