# qairt.api.profiler

## qairt.api.profiler.profiler

- *class* qairt.api.profiler.profiler.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.

- *class* qairt.api.profiler.profiler.ProfilerContext(*level: Optional[Union[qti.aisw.tools.core.modules.api.ProfilingLevel, str]] = None*, *option: Optional[Union[qti.aisw.tools.core.modules.api.ProfilingOption, str]] = None*)

    - Bases: `object`

Configuration for how profiling should behave. It can be freely extended with more fields as needed.

- clear()

    - 

- level*: Optional[Union[qti.aisw.tools.core.modules.api.ProfilingLevel, str]]*  *= None*

    - Profiling level. Possible levels are - “basic”, “detailed”, “client” and “backend”.

- option*: Optional[Union[qti.aisw.tools.core.modules.api.ProfilingOption, str]]*  *= None*

    - Profiling Option. Possible options are - “optrace”

- qairt.api.profiler.profiler.add\_profiling\_fields(*cls: Type[BaseModel]*) → Type[BaseModel]

    - Returns a modified pydantic class which support profiling levels and options

1. A profiler context, profiling level and profiling option is inserted into the class
2. The underlying class can now call cls.profiling\_level or cls.profiling\_option properties to retrieve
the levels and options respectively.
3. The profiling level and option are relative to the profiling context specified.

- qairt.api.profiler.profiler.add\_profiling\_fields\_dict(*profiler\_context: ProfilerContext*, *\*\*kwargs*) → dict

    - Add profiling fields level and option to the keyword args

- qairt.api.profiler.profiler.get\_active\_profiler() → Optional[[Profiler](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-core-api.html#qairt.Profiler)]

    - Returns a currently active profiler (if used inside a with block), otherwise
None is returned

- qairt.api.profiler.profiler.profile(*event\_type: str*, *raw\_data\_callable: Optional[Callable[[...], Any]] = None*)

    - A decorator factory that returns a decorator for profiling functions.

- Parameters

    - - **event\_type** – The event type to profile (e.g. “inference”).
- **raw\_data\_callable** – A callable which takes the result of called function and
returns any data to be stored in the captured event.

- Returns

    - A decorator that profiles the decorated function.

## qairt.api.profiler.report

- *class* qairt.api.profiler.report.EventType(*value*)

    - Bases: `str`, `Enum`

An enumeration.

- COMPILE *= 'compile'*

    - 

- CUSTOM *= 'custom'*

    - 

- INFERENCE *= 'inference'*

    -

- *class* qairt.api.profiler.report.FunctionProfilingEvent(*id: int*, *name: str*, *type: [qairt.api.profiler.report.EventType](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-profiler.html#qairt.api.profiler.report.EventType)*, *data: Optional[Any] = None*, *level: Optional[qti.aisw.tools.core.modules.api.definitions.common.ProfilingLevel] = None*, *option: Optional[qti.aisw.tools.core.modules.api.definitions.common.ProfilingOption] = None*)

    - Bases: `object`

- data*: Optional[Any]*  *= None*

    - 

- id*: int*

    - 

- level*: Optional[qti.aisw.tools.core.modules.api.definitions.common.ProfilingLevel]*  *= None*

    - Profiling level (e.g., ‘basic’, ‘detailed’, ‘linting’).

- name*: str*

    - 

- option*: Optional[qti.aisw.tools.core.modules.api.definitions.common.ProfilingOption]*  *= None*

    - Profiling option - “op trace”

- type*: [EventType](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-profiler.html#qairt.api.profiler.report.EventType)*

    -

- *class* qairt.api.profiler.report.OpTraceGenerator

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

- generate\_report(*event: [FunctionProfilingEvent](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-profiler.html#qairt.api.profiler.report.FunctionProfilingEvent)*) → [OpTraceReport](https://docs.qualcomm.com/doc/80-87189-2/topic/qairt-api-profiler.html#qairt.api.profiler.report.OpTraceReport)

    - Generate a profiling report from a list of profiling events.

- *class* qairt.api.profiler.report.OpTraceReport(*\*args: Any*, *\*\*kwargs: Any*)

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

Base class for profiling reports. Supports sub-reports for more granular profiling.

- dump\_qhas(*path: str | os.PathLike*) → str

    - 

- level*: Union[qti.aisw.tools.core.modules.api.definitions.common.ProfilingLevel, str]*  *= 'detailed'*

    - Profiling level “detailed”

- option*: Union[qti.aisw.tools.core.modules.api.definitions.common.ProfilingOption, str]*  *= 'optrace'*

    - “op trace”

- Type

    - Profiling option

- summary*: Optional[Report]*  *= None*

    - A summary of the op trace report

- *class* qairt.api.profiler.report.ProfileLogGenerator

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

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

    - Generate a report from an event.

- *class* qairt.api.profiler.report.ProfilingReport(*\*args: Any*, *\*\*kwargs: Any*)

    - Bases: `Report`

Base class for profiling reports. Supports sub-reports for more granular profiling.

- level*: Optional[Union[qti.aisw.tools.core.modules.api.definitions.common.ProfilingLevel, str]]*  *= None*

    - Profiling level (e.g., ‘basic’, ‘detailed’, ‘linting’).

- option*: Optional[Union[qti.aisw.tools.core.modules.api.definitions.common.ProfilingOption, str]]*  *= None*

    - Profiling option - “op trace”

- *class* qairt.api.profiler.report.ReportGenerator

    - Bases: `object`

Class responsible for transforming profiling events into profiling reports

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

    - Generate a report from an event.

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

    - Generate a list of reports from a list of events.

Last Published: May 26, 2026

[Previous Topic
qairt.api.executor](https://docs.qualcomm.com/bundle/publicresource/80-87189-2/topics/qairt-api-executor.md) [Next Topic
Gen AI API](https://docs.qualcomm.com/bundle/publicresource/80-87189-2/topics/qairt-gen-ai.md)