Snapdragon Neural Processing Engine SDK Reference Guide
TensorFlow Model Conversion

Machine Learning frameworks have specific formats for storing neural network models. SNPE supports these various models by converting them to a framework neutral deep learning container (DLC) format. The DLC file is used by the SNPE runtime for execution of the neural network.

A trained TensorFlow model consists of either:

• A frozen TensorFlow model (pb file) OR
• A pair of checkpoint and graph meta files

The snpe-tensorflow-to-dlc tool converts a frozen TensorFlow model or a graph meta file into an equivalent SNPE DLC file. The following command will convert an Inception v3 TensorFlow model into a SNPE DLC file.

snpe-tensorflow-to-dlc --input_network \$SNPE_ROOT/models/inception_v3/tensorflow/inception_v3_2016_08_28_frozen.pb
--input_dim input "1,299,299,3" --out_node "InceptionV3/Predictions/Reshape_1" --output_path inception_v3.dlc
--allow_unconsumed_nodes


The Inception v3 model files can be obtained by following the Getting Inception v3 tutorial.

# TensorFlow Graph and SNPE Layer Mapping

SNPE like many other neural network runtime engines uses layers as building blocks to define the structure of neural networks. TensorFlow on the other hand, defines a neural network as a graph of nodes and a layer is defined as a set of nodes within the graph.

With this in mind, in order to properly convert a TensorFlow graph into a SNPE DLC file the following requirements must be met when defining a TensorFlow graph:

1. All nodes belonging to a layer must be defined in a unique TensorFlow scope.
2. A node can only belong to a single layer.

The snpe-tensorflow-to-dlc converter by default uses a strict layer resolution algorithm which requires all nodes in the Tensorflow graph to be resolved to a layer. If your graph has nodes which are not related to a layer such as training nodes, you may be required to use the "allow_unconsumed_nodes" converter option.