Skip to content
DuolixDuolix
HomeAll RobotsKits & partsEvents

My

Saved itemsOrders

Explore

Developer docsCommunity
AboutSupportPrivacy

© 2026 Duolix

Duolix
Developer documentationSDK reference
All documentation
Start hereDevelopment overviewQuick startConnect to the device
QCS6490 hardwareQCS6490 hardware overviewQCS6490 interfacesQCS6490 bring-up
AidLux systemAidLux workspaceNetwork and remote accessDevelopment environmentStart an application at boot
AI developmentInference workflowAidLite SDKROS 2 integration
SDK referenceAidLite Python APIAidLite C++ APIAidCV Python APIAidConnect C++ APIAidConnect Android APIAidStream C++ APIAidVoice C++ API
TroubleshootingTroubleshooting
SDK reference

AidLite Python API

Python model, interpreter, tensor, and runtime interfaces.

Model Data Types class DataType

For AidliteSDK, it handles different models from different frameworks, and each model has its own different input data types and different output data types. In the aforementioned usage workflow, you need to set the input and output data types of the model, which requires using this data type.

Member Variable NameTypeValueDescription
TYPE_DEFAULTint0Invalid DataType type
TYPE_UINT8int1Unsigned byte data
TYPE_INT8int2Byte data
TYPE_UINT32int3Unsigned int32 data
TYPE_FLOAT32int4Float data
TYPE_INT32int5Int32 data
TYPE_INT64int6Int64 data
TYPE_UINT64int7Uint64 data
TYPE_INT16int8Int16 data
TYPE_UINT16int9Uint16 data
TYPE_FLOAT16int10Float16 data
TYPE_BOOLint11Bool data

Inference Implementation Type class ImplementType

Member Variable NameTypeValueDescription
TYPE_DEFAULTint0Invalid ImplementType type
TYPE_MMKVint1Implementation through MMKV (currently no related implementation, may be removed later)
TYPE_REMOTEint2Backend implementation through IPC
TYPE_LOCALint3Backend implementation through local calls

Model Framework Type class FrameworkType

As mentioned earlier, AidLite SDK integrates multiple deep learning inference frameworks, so in the aforementioned usage workflow, you need to set which framework's model is currently being used, which requires using this framework type.

Member Variable NameTypeValueDescription
TYPE_DEFAULTint0Invalid FrameworkType type
TYPE_SNPEint1SNPE 1.x (DLC) model
TYPE_TFLiteint2TFLite model
TYPE_RKNNint3RKNN model
TYPE_QNNint4QNN model
TYPE_SNPE2int5SNPE 2.x (DLC) model
TYPE_NCNNint6NCNN model
TYPE_MNNint7MNN model
TYPE_TNNint8TNN model
TYPE_PADDLEint9Paddle model
TYPE_MSint10MindSpore model
TYPE_ONNXuint8_t11ONNX model
TYPE_QNN216uint8_t101QNN2.16 model
TYPE_SNPE216uint8_t102SNPE2.16 model
TYPE_QNN223uint8_t103QNN2.23 model
TYPE_SNPE223uint8_t104SNPE2.23 model
TYPE_QNN229uint8_t105QNN2.29 model
TYPE_SNPE229uint8_t106SNPE2.29 model
TYPE_QNN231uint8_t107QNN2.31 model
TYPE_SNPE231uint8_t1068SNPE2.31 model

[!TIP] 💡Note Special notes:

  • If the user environment has multiple backend implementation software packages such as AidLite-QNN216/AidLite-QNN223/AidLite-QNN229 installed simultaneously, and the FrameworkType in the code is set to TYPE_QNN (i.e., without specifying which specific version of QNN backend to use), then the actual running QNN backend should be the one with the highest QNN version (i.e., AidLite-QNN229 will be prioritized to complete inference).
  • Different QNN version backend software packages cannot be used simultaneously in the same program, which means if the program first specifies TYPE_QNN216 to complete inference, then TYPE_QNN223/TYPE_QNN229 cannot be used for inference.

Inference Acceleration Hardware Type class AccelerateType

For each deep learning inference framework, it may support running on different acceleration hardware units (such as SNPE/QNN models running on Qualcomm DSP computing units, RKNN models running on Rockchip NPU computing units), so in the aforementioned usage workflow, you need to set which computing unit the current model is expected to run on, which requires using this acceleration hardware unit type.

Member Variable NameTypeValueDescription
TYPE_DEFAULTint0Invalid AccelerateType type
TYPE_CPUint1CPU general acceleration unit
TYPE_GPUint2GPU general acceleration unit
TYPE_DSPint3Qualcomm DSP acceleration unit
TYPE_NPUint4NPU general acceleration unit

