Skip to content
This repository was archived by the owner on Jan 24, 2024. It is now read-only.

TfLite Survey

qingqing01 edited this page Nov 22, 2017 · 28 revisions

Architecture

  • Architecture Introduction

    See the architecture graph: https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/lite

    • Lite Converter Also called freeze Graph, it will merge the checkpoint values with the graph structure.
    • Android APP
      • Jave API
      • C++ API
      • Interpreter: The main executive engines
      • Android Neural Network API.
  • What is the relationship between TensorFlow and TfLite?

    There is no relationship between TensorFlow and TfLite. TfLite is another lightweight inference framework.

C++ API

The simple usage is as follows:

// 1. Load Model
tflite::FlatBufferModel model(path_to_model);

// 2. Init and Build Interpreter
tflite::ops::builtin::BuiltinOpResolver resolver;
std::unique_ptr<tflite::Interpreter> interpreter;
tflite::InterpreterBuilder(*model, resolver)(&interpreter);

// 3. Resize input tensors, if desired.
// Allocate Tensors and fill `input`.
interpreter->AllocateTensors();
float* input = interpreter->typed_input_tensor<float>(0);

// 4. Inference
interpreter->Invoke();

// 5. Read the output
float* output = interpreter->type_output_tensor<float>(0);

Operator Pruning and BuiltinOpResolver

  • BuiltinOpResolver
    • The regular usage will require the developer to use the BuiltinOpResolver, which has many operators.
  • Operator pruning
    • Users can rewrite other OpResolver to prune the operators.

Interpreter && InterpreterBuilder

Optimization

Performance

Clone this wiki locally