Snapdragon Neural Processing Engine SDK
Reference Guide
Tutorials Setup

Tutorial Resources

The tutorials require additional resources which are not included in the default SNPE SDK package. These assets need to be downloaded before running the tutorials.

Getting AlexNet

In this tutorial, AlexNet Caffe model files (prototxt and caffemodel), and sample image files are prepared for the Caffe tutorial. The script requires a directory path to the AlexNet assets. The script can also optionally download the AlexNet assets. Please note that the script changes the number of batch to 1 and saves a modified model as deploy_batch_1.prototxt in $SNPE_ROOT/models/alexnet/caffe.

The AlexNet assets are listed below:

deploy.prototxt         - https://raw.githubusercontent.com/BVLC/caffe/master/models/bvlc_alexnet/deploy.prototxt
bvlc_alexnet.caffemodel - http://dl.caffe.berkeleyvision.org/bvlc_alexnet.caffemodel
caffe_ilsvrc12.tar.gz   - http://dl.caffe.berkeleyvision.org/caffe_ilsvrc12.tar.gz

Note that the assets are large and can take some time to download.

Running "python3 $SNPE_ROOT/models/alexnet/scripts/setup_alexnet.py -h" will show the usage description.

usage: $SNPE_ROOT/models/alexnet/scripts/setup_alexnet.py [-h] -a ASSETS_DIR [-d]

Prepares the AlexNet assets for tutorial examples.

required arguments:
  -a ASSETS_DIR, --assets_dir ASSETS_DIR
                        directory containing the AlexNet assets

optional arguments:
  -d, --download        Download AlexNet assets to AlexNet assets directory

Download the model and prepare the assets
The assets directory contains the network model assets. If the assets have been previously downloaded set the ASSETS_DIR to this directory otherwise select a target directory to store the assets as they are downloaded. If the assets are already downloaded to a directory (e.g. ~/tmpdir) then issue the following command.

  • python3 $SNPE_ROOT/models/alexnet/scripts/setup_alexnet.py -a ~/tmpdir

Issue this command to download the assets first. The downloaded files with be written to the specified assets directory (e.g. ~/tmpdir)

  • python3 $SNPE_ROOT/models/alexnet/scripts/setup_alexnet.py -a ~/tmpdir -d

After the script is complete the prepared AlexNet assets are copied to the $SNPE_ROOT/models/alexnet directory, along with sample raw images, and converted SNPE DLC files.

Getting Inception v3

In this tutorial, the Inception v3 TensorFlow model file, and sample image files are prepared for the TensorFlow classification tutorial. The script requires a directory path to the Inception v3 assets (zip file). The script can also optionally download the Inception v3 archive.

The Inception v3 assets are listed below:

inception_v3_2016_08_28_frozen.pb.tar.gz - https://storage.googleapis.com/download.tensorflow.org/models/inception_v3_2016_08_28_frozen.pb.tar.gz

Note that the assets are large and can take some time to download.

Running "python3 $SNPE_ROOT/models/inception_v3/scripts/setup_inceptionv3.py -h" will show the usage description.

usage: $SNPE_ROOT/models/inception_v3/scripts/setup_inceptionv3.py [-h] -a ASSETS_DIR [-d] [-r RUNTIME] [-u] [-l [HTP_SOC]]

Prepares the inception_v3 assets for tutorial examples.

required arguments:
  -a ASSETS_DIR, --assets_dir ASSETS_DIR
                        directory containing the inception_v3 assets

optional arguments:
  -d, --download        Download inception_v3 assets to inception_v3 example
                        directory
  -r RUNTIME, --runtime RUNTIME
                        Choose a runtime to set up tutorial for. Choices: cpu,
                        gpu, dsp, aip, all. 'all' option is only supported
                        with --udo flag
  -u, --udo             Generate and compile a user-defined operation package
                        to be used with inception_v3. Softmax is simulated as
                        a UDO for this script.
  -l [HTP_SOC], --htp_soc [HTP_SOC]
                        Specify SOC target for generating HTP Offline Cache.
                        For example: "--htp_soc sm8450" for waipio, default
                        value is sm8550

Download the model and prepare the assets
The assets directory is intended to contain the network model assets. If the assets have been previously downloaded set the ASSETS_DIR to this directory otherwise select a target directory to store the assets as they are downloaded, along with the option [--download] to actually download the model files.

Choice of target runtime
Depending on the chosen runtime the script may perform additional steps of optimization specific to a hardware target. Users can choose to generate the final DLC to run on one of CPU, GPU, DSP or the HTA targets at runtime.
The argument 'runtime' is optional and defaults to 'cpu' when not explicitly specified.
Here are some sample commands to use in different circumstances:
Let us use ~/tmpdir as our assets directory for these examples.


1. Run the script to download model and set up to run on CPU:

  • python $SNPE_ROOT/models/inception_v3/scripts/setup_inceptionv3.py -a ~/tmpdir -d


2. Run the script to download model and set up to run on DSP:

  • python $SNPE_ROOT/models/inception_v3/scripts/setup_inceptionv3.py -a ~/tmpdir -d -r dsp


3. Run the script on an model already downloaded to ~/tmpdir to set up to run on HTA:

  • python $SNPE_ROOT/models/inception_v3/scripts/setup_inceptionv3.py -a ~/tmpdir -r aip

Choice of SoC target
Based on SoC target, the script will add enable_htp and htp_socs arguments to snpe-dlc-quantize when target runtime is 'dsp' or 'all'.
The argument 'htp_soc' is optional, if no value is given then 'sm8550' is taken as default value for htp_soc argument.
Here are some sample commands for running setup_inceptionv3.py:

Run the script to download model and set up to run on dsp with
1. SoC target as sm8550:

  • python $SNPE_ROOT/models/inception_v3/scripts/setup_inceptionv3.py -a ~/tmpdir -d -r dsp -l


2. SoC target as sm8450:

  • python $SNPE_ROOT/models/inception_v3/scripts/setup_inceptionv3.py -a ~/tmpdir -d -r dsp -l sm8450

After the script is complete the prepared Inception v3 assets are copied to the $SNPE_ROOT/models/inception_v3 directory, along with sample raw images, and converted SNPE DLC files with additional optimizations as applicable.

Note: for information on running Inception v3 with UDO and the use of the --udo visit UDO Tutorial