Log Level class LogLevel

AidliteSDK provides an interface for setting logs (which will be introduced later), which requires providing the interface with which log level to use currently, so this log level needs to be used.

Member Variable NameTypeValueDescription
INFOint0Information
WARNINGint1Warning
ERRORint2Error
FATALint3Fatal error

Input/Output Information class TensorInfo

Each model has its own inputs and outputs. For models that developers are not familiar with, during development they may need to query the input and output Tensor information of the model to facilitate developers in performing pre and post-processing operations for model inference. AidLite provides developers with an interface to query detailed information about model inputs and outputs.

Member Variable List

The TensorInfo object is used to store detailed information about the model's input and output Tensors, including the following parameters:

Field 1Field 2
Member Variableversion
Typeuint32_t
Default ValueNo default value
DescriptionThis member is used to identify the TensorInfo version. If more information needs to be extended in the future, the version number will be updated
Field 1Field 2
Member Variableindex
Typeuint32_t
Default ValueNo default value
DescriptionIndex value of the Tensor
Field 1Field 2
Member Variablename
Typestd::string
Default ValueNo default value
DescriptionName string of the Tensor
Field 1Field 2
Member Variableelement_count
Typeuint64_t
Default Value0
DescriptionNumber of data elements in the Tensor
Field 1Field 2
Member Variableelement_type
Typeenum DataType
Default ValueDataType::TYPE_DEFAULT
DescriptionType of data elements in the Tensor
Field 1Field 2
Member Variabledimensions
Typeuint32_t
Default Value0
DescriptionDimension value of data elements in the Tensor
Field 1Field 2
Member Variableshape
Typestd::vector< uint64_t >
Default ValueNo default value
DescriptionShape description of data elements in the Tensor

Model class Model

As mentioned earlier, before creating an inference interpreter, you need to set specific detailed parameters related to the model. The Model class is mainly used to record the model's file information, structural information, and model-related content during runtime.

Create Model Instance Object create_instance()

To set detailed information related to the model, you naturally need to have a model instance object first. This function is used to create a Model instance object.

Field 1Field 2
APIcreate_instance
DescriptionConstructs a Model type instance object by passing the path name of the model file
Parametersmodel_path: Path name of the model file
Return ValueNormal: Model instance object
Exception: None—
# Create model object using inceptionv3_float32.dlc file in current path, error if return value is empty
model = aidlite.Model.create_instance(model_path=r"./inceptionv3.dlc")
if model is None:
    print("Create model failed !")
    return False

Set Model Properties set_model_properties()

After the model instance object is created successfully, you need to set the input and output data types of the model and the shape information of the input and output tensor data.

Field 1Field 2
APIset_model_properties
DescriptionSet model properties, input and output data shape and data types.
Parametersinput_shapes: Shape array of input tensors, two-dimensional array structure.
input_data_type: Data type of input tensors, DataType enumeration type.—
output_shapes: Shape array of output tensors, two-dimensional array structure.—
output_data_type: Data type of output tensors, DataType enumeration type.—
Return ValueModel file path string object corresponding to the Model object
# Data type uses the aforementioned DataType, input and output shapes are two-dimensional arrays
input_shapes=[[1,640,640,3]]
output_shapes=[[1,10,10,255], [1,20,20,255], [1,40,40,255]]
model.set_model_properties(input_shapes=input_shapes, input_data_type=aidlite.DataType.TYPE_FLOAT32, output_shapes=output_shapes, output_data_type=aidlite.DataType.TYPE_FLOAT32)

Get Model Path get_model_absolute_path()

Field 1Field 2
APIget_model_absolute_path
DescriptionUsed to get the existing path of the model file
ParametersNone
Return ValueModel file path string object corresponding to the Model object
model_path = model.get_model_absolute_path()

Get Model Framework Type get_model_type()

Field 1Field 2
APIget_model_type
DescriptionUsed to get the model type identifier, such as different model categories like DLC, RKNN, etc.
ParametersNone
Return ValueModel file path string object corresponding to the Model object
model_type = model.get_model_type()

Configuration class Config

As mentioned earlier, before creating an inference interpreter, in addition to setting specific Model information, you also need to set some configuration information for inference. The Config class is used to record configuration options that need to be set in advance, and these configuration items will be used at runtime.

Create Config Instance Object create_instance()

To set runtime configuration information, you naturally need to have a configuration instance object first. This function is used to create a Config instance object.

