tflite/guide/inference.md
The model is created by reinterpret a raw memory directly.
call graph
Interpreter::Invoke
Subgraph::Invoke
Subgraph::OpInvoke
TfLiteRegistration::Invoke
Op Registration
In tflite, ops are registerred to the interpreter.
- lite/python/optimize/calibrator_wrapper.cc:CreateWrapperCPPFromBuffer > lite/kernels/register.cc:BuiltinOpResolver
- BuiltinOpResolver creates a default registration
- the Resolver is used by BuildLocalIndexToRegistrationMapping
- which create flatbuffer_op_index_to_registration_
- The mapping is used by model.cc:InterpreterBuilder::ParseNodes
- which retrieve registration from op_index
- the registration and node is added by Subgraph::AddNodeWithParameter
- The node and registration is used in Invoke
when is minmax being updated?
- the info is stored in lite/schema :TensorT:quantization
- moved by lite/tools/optimize/calibration/calibration_reader.cc:AddCalibrationToModel
- from logger_ -> GetCalibrationValues
- created in lite/tools/optimize/calibration/calibrator.cc:BuildLoggingInterpreter
- in GetCalibratorRegistry()->CreateCalibrator
- Calibrator is based on result stored in LoggingOpResolver
- LoggingOpResolver overwrite TfLiteRegistration::invoke
- with calibrator.cc:LoggingEval
- calibrator is retrieved from the context. (singleton)
- calls LogTensorValue
- updates tensor stats map calibration_logger.h:Update
- with min, max -> absolute value
how does tensor get indexed by int?
in tensorflow, tensor is refereced by string
todo: how does this work in tflite
special ops
add
scale and zero point
calculation
concat
scale and zero point is taken as an array
if input and output scale is the same, memcpy if they are different,