Snapdragon Neural Processing Engine SDK
Reference Guide
|
This section talks about the steps required to convert a framework model with user defined operations(UDO).
snpe-<framework>-to-dlc tools support UDO functionality by accepting configuration file(s) with the option --udo_config_paths. For input UDO config file specifications, see Defining a UDO.
Currently UDO functionality is supported on TensorFlow, Caffe and ONNX models. It is also supported on models trained with Caffe2 that are expressed in ONNX formatting.
Note: Any modifications in the UDO configuration file should be followed up with re-generation of DLCs to reflect the changes.
Converting Tensorflow model with UDO to DLC
The following syntax showcases the way TensorFlow models can be converted using UDO:
snpe-tensorflow-to-dlc -i <input-tensorflow-model> -d <input-name> <input-dim> --out_node <output-node-name> --udo_config_paths <input-model.json> -o <output-model.dlc>
where the option --udo_config_paths allows users to specify the UDO configuration file to be used in the conversion.
See snpe-tensorflow-to-dlc and TensorFlow Model Conversion for further details.
Converting ONNX model with UDO to DLC
The following syntax showcases the way ONNX models can be converted using UDO:
snpe-onnx-to-dlc -i <input-onnx-model> --udo_config_paths <input-model.json> -o <output-model.dlc>
where the option --udo_config_paths allows users to specify the UDO configuration file to be used in the conversion.
Additionally, users may want to quantize converted models having UDOs to run on fixed-point runtimes. SNPE SDK provides the tool snpe-dlc-quantize for this purpose. This is an offline tool that can be run on the host x86 platform. Since it runs inferences with a representative data-set in order to determine quantization ranges for all layers in the network including UDOs, users will need to provide a UDO package containing CPU reference implementation to the tool. Refer to Creating a UDO Package and Compiling a UDO package for further instructions on creating such a package for the x86 platform.
The following syntax showcases the way DLCs with UDOs can be quantized with snpe-dlc-quantize:
snpe-dlc-quantize --input_dlc <model.dlc> --input_list <input-list.txt> --udo_package_path <udo-registration-lib> --output_dlc <quantized-model.dlc>
where the option --udo_package_path allows users to specify the absolute path to the UDO registration library.
Note: If your UDO contains static inputs or parameters, you need to handle both floating-point and fixed-point data types in CPU reference implementation. Refer to provided example $SNPE_ROOT/examples/NativeCpp/UdoExample/Conv2D/src/CPU/ConvolutionImplLibCpu.cpp for details.