Field 1Field 2
APIcreate_instance
DescriptionUsed to construct an instance object of the Config class
Parameterssnpe_out_names: List of model output node names (optional)
number_of_threads: Number of threads, valid when greater than 0 (optional)—
is_quantify_model: Whether it's a quantized model, 1 indicates quantized model for FAST (optional)—
fast_timeout: Interface timeout (milliseconds, valid when greater than 0) for FAST (optional)—
accelerate_type: Type of acceleration hardware (optional)—
framework_type: Type of underlying deep learning framework (optional)—
Return ValueNormal: Config instance object
Exception: None—
# Create configuration instance object, error if return value is None
config = aidlite.Config.create_instance()
if config is None:
    print("Create config failed !")
    return False

Member Variable List

The Config object is used to set runtime configuration information, including the following parameters:

Field 1Field 2
Member Variableaccelerate_type
Typeclass AccelerateType
Default ValueAccelerateType.TYPE_CPU
DescriptionType of acceleration hardware

Field 1Field 2
Member Variableimplement_type
Typeclass ImplementType
Default ValueImplementType.TYPE_LOCAL
DescriptionDistinction of underlying function implementation approach

Field 1Field 2
Member Variableframework_type
Typeclass FrameworkType
Default ValueFrameworkType.TYPE_DEFAULT
DescriptionType of underlying inference framework

Field 1Field 2
Member Variablenumber_of_threads
Typeint
Default Value-1
DescriptionNumber of threads, valid when greater than 0

Field 1Field 2
Member VariableSNPE_out_names
Typelist
Default ValueNone
DescriptionList of model output node names

Field 1Field 2
Member Variableis_quantify_model
Typeint
Default Value0
DescriptionWhether it's a quantized model, 1 indicates quantized model (only Remote needs to be set)

Field 1Field 2
Member Variableremote_timeout
Typeint
Default Value-1
DescriptionInterface timeout (milliseconds, valid when greater than 0) (only Remote needs to be set)

config.framework_type = aidlite.FrameworkType.TYPE_SNPE
config.accelerate_type = aidlite.AccelerateType.TYPE_DSP
config.is_quantify_model = 1
config.SNPE_out_names = ["InceptionV3/Softmax"]
config.fast_timeout = 1000

Context Class class Context

Used to store runtime context involved in the execution process, including Model objects and Config objects, and may be extended to include runtime data in the future.

Constructor Context()

Field 1Field 2
APIContext
DescriptionConstruct a Context instance object
Parametersmodel: Model instance object
config: Config instance object—
Return ValueNormal: Context instance object
Exception: None—
context = aidlite.Context(model=model, config=config)

Get Model Member Variable get_model()

Field 1Field 2
APIget_model
DescriptionGet the Model object managed by context
ParametersNone
Return ValueModel object
model = context.get_model()

Get Config Member Variable get_config()

Field 1Field 2
APIget_config
DescriptionGet the Config object managed by context
ParametersNone
Return ValueConfig object
config = context.get_config()

Interpreter Class class Interpreter

The Interpreter class object instance is the main entity that executes inference operations and is used to perform specific inference processes. In the inference workflow mentioned earlier, after creating the interpreter object, all operations are completed based on the interpreter object, making it the absolute core content of AidliteSDK.

Create Interpreter Instance Object create_instance()

To execute inference-related operations, the inference interpreter is essential. This function is used to build an instance object of the inference interpreter.

Field 1Field 2
APIcreate_instance
DescriptionUse the various data managed by the Context object to construct an Interpreter type object.
ParametersNone
Return ValueNormal: Interpreter instance object
Exception: None—
# Create interpreter object, return value of None indicates error
interpreter = aidlite.Interpreter.create_instance()
if interpreter is None:
    print("Create Interpreter failed !")
    return False

Initialize init()

After the interpreter object is created, some initialization operations need to be performed (such as environment checking, resource construction, etc.).

Field 1Field 2
APIcreate_instance
DescriptionUse the various data managed by the Context object to construct an Interpreter type object.
Parameterscontext: Context object instance. It manages Model and Config objects, which contain model data, configuration data, etc.
Return ValueNormal: 0
Exception: Non-zero—
# Initialize interpreter, non-zero return value indicates error
result = aidlite.interpreter.init()
if result != 0:
    printf("sample : interpreter->init() failed !")
    return False

Load Model load_model()

After the interpreter object completes the initialization operation, the required model file can be loaded for the interpreter to complete the model loading work. The subsequent inference process uses the loaded model resources.

