MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / InterpreterBuilder

Class InterpreterBuilder

tensorflow/lite/model.h:191–232  ·  view source on GitHub ↗

Build an interpreter capable of interpreting `model`. model: A model whose lifetime must be at least as long as any interpreter(s) created by the builder. In principle multiple interpreters can be made from a single model. op_resolver: An instance that implements the OpResolver interface, which maps custom op names and builtin op codes to op registrations. The lifetime of the provided `op_resolve

Source from the content-addressed store, hash-verified

189/// Interpreter. Note: The user must ensure the model lifetime (and error
190/// reporter, if provided) is at least as long as interpreter's lifetime.
191class InterpreterBuilder {
192 public:
193 InterpreterBuilder(const FlatBufferModel& model,
194 const OpResolver& op_resolver);
195 /// Builds an interpreter given only the raw flatbuffer Model object (instead
196 /// of a FlatBufferModel). Mostly used for testing.
197 /// If `error_reporter` is null, then DefaultErrorReporter() is used.
198 InterpreterBuilder(const ::tflite::Model* model,
199 const OpResolver& op_resolver,
200 ErrorReporter* error_reporter = DefaultErrorReporter());
201 ~InterpreterBuilder();
202 InterpreterBuilder(const InterpreterBuilder&) = delete;
203 InterpreterBuilder& operator=(const InterpreterBuilder&) = delete;
204 TfLiteStatus operator()(std::unique_ptr<Interpreter>* interpreter);
205 TfLiteStatus operator()(std::unique_ptr<Interpreter>* interpreter,
206 int num_threads);
207
208 private:
209 TfLiteStatus BuildLocalIndexToRegistrationMapping();
210 TfLiteStatus ParseNodes(
211 const flatbuffers::Vector<flatbuffers::Offset<Operator>>* operators,
212 Subgraph* subgraph);
213 TfLiteStatus ParseTensors(
214 const flatbuffers::Vector<flatbuffers::Offset<Buffer>>* buffers,
215 const flatbuffers::Vector<flatbuffers::Offset<Tensor>>* tensors,
216 Subgraph* subgraph);
217 TfLiteStatus ApplyDelegates(Interpreter* interpreter);
218 TfLiteStatus ParseQuantization(const QuantizationParameters* src_quantization,
219 TfLiteQuantization* quantization,
220 const std::vector<int>& dims);
221
222 const ::tflite::Model* model_;
223 const OpResolver& op_resolver_;
224 ErrorReporter* error_reporter_;
225
226 std::vector<const TfLiteRegistration*> flatbuffer_op_index_to_registration_;
227 std::vector<TfLiteRegistration> unresolved_custom_ops_;
228 std::vector<BuiltinOperator> flatbuffer_op_index_to_registration_types_;
229 const Allocation* allocation_ = nullptr;
230
231 bool has_flex_op_ = false;
232};
233
234} // namespace tflite
235

Callers 15

TESTFunction · 0.85
TESTFunction · 0.85
TEST_FFunction · 0.85
TESTFunction · 0.85
BuildLoggingInterpreterFunction · 0.85
InitMethod · 0.85
InitMethod · 0.85
CreateInterpreterFunction · 0.85
BuildInterpreterMethod · 0.85
RunInferenceFunction · 0.85

Calls 1

DefaultErrorReporterFunction · 0.85

Tested by 6

TESTFunction · 0.68
TESTFunction · 0.68
TEST_FFunction · 0.68
TESTFunction · 0.68
BuildInterpreterMethod · 0.68
mainFunction · 0.68