# Functions

- qairt.compile(*model: Union[[Model](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-core-api.html#qairt.Model), List[[Model](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-core-api.html#qairt.Model)]]*, *\**, *backend: Optional[Union[[BackendType](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.common.BackendType), str]] = None*, *config: Optional[[CompileConfig](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-compiler.html#qairt.api.compiler.config.CompileConfig)] = None*) → [CompiledModel](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-core-api.html#qairt.CompiledModel)

    - Compile the given model for a specified backend using optional configuration options.

- Parameters

    - - **model** (*Union* *[*[*Model*](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-core-api.html#qairt.Model)*,* *List* *[*[*Model*](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-core-api.html#qairt.Model)*]* *]*) – The model(s) object to compile. If a list of models is provided, the
models will be compiled into a single compiled model.
- **backend** (*Optional* *[* *str*  *|* [*BackendType*](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.common.BackendType)*]*) – The QAIRT backend for which to compile the model e.x. “HTP”, “AIC”.
Use [`qairt.api.configs.common.BackendType.offline_preparable_backends()`](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.common.BackendType.offline_preparable_backends) for the full list of supported backends.
- **config** (*Optional* *[*[*CompileConfig*](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-compiler.html#qairt.api.compiler.config.CompileConfig)*]*) – The compile configuration to use. See [`qairt.api.compiler.config.CompileConfig`](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-compiler.html#qairt.api.compiler.config.CompileConfig)
for the full list of options.

Examples

# Compile a model to HTP backend
    compiled_model = qairt.compile(my_model, backend="HTP")

    # Compile the model for a particular SOC
    compile_config =  CompileConfig(backend="HTP", soc_details="chipset:SM8550")
    compiled_model_8550 = qairt.compile(my_model, config=compile_config)
    Copy to clipboard

- Returns

    - A new CompiledModel instance containing a reference to a generated context binary.

- Return type

    - [CompiledModel](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-core-api.html#qairt.CompiledModel)

- Raises

    - **CompilationError** – If a context binary could not be generated from the Model.

Note

One of backend and config should be specified. if both backend and config are specified,
the backend argument will be ignored.

- qairt.convert(*model: str | os.PathLike*, *encodings: Optional[Union[str, PathLike]] = None*, *calibration\_config: Optional[[CalibrationConfig](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-converter.html#qairt.api.converter.converter_config.CalibrationConfig)] = None*, *backend: str | [qairt.api.configs.common.BackendType](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.common.BackendType) = 'HTP'*, *\*\*extra\_args*) → [Model](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-core-api.html#qairt.Model)

    - Convert a framework model into a Model object.

- Parameters

    - - **model** – The framework model path (frameworks supported: ONNX, TFLite and PyTorch).
- **encodings** – The encoding information to be applied to the graph.
- **calibration\_config** – Configuration for calibration process. Use this option to pass in sample input data
for calibration.
See [`qairt.api.converter.converter_config.CalibrationConfig`](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-converter.html#qairt.api.converter.converter_config.CalibrationConfig) for details.
- **backend** – Specifies the backend used for serialization. This arg is required when using V2 encodings.
Available options are HTP (default), CPU, AIC, and LPAI.
Note: For V2 encodings, only HTP is supported. For non-V2 encodings, all options are valid.
- **\*\*extra\_args** –

    Extra keyword arguments for conversion options.
See [`qairt.api.converter.converter_config.ConverterConfig`](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-converter.html#qairt.api.converter.converter_config.ConverterConfig) for details.

- Additional supported arguments include:
    - - - <cite>lora_importer_config</cite>: Optional configuration for LoRA Importer’s
    - apply\_lora\_updates
    - - <cite>lora_tensor_names</cite>: Optional file specifying a list of tensor names
    - that should be updatable.
    - <cite>quant_updatable_mode</cite>: Mode for quant-updatable tensors.
    - <cite>disable_batchnorm_folding</cite>: (Optimization) Disables batch normalization folding.
    - <cite>expand_lstm_op_structure</cite>: (Optimization) Expands LSTM operator structure.
    - <cite>multi_time_steps_lstm</cite>: (Optimization) Enables multi-time steps LSTM optimization.
    - <cite>multi_time_steps_gru</cite>: (Optimization) Enables multi-time steps GRU optimization.

Examples

converted_model = qairt.convert("path/to/model")
    
    # For applying encodings -
    converted_model = qairt.convert("path/to/model", encodings="path/to/encodings")
    
    # For calibration
    calib_config = CalibrationConfig(dataset=input_data, batch_size = 4, act_precision = 16)
    converted_model = qairt.convert("/path/to/model", calibration_config=calib_config)
    
    # Using extra args
    converted_model = qairt.convert("path/to/model",
                                    float_precision=16,
                                    input_tensor_config=[{"name": "input", "shape": (1, 3, 224, 224), "desired_datatype"="int8"}])
    
    # Advance IO customization
    converted_model = qairt.convert("path/to/model",
                                    input_tensor_config=[InputTensorConfig(name="input", shape=(1,3,224,224), desired_datatype="int8",
                                    layout="NCHW", desired_layout="NHWC", quant_param = QuantParam(scale=1.0, offset=0), optional = True)],
                                    output_tensor_config=[OutputTensorConfig(name="output", layout="NCHW", desired_datatype="uint16", optional = True)])
    
    # Using optimizer args
    converted_model = qairt.convert("path/to/model",
                                    disable_batchnorm_folding=True,
                                    multi_time_steps_lstm=True)
    
    # See qairt.api.converter.converter_config.InputTensorConfig and qairt.api.converter.converter_config.OutputTensorConfig for details.
    Copy to clipboard

- Returns

    - A Model instance that is executable on a QAIRT Runtime.

- Return type

    - [Model](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-core-api.html#qairt.Model)

- Raises

    - - **ValidationError** – If provided extra args are invalid.
- **ConversionError** – If model conversion fails.
- **OptimizationError** – If model optimization fails.
- **SerializationError** – If model serialization fails.
- **ApplyEncodingsError** – If apply encodings fails.

Note

To convert pytorch models, the <cite>input_tensor_config</cite> argument must be passed in to specify
the input tensor shape and data type:

converted_model = qairt.convert("model.pt", input_tensor_config= [InputTensorConfig(name="input",
    shape=(1,3,224,224))])
    Copy to clipboard

- qairt.load(*path: str | os.PathLike*, *\*\*load\_args*) → [Model](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-core-api.html#qairt.Model)

    - Loads assets of the following types:

> 
> 
> - A QAIRT Deep Learning Container (.dlc)
> - A QAIRT context binary (.bin)

- Parameters

    - - **path** (*str*) – Path to the DLC or binary.
- **\*\*load\_args** – Additional arguments for loading a DLC or binary. For specifics,
see [`CompiledModel.load()`](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-core-api.html#qairt.CompiledModel.load) for binaries and compiled DLCs or
[`Model.load()`](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-core-api.html#qairt.Model.load) for DLCs.

Examples

# Load a DLC
    my_model = qairt.load("model.dlc")
    
    # load a binary (.bin)
    my_model = qairt.load("model.bin")
    Copy to clipboard

- Returns

    - A model object if the path is a valid DLC
CompiledModel: A child class of a model object if the model is a binary or
DLC compiled for a QAIRT Backend.

- Return type

    - [Model](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-core-api.html#qairt.Model)

- Raises

    - **LoadAssetError** – If the path is not a valid DLC or binary.

- *class* qairt.CompiledModel(*module: qairt.modules.dlc\_module.dlc\_module.DlcModule | qairt.modules.cache\_module.cache\_module.CacheModule*, *backend: Optional[Union[[BackendType](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.common.BackendType), str]] = None*, *\**, *name: str = ''*, *config: Optional[[CompileConfig](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-compiler.html#qairt.api.compiler.config.CompileConfig)] = None*)

    - Bases: [`Model`](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-core-api.html#qairt.Model)

Representative entity that has been prepared for execution on a QAIRT Backend,
and is executable only that backend.This means that graph initialization and composition
has been performed, and the model contains a reference to a serialized cache or a container
composed of serialized caches.

- It has the following additional properties:
    - - It can be saved to an asset that remains executable only on the QAIRT Backend for which it has been
compiled.
- It can be loaded from a DLC or Binary asset. If load is successful, the CompiledModel object
can be executed similar to the asset.
- It can be queried to return properties that identify the asset from which it was loaded. No properties
may be changed after the object has been created.

- \_\_call\_\_(*inputs: Union[str, PathLike, ndarray, Dict[str, ndarray], List[ndarray], List[Dict[str, ndarray]]]*, *\**, *backend: Optional[str] = None*, *device: Optional[[Device](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.device.Device)] = None*, *\*\*kwargs*) → [ExecutionResult](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.common.ExecutionResult)

    - Public method to execute the model. Handles the execution flow internally by calling self.\_execute.

- Parameters

    - - **inputs** – Input data to be used for execution.
- **backend** (*Optional* *[* *str* *]*) – The intended QAIRT Backend for execution. Defaults to self.backend
if no backend is specified.
- **device** (*Optional* *[*[*Device*](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.device.Device)*]*) – The intended QAIRT device. If none, then the default local host is used.
- **\*\*kwargs** –

    Keyword arguments for execution.

- kwargs may contain:
    - - Extra keyword arguments to pass for execution. See submodule
[`qairt.api.executor.execution_config.ExecutionConfig`](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-executor.html#qairt.api.executor.execution_config.ExecutionConfig) for details.
    - Arguments to pre or post execute hooks.

Examples

compiled_model = qairt.load("model.bin")
    
    # Execute the model with a single input
    result = compiled_model(inputs=np.ndarray(shape=(1, 3, 224, 224)))
    
    # Execute the model on device
    from qairt import Device, RemoteDeviceIdentifier, DevicePlatformType
    
    device = Device(RemoteDeviceIdentifier(serial_id="abcd123"), type=DevicePlatformType.ANDROID)
    result = compiled_model(inputs=np.ndarray(shape=(1, 3, 224, 224)), device=device)
    
    # Execute the model with kwargs
    result = compiled_model(inputs=np.ndarray(shape=(1, 3, 224, 224)), synchronous=False, use_mmap=True)
    Copy to clipboard

- Returns

    - The result after applying pre-execute hooks, execution, and post-execute hooks.
The result contains the inference output data in memory, and any additional output generated from
profiling.

- Return type

    - [ExecutionResult](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.common.ExecutionResult)

- Raises

    - - **AttributeError** – if no backend can be identified
- **ExecutionError** – if an error occurs during model execution

- \_execute(*inputs: Union[str, PathLike, ndarray, Dict[str, ndarray], List[ndarray], List[Dict[str, ndarray]]]*, *\**, *backend: Optional[Union[[BackendType](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.common.BackendType), str]] = None*, *device: Optional[[Device](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.device.Device)] = None*, *\*\*extra\_args*) → [ExecutionResult](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.common.ExecutionResult)

    - > 
> 
> Performs inference on a QAIRT backend.

This method is triggered via the \_\_call\_\_ method, and must be implemented by
any subclasses. The behavior of this method is not guaranteed if it is called directly.

- Parameters

    - - **inputs** – Input data to be used for execution. See <cite>qairt.configs.common.ExecutionInputData</cite> for types.
- **backend** (*Optional* *[*[*BackendType*](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.common.BackendType)*]*) – The intended QAIRT Backend for execution. If no backend is specified,
then self.\_backend is used.
- **device** (*Optional* *[*[*Device*](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.device.Device)*]*) – The intended QAIRT device. If none, then the default local host is used.
- **extra\_args** – Extra keyword arguments to pass for execution. See submodule
[`qairt.api.executor.execution_config.ExecutionConfig`](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-executor.html#qairt.api.executor.execution_config.ExecutionConfig) for details.

- Returns

    - The result after applying pre-execute hooks, execution, and post-execute hooks.
The result contains the inference output data in memory, and any additional output generated from
profiling.

- Return type

    - [ExecutionResult](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.common.ExecutionResult)

- Raises

    - - **ValidationError** – if provided extra args are not valid
- **ExecutionError** – if an error occurs during compiled model execution

- *property* backend*: Optional[Union[[BackendType](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.common.BackendType), str]]*

    - Returns the backend associated with this model.

- *property* config*: Optional[[CompileConfig](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-compiler.html#qairt.api.compiler.config.CompileConfig)]*

    - Returns the configuration used to compile this model.

- initialize(*backend: Optional[Union[[BackendType](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.common.BackendType), str]] = None*, *device: Optional[[Device](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.device.Device)] = None*, *\*\*extra\_args*) → None

    - Initializes the QAIRT model and loads required backend artifacts needed for executing on device.

This function is optional, and should be used if you intend to call execute multiple times
with the same model, backend, and device. In addition to enabling a single initialization,
this method controls the lifetime of backend library artifacts.

- Parameters

    - - **backend** (*Optional* *[*[*BackendType*](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.common.BackendType)*]* *,* *optional*) – The intended QAIRT Backend for execution.
- **device** (*Optional* *[*[*Device*](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.device.Device)*]* *,* *optional*) – The intended QAIRT device. If none, then the default local host is used.
- **extra\_args** – Extra keyword arguments to pass for execution.
See [`qairt.api.executor.execution_config.ExecutionConfig`](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-executor.html#qairt.api.executor.execution_config.ExecutionConfig) for details.

- *classmethod* load(*path: str | os.PathLike*, *\**, *name: str = ''*, *compile\_config: Optional[[CompileConfig](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-compiler.html#qairt.api.compiler.config.CompileConfig)] = None*, *backend: Optional[[BackendType](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.common.BackendType)] = None*, *lora\_config\_or\_path: Optional[Union[str, PathLike, List[[UseCaseOutputConfig](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-gen-ai-modules-lora.html#qairt.modules.lora.lora_config.UseCaseOutputConfig)]]] = None*, *\*\*load\_args*) → [CompiledModel](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-core-api.html#qairt.CompiledModel)

    - Loads a model from a specified context binary (.bin) or DLC (.dlc).

- Parameters

    - - **path** (*str*) – The path to a binary or DLC.
- **name** (*str*) – The name of the model
- **compile\_config** (*Optional* *[*[*CompileConfig*](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-compiler.html#qairt.api.compiler.config.CompileConfig)*]*) – The specifications used to compile this model.
- **backend** (*Optional* *[*[*BackendType*](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.common.BackendType)*]*) – The backend this model is associated with.
- **lora\_config\_or\_path** (*Optional* *[* *Union* *[* *str* *,* *PathLike* *,* *List* *[*[*UseCaseOutputConfig*](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-gen-ai-modules-lora.html#qairt.modules.lora.lora_config.UseCaseOutputConfig)*]* *]* *]*) – Path to lora\_use\_cases.yaml file or a list of UseCaseOutputConfig objects.
- **load\_args** (*Optional* *[* *Dict* *[* *str* *,* *Any* *]* *]*) – Additional arguments for loading a DLC. See DLCModule.load
- **details.** (*for*) –

- Returns

    - The loaded model object.

- Return type

    - [CompiledModel](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-core-api.html#qairt.CompiledModel)

- *property* module*: qairt.modules.dlc\_module.dlc\_module.DlcModule | qairt.modules.cache\_module.cache\_module.CacheModule*

    - Returns the module associated with this model.

- *property* quantized*: bool*

    - Returns True if the model is quantized False otherwise.

- save(*path: str | os.PathLike = ''*, *asset\_type: Optional[AssetType] = None*, *\*\*kwargs*) → str

    - Saves a model

- Parameters

    - - **path** (*str*) – The path where the model should be saved.
- **asset\_type** (*Optional* *[* *AssetType* *]*) – The type of asset to write to disk. The option can be used
to save a DLC loaded as a compiled model as a directory
of context binaries by setting the asset\_type to AssetType.CTX\_BIN.
- **kwargs** (*Optional* *[* *Dict* *[* *str* *,* *Any* *]* *]*) – Additional arguments for saving the model.

Examples

compiled_model.save("model.bin")
    Copy to clipboard

- Returns

    - The path where the model was saved.

- Return type

    - str

- save\_with\_assets(*dir\_path: str | os.PathLike = '.'*, *\*\*kwargs*) → str

    - Saves all assets associated with this model. This method can be used to save the model and additional
assets such as profiling logs and binaries generated during execution.

- Parameters

    - - **dir\_path** (*DirectoryPath*) – The path directory where the model, along with any associated assets,
should be saved.
- **\*\*kwargs** – Additional keyword arguments.

- Returns

    - The path where the assets were saved.

- Return type

    - str

- Raises

    - **IOError** – If the provided path does not exist or is not a directory.

- *class* qairt.Model(*module: DlcModule*, *\**, *name: str = ''*)

    - Bases: `ModelBase`

Representative entity that is executable on a QAIRT Backend.

It has the following additional properties:

- It can be saved to an asset that remains executable on a QAIRT Backend.
- It can be loaded from a DLC. If load is successful, the Model object can be executed similar
to the asset.
- It can be queried to return properties that identify the asset from which it was loaded.

- \_\_call\_\_(*inputs: Union[str, PathLike, ndarray, Dict[str, ndarray], List[ndarray], List[Dict[str, ndarray]]]*, *\**, *backend: Optional[str] = 'CPU'*, *device: Optional[[Device](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.device.Device)] = None*, *optional\_output\_tensor\_names: Optional[Union[List[str], Dict[str, Optional[List[str]]]]] = None*, *\*\*kwargs*) → [ExecutionResult](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.common.ExecutionResult)

    - Public method to execute the model. Handles the execution flow internally by calling self.\_execute.

- Parameters

    - - **inputs** –

    Input data to be used for execution. Input data could be of the following types.

    - np.ndarray | Sequence[np.ndarray]: A single numpy array or sequence of numpy arrays.
    - - str | PathLike: A path to an input list text file containing paths to raw data.
    - This type is intended for data that will be executed on remote devices,
where the data must be pushed to the execution environment.
The format of this file is defined further in documentation.
See <cite>QAIRT SDK</cite> for details.
    - Dict[str, np.ndarray]: A dictionary of tensor names to
numpy arrays.
- **backend** (*Optional* *[* *str* *]*) – The intended QAIRT Backend for execution. Defaults to
“CPU” if no backend is specified.
- **device** (*Optional* *[*[*Device*](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.device.Device)*]*) – The intended QAIRT device. If none, then the default local host is used.
- **optional\_output\_tensor\_names** (*Optional* *[* *Union* *[* *List* *[* *str* *]* *,* *Dict* *[* *str* *,* *Optional* *[* *List* *[* *str* *]* *]* *]* *]* *]*) –

    Controls which optional output tensors to return from the model. This parameter does not affect
mandatory outputs, which are always included.

    For single-graph models:
- If None (default): Returns all optional outputs (same as CLI behavior when optionalOutputTensorNames is omitted)
- If empty list ([]): Returns no optional outputs (only mandatory outputs)
- If list of strings: Returns only the specified optional outputs plus all mandatory outputs

    For multi-graph models:
- Should be a dictionary mapping graph names to their respective output selections
- Each value follows the same rules as single-graph models.
- **\*\*kwargs** –

    Keyword arguments for execution.

- kwargs may contain
    - - Extra keyword arguments to pass for execution.
See [`qairt.api.executor.execution_config.ExecutionConfig`](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-executor.html#qairt.api.executor.execution_config.ExecutionConfig) for details.
    - Arguments to pre or post execute hooks.

Examples

model = qairt.load("model.dlc")
    
    # Execute the model with a single input
    result = model(inputs=np.ndarray(shape=(1, 3, 224, 224)))
    
    # Execute the model on device
    from qairt import Device, RemoteDeviceIdentifier, DevicePlatformType
    
    device = Device(RemoteDeviceIdentifier(serial_id="abcd123"), type=DevicePlatformType.ANDROID)
    result = model(inputs=np.ndarray(shape=(1, 3, 224, 224)), backend="HTP", device=device)
    
    # Execute the model with kwargs
    result = model(inputs=np.ndarray(shape=(1, 3, 224, 224)), synchronous=False, use_mmap=True)
    
    # Execute the single graph model with output tensor names
    result = model(inputs=inputs, optional_output_tensor_names=["tensor1", "tensor2"])
    
    # Execute single graph model, get only mandatory outputs
    result = model(inputs=inputs, optional_output_tensor_names=[])
    
    # Execute Multi-graph model with different selections per graph
    result = model(inputs=inputs, optional_output_tensor_names={
        "graph1": ["tensorA", "tensorB"],
        "graph2": None,  # All optional outputs for graph2
        "graph3": []      # No optional outputs for graph3
    })
    Copy to clipboard

- Returns

    - The result after applying pre-execute hooks, execution, and post-execute hooks.
The result contains the inference output data in memory, and any additional output generated from
profiling.

- Return type

    - [ExecutionResult](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.common.ExecutionResult)

- Raises

    - **ExecutionError** – if a runtime error occurs.

- \_execute(*inputs: Union[str, PathLike, ndarray, Dict[str, ndarray], List[ndarray], List[Dict[str, ndarray]]]*, *\**, *backend: str | [qairt.api.configs.common.BackendType](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.common.BackendType) = 'CPU'*, *device: Optional[[Device](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.device.Device)] = None*, *\*\*extra\_args*) → [ExecutionResult](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.common.ExecutionResult)

    - Performs inference on a QAIRT backend.

This method is triggered via the \_\_call\_\_ method, and must be implemented by
any subclasses. The behavior of this method is not guaranteed if it is called directly.

- Parameters

    - - **inputs** (*ExecutionInputData*) – Input data to be used for execution.
- **backend** (*Optional* *[*[*BackendType*](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.common.BackendType)*]*) – The intended QAIRT Backend for execution. Defaults to
“CPU” if no backend is specified.
- **device** (*Optional* *[*[*Device*](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.device.Device)*]*) – The intended QAIRT device. If none, then the default local host is used.
- **extra\_args** – Extra keyword arguments to pass for execution. See submodule
[`qairt.api.executor.execution_config.ExecutionConfig`](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-executor.html#qairt.api.executor.execution_config.ExecutionConfig) for details.

- Returns

    - The result contains the inference output data in memory, and
any additional output generated from profiling.

- Return type

    - [ExecutionResult](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.common.ExecutionResult)

- Raises

    - - **ValidationError** – if provided extra args are not valid
- **ExecutionError** – if an error occurs during model execution

- destroy() → None

    - This method is called when the model object is being garbage collected.
It unloads the model from memory and releases any associated resources.

- Returns

    - None

- *property* graphs\_info*: list[qairt.modules.common.graph\_info\_models.GraphInfo]*

    - Returns a list of graph information details of the model.

- initialize(*backend: Union[str, [BackendType](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.common.BackendType)] = 'CPU'*, *device: Optional[[Device](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.device.Device)] = None*, *\*\*extra\_args*) → None

    - Initializes the QAIRT model and loads required backend artifacts needed for executing on device.

This function is optional, and should be used if you intend to call execute multiple times
with the same model, backend, and device. In addition to enabling a single initialization,
this method controls the lifetime of backend library artifacts.

- Parameters

    - - **backend** (*Optional* *[*[*BackendType*](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.common.BackendType)*]* *,* *optional*) – The intended QAIRT Backend for execution.
Defaults to “CPU” if no backend is specified.
- **device** (*Optional* *[*[*Device*](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-configs.html#qairt.api.configs.device.Device)*]* *,* *optional*) – The intended QAIRT device. If none, then the default local host is used.
- **extra\_args** – Extra keyword arguments to pass for execution.
See [`qairt.api.executor.execution_config.ExecutionConfig`](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-executor.html#qairt.api.executor.execution_config.ExecutionConfig) for details.

- *property* input\_tensors*: List[Tuple[str, List[TensorInfo]]]*

    - Returns the input tensor information of the model.

- Returns

    - A list of tuples containing the graph name and input tensors information.

- Return type

    - list

- *classmethod* load(*path: str | os.PathLike*, *\**, *name: str = ''*, *load\_weight\_data: bool = True*, *\*\*load\_args*) → [Model](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-core-api.html#qairt.Model)

    - Loads a DLC from the specified path.

- Parameters

    - - **path** (*str*) – The path to a DLC.
- **name** (*str*) – The name of the model
- **load\_weight\_data** (*bool*) – Whether to load the weights of the DLC on initialization.
- **load\_args** (*Optional* *[* *Dict* *[* *str* *,* *Any* *]* *]*) – Additional arguments for loading a DLC.
See DlcModule.load for details.

- Returns

    - The loaded model object.

- *property* module*: DlcModule*

    - Returns the dlc module associated with this model.

- *property* output\_tensors*: List[Tuple[str, List[TensorInfo]]]*

    - Returns the output tensor information of the model.

- Returns

    - A list of tuples containing the graph name and output tensors information.

- Return type

    - list

- *property* quantized*: bool*

    - Returns True if the model is quantized False otherwise.

- save(*path: str | os.PathLike = ''*, *\*\*kwargs*) → str

    - Saves a model as a DLC (.dlc).

- Parameters

    - **path** (*str*) – The path where the model will be saved.

Examples

model.save("model.dlc")
    Copy to clipboard

- Returns

    - The path where the model, along with any associated assets, were saved.

- save\_with\_assets(*dir\_path: str | os.PathLike = '.'*, *\*\*kwargs*) → str

    - Saves all assets associated with this model. This method can be used to save the model and additional
assets such as profiling logs and binaries generated during execution.

- Parameters

    - - **dir\_path** (*DirectoryPath*) – The path directory where the model, along with any associated assets,
should be saved.
- **\*\*kwargs** – Additional keyword arguments.

- Returns

    - The path where the assets were saved.

- Return type

    - str

- *class* qairt.Profiler(*context: Optional[Dict[str, Any]] = None*, *report\_generator: Optional[[ReportGenerator](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-profiler.html#qairt.api.profiler.report.ReportGenerator)] = None*, *event\_name\_prefix: str = ''*)

    - Bases: `object`

Captures function profiling events for the duration of a with block. It can be used as a context manager
and becomes the active profiler within the context.

- capture\_function\_event(*name: str*, *type: str | [qairt.api.profiler.report.EventType](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-profiler.html#qairt.api.profiler.report.EventType)*, *data: Any*)

    - Captures a function profiling event.

- Parameters

    - - **name** (*str*) – The name of the function being profiled.
- **type** (*str*  *|* [*EventType*](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-profiler.html#qairt.api.profiler.report.EventType)) – The type of event.
- **data** – Additional data associated with the event.

- *property* context

    - Returns the profiler’s current context

- generate\_report(*event\_id: int = -1*)

    - Returns a profiling report based on id

- generate\_reports() → List[[ProfilingReport](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-profiler.html#qairt.api.profiler.report.ProfilingReport)]

    - Returns a profiling report.

- get\_event(*event\_id: int = -1*)

    - Returns the event with the given id.

- get\_events() → List[[FunctionProfilingEvent](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-profiler.html#qairt.api.profiler.report.FunctionProfilingEvent)]

    - Returns a list of captured profiling events.

- get\_reports()

    - Returns a generator that yields profiling reports.

Last Published: May 26, 2026

[Previous Topic
Core API](https://docs.qualcomm.com/bundle/publicresource/80-87189-2/topics/qairt-core.md) [Next Topic
Modules](https://docs.qualcomm.com/bundle/publicresource/80-87189-2/topics/core_qairt-modules.md)