Field 1Field 2
APIload_model
DescriptionComplete model loading related work. Since the model file path has been set in the Model object previously, the model loading operation can be executed directly
ParametersNone
Return ValueNormal: 0
Exception: Non-zero—
# Load model with interpreter, non-zero return value indicates error
result = interpreter.load_model()
if result != 0:
    print("sample : interpreter->load_model() failed !")
    return False

Get Input Tensor Details get_input_tensor_info()

If you want to get detailed information about the model's input Tensor, you can use this interface to obtain it.

Field 1Field 2
APIget_input_tensor_info
DescriptionGet detailed information about input Tensors in the model
Return ValueNormal: Two-dimensional array of TensorInfo type data
Exception: None—
Special NoteThis interface is supported from version 2.2.5 onwards
# Get detailed information about model input Tensors
input_tensor_info = onnx_interpreter.get_input_tensor_info()
if len(input_tensor_info) == 0 :
    printf("interpreter get_input_tensor_info() failed !\n")
    return False
for gi, graph_tensor_info in enumerate(input_tensor_info):
    for ti, tensor_info in enumerate(graph_tensor_info):
        print(  f"Input  tensor : Graph[{gi}]-Tensor[{ti}]-name[{tensor_info.name}]"
                f"-element_count[{tensor_info.element_count}]-element_type[{tensor_info.element_type}]"
                f"-dimensions[{tensor_info.dimensions}]-shape{tensor_info.shape}")

Get Output Tensor Details get_output_tensor_info()

If you want to get detailed information about the model's output Tensor, you can use this interface to obtain it.

Field 1Field 2
APIget_output_tensor_info
DescriptionGet detailed information about output Tensors in the model
Return ValueNormal: Two-dimensional array of TensorInfo type data
Exception: None—
Special NoteThis interface is supported from version 2.2.5 onwards
# Get detailed information about model output Tensors
output_tensor_info = onnx_interpreter.get_output_tensor_info()
if len(output_tensor_info) == 0 :
    printf("interpreter get_output_tensor_info() failed !\n")
    return False
for gi, graph_tensor_info in enumerate(output_tensor_info):
    for ti, tensor_info in enumerate(graph_tensor_info):
        print(  f"Output tensor : Graph[{gi}]-Tensor[{ti}]-name[{tensor_info.name}]"
                f"-element_count[{tensor_info.element_count}]-element_type[{tensor_info.element_type}]"
                f"-dimensions[{tensor_info.dimensions}]-shape{tensor_info.shape}")

Set Input Data set_input_tensor()

As mentioned when introducing the workflow, before setting input data, different preprocessing operations need to be completed for different models to adapt to specific models.

Field 1Field 2
APIset_input_tensor
DescriptionExecute inference computation process
Parametersin_tensor_tag: Index value or name string of input tensor, type is int or str
input_data: Binary data of input tensor, type is passed according to actual situation—
Return ValueNormal: 0
Exception: Non-zero—
Special NoteParameter in_tensor_tag supports name string from version 2.2.5 onwards
# Set input data for inference, non-zero return value indicates error
result = interpreter.set_input_tensor(in_tensor_tag=1, input_data=obj)
#result = interpreter.set_input_tensor(in_tensor_tag="input_tensor_name", input_data=obj)
if result != 0:
    print("interpreter->set_input_tensor() failed !")
    return False

Execute Inference invoke()

As mentioned when introducing the workflow, after setting the input data, the next step is naturally to execute the inference running process on the input data.

Field 1Field 2
APIinvoke
DescriptionExecute inference computation process
ParametersNone
Return ValueNormal: 0
Exception: Non-zero—
# Execute inference operation, non-zero return value indicates error
result = interpreter.invoke()
if result != 0:
    print("sample : interpreter->invoke() failed !")
    return False

Get Output Data get_output_tensor()

After inference is completed, the result data obtained from inference needs to be extracted. As mentioned when introducing the workflow, after extracting the result data, this result data can be processed to determine whether the result is correct.

Field 1Field 2
APIget_output_tensor
DescriptionAfter successful inference, get inference result data
Parametersout_tensor_tag: Index value or name string of result output tensor, type is int or str
output_type: Type of result output, optional parameter, defaults to aidlite.DataType.TYPE_FLOAT32 if not passed—
Return ValueNormal: float result data.
Exception: None.—
Special NoteParameter out_tensor_tag supports name string from version 2.2.5 onwards
# Get inference result data, return value of None indicates error
out_data = interpreter.get_output_tensor(out_tensor_tag=1, output_type=aidlite.DataType.TYPE_INT32)
#out_data = interpreter.get_output_tensor(out_tensor_tag="output_tensor_name", output_type=aidlite.DataType.TYPE_INT32)
if out_data is None:
    print("interpreter->get_output_tensor() failed !")
    return False

