Import graph

Arm NN provides parsers for reading model files from neural network frameworks. There are typically two steps to do this:

  1. Load the model.
  2. Bind the input and output points of its graph.

 The following sample code imports the graph:

// Import the TensorFlow model. Note: use CreateNetworkFromBinaryFile for .pb files.
armnnTfParser::ITfParserPtr parser = armnnTfParser::ITfParser::Create();
armnn::TensorInfo inputTensorInfo({1, 784, 1, 1}, armnn::DataType::Float32);
armnn::INetworkPtr network = parser->CreateNetworkFromTextFile("model/simple_mnist_tf.prototxt",
                                                                   { {"Placeholder", {1, 784, 1, 1}} },
                                                                   { "Softmax" });

TensorFlow graphs in both text and binary ProtoBuf formats are supported. For more details on freezing TensorFlow graphs to include their weights, see the Customization basics: tensors and operations guide in the Related information section.

Note: After this step, the code is common regardless of the framework that you started with. This is because the INetwork and two BindingPointInfo objects provide everything that is needed.

Previous Next