TensorFlow Model Conversion¶
Machine Learning frameworks have specific formats for storing neural network models. Qualcomm® Neural Processing SDK supports these various models by converting them to a framework neutral deep learning container (DLC) format. The DLC file is used by the Qualcomm® Neural Processing SDK 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
A SavedModel directory (Tensorflow 2.x)
The snpe-tensorflow-to-dlc tool converts a frozen TensorFlow model or a graph meta file into an equivalent Qualcomm® Neural Processing SDK DLC file. The following command will convert an Inception v3 TensorFlow model into a Qualcomm® Neural Processing SDK DLC file.
snpe-tensorflow-to-dlc --input_network $SNPE_ROOT/examples/Models/InceptionV3/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
The Inception v3 model files can be obtained by following the Getting Inception v3 tutorial.
TensorFlow Graph and Qualcomm® Neural Processing SDK Layer Mapping
Qualcomm® Neural Processing SDK, 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 Qualcomm® Neural Processing SDK DLC file the following requirements must be met when defining a TensorFlow graph:
All nodes belonging to a layer must be defined in a unique TensorFlow scope.
A node can only belong to a single layer.
More information about graph compatibility can be found in the TensorFlow Graph Compatibility chapter.