tflite::impl

An RAII object that represents a read-only tflite model, copied from disk, or mmapped.

Summary

This uses flatbuffers as the serialization format.

NOTE: The current API requires that a FlatBufferModel instance be kept alive by the client as long as it is in use by any dependent Interpreter instances. As the FlatBufferModel instance is effectively immutable after creation, the client may safely use a single model with multiple dependent Interpreter instances, even across multiple threads (though note that each Interpreter instance is not thread-safe).


using namespace tflite;
StderrReporter error_reporter;
auto model = FlatBufferModel::BuildFromFile("interesting_model.tflite",
                                            &error_reporter);
MyOpResolver resolver;  // You need to subclass OpResolver to provide
                        // implementations.
InterpreterBuilder builder(*model, resolver);
std::unique_ptr interpreter;
if(builder(&interpreter) == kTfLiteOk) {
  .. run model inference with interpreter
}

OpResolver must be defined to provide your kernel implementations to the interpreter. This is environment specific and may consist of just the builtin ops, or some custom operators you defined to extend tflite.

Classes

tflite::impl::FlatBufferModel
tflite::impl::Interpreter
tflite::impl::InterpreterBuilder