Resource Release destroy()

As mentioned earlier, the interpreter object needs to perform init initialization operations and load model operations. Correspondingly, the interpreter also needs to perform some release operations to destroy the previously created resources.

Field 1Field 2
APIdestroy
DescriptionComplete necessary release operations
ParametersNone
Return ValueNormal: 0
Exception: Non-zero—
# Execute interpreter release process, non-zero return value indicates error
result = interpreter.destroy()
if result != 0:
    print("sample : interpreter-> destroy() failed !")
    return False

Interpreter Builder Class class InterpreterBuilder

Unified creation function for Interpreter objects, create required interpreter objects through this class.

Build Interpreter build_interpreter_from_path()

Build inference interpreter object, can provide different parameters, the simplest is to provide only the path and name of the model file.

Field 1Field 2
APIbuild_interpreter_from_path
DescriptionDirectly create corresponding interpreter object through the path name of the model file. All related parameters use default values
Parameterspath: Path name of the model file
Return ValueNormal: Interpreter object instance
Exception: None—
# Build interpreter by passing Model file path, return value of None indicates error
interpreter = aidlite.InterpreterBuilder.build_interpreter_from_path(path=r"./640.dlc")
if interpreter is None:
    print("Create Interpreter failed !")
    return False

Build Interpreter build_interpreter_from_model()

Build inference interpreter object, in addition to providing the model file path, you can also provide a Model object, so that you can not only set the path name of the model file, but also set the input and output data types of the model and the shape information of input and output data.

Field 1Field 2
APIbuild_interpreter_from_model
DescriptionCreate corresponding interpreter object by passing Model object. Config related parameters all use default values
Parametersmodel: Model type object containing model-related data
Return ValueNormal: Interpreter object instance
Exception: None—
# Build interpreter by passing Model object, return value of None indicates error
interpreter = aidlite.InterpreterBuilder.build_interpreter_from_model(model=model)
if interpreter is None:
    print("Create Interpreter failed !")
    return False

Build Interpreter build_interpreter_from_model_and_config()

Build inference interpreter object, in addition to the two methods mentioned above, you can also provide both Model object and Config object, so that you can not only provide model-related information, but also provide more runtime configuration parameters.

Field 1Field 2
APIbuild_interpreter_from_model_and_config
DescriptionCreate corresponding interpreter object by passing Model object and Config.
Parametersmodel: Model type object containing model-related data
config: Config type object containing some configuration parameters—
Return ValueNormal: Interpreter object instance
Exception: None—
# Build interpreter by passing Model and Config objects, return value of None indicates error
interpreter = aidlite.InterpreterBuilder.build_interpreter_from_model_and_config(model=model, config=config)
if interpreter is None:
    print("Create Interpreter failed !")
    return False

Other Methods

Get SDK Version Information get_library_version()

Field 1Field 2
APIget_library_version
DescriptionUsed to get version-related information of the current AidLite-SDK
ParametersNone
Return ValueReturns version information string of the current AidLite-SDK

Get Python SDK Version Information get_library_version()

Field 1Field 2
APIget_py_library_version
DescriptionUsed to get version-related information of the current Py-AidLite-SDK
ParametersNone
Return ValueReturns version information string of the current Py-AidLite-SDK

Set Log Level set_log_level()

Field 1Field 2
APIset_log_level
DescriptionSet the current minimum log level, output log data greater than or equal to this log level. By default, prints WARNING and above level logs.
Parameterslog_level: LogLevel type value
Return ValueReturns 0 by default

Log Output to Standard Terminal log_to_stderr()

Field 1Field 2
APIlog_to_stderr
DescriptionSet log information output to standard error terminal
ParametersNone
Return ValueReturns 0 by default

Log Output to Text File log_to_file()

Field 1Field 2
APIlog_to_file
DescriptionSet log information output to specified text file
Parameterspath_and_prefix: Storage path and name prefix for log file
also_to_stderr: Flag indicating whether to simultaneously output logs to stderr terminal, default value is False—
Return ValueNormal: 0
Exception: Non-zero—

Get Latest Log Information last_log_msg()

Field 1Field 2
APIlast_log_msg
DescriptionGet the latest log information for a specific log level, typically used to retrieve the latest error information
Parameterslog_level: Value of LogLevel type
Return ValueLatest log information
PreviousTroubleshootingNextAidLite C++ API