Provides context-related APIs for configuring runtime information. This API is not thread-safe.
File to include: <mindspore/context.h>
Library: libmindspore_lite_ndk.so
System capability: SystemCapability.Ai.MindSpore
Since: 9
Related module: MindSpore
| Name | typedef Keyword | Description |
|---|---|---|
| OH_AI_ContextHandle | void* | Pointer to the MindSpore Lite context information, which points to Context. |
| OH_AI_DeviceInfoHandle | void* | Pointer to the MindSpore Lite running device information. |
| Name | Description |
|---|---|
| OH_AI_API OH_AI_ContextHandle OH_AI_ContextCreate() | Creates a context object. Note: This API must be used together with OH_AI_ContextDestroy. |
| OH_AI_API void OH_AI_ContextDestroy(OH_AI_ContextHandle *context) | Destroys a context object. |
| OH_AI_API void OH_AI_ContextSetThreadNum(OH_AI_ContextHandle context, int32_t thread_num) | Sets the number of runtime threads. |
| OH_AI_API int32_t OH_AI_ContextGetThreadNum(const OH_AI_ContextHandle context) | Obtains the number of threads. |
| OH_AI_API void OH_AI_ContextSetThreadAffinityMode(OH_AI_ContextHandle context, int mode) | Sets the policy for binding runtime threads to CPU cores. CPU physical cores are classified into big, medium, and small cores by frequency. Only big cores or medium cores need to be bound, and small cores do not need to be bound. |
| OH_AI_API int OH_AI_ContextGetThreadAffinityMode(const OH_AI_ContextHandle context) | Obtains the policy for binding runtime threads to CPU cores. |
| OH_AI_API void OH_AI_ContextSetThreadAffinityCoreList(OH_AI_ContextHandle context, const int32_t *core_list,size_t core_num) | Sets the list of CPU cores to which runtime threads are bound. For example, when core_list=[2,6,8], the threads run on CPU cores 2, 6, and 8. If both OH_AI_ContextSetThreadAffinityMode and OH_AI_ContextSetThreadAffinityCoreList are called for the same context object, only the core_list parameter of OH_AI_ContextSetThreadAffinityCoreList takes effect, while the mode parameter of OH_AI_ContextSetThreadAffinityMode does not take effect. |
| OH_AI_API const int32_t *OH_AI_ContextGetThreadAffinityCoreList(const OH_AI_ContextHandle context, size_t *core_num) | Obtains the CPU core binding list. |
| OH_AI_API void OH_AI_ContextSetEnableParallel(OH_AI_ContextHandle context, bool is_parallel) | Sets whether to support parallelism at runtime. This feature is not enabled yet, and the setting does not take effect. |
| OH_AI_API bool OH_AI_ContextGetEnableParallel(const OH_AI_ContextHandle context) | Obtains whether parallelism between operators is supported. |
| OH_AI_API void OH_AI_ContextAddDeviceInfo(OH_AI_ContextHandle context, OH_AI_DeviceInfoHandle device_info) | Attaches user-defined running device information to the inference context. |
| OH_AI_API OH_AI_DeviceInfoHandle OH_AI_DeviceInfoCreate(OH_AI_DeviceType device_type) | Creates a device information object. |
| OH_AI_API void OH_AI_DeviceInfoDestroy(OH_AI_DeviceInfoHandle *device_info) | Destroys a device information instance. Note: After a device information instance is added to the context, the caller does not need to destroy it manually. |
| OH_AI_API void OH_AI_DeviceInfoSetProvider(OH_AI_DeviceInfoHandle device_info, const char *provider) | Sets the name of the provider. |
| OH_AI_API const char *OH_AI_DeviceInfoGetProvider(const OH_AI_DeviceInfoHandle device_info) | Obtains the name of the provider. |
| OH_AI_API void OH_AI_DeviceInfoSetProviderDevice(OH_AI_DeviceInfoHandle device_info, const char *device) | Sets the name of the provider device. |
| OH_AI_API const char *OH_AI_DeviceInfoGetProviderDevice(const OH_AI_DeviceInfoHandle device_info) | Obtains the name of the provider device. |
| OH_AI_API OH_AI_DeviceType OH_AI_DeviceInfoGetDeviceType(const OH_AI_DeviceInfoHandle device_info) | Obtains the type of the device. |
| OH_AI_API void OH_AI_DeviceInfoSetEnableFP16(OH_AI_DeviceInfoHandle device_info, bool is_fp16) | Sets whether to enable the float16 inference mode. This API is available only for CPU/GPU devices. |
| OH_AI_API bool OH_AI_DeviceInfoGetEnableFP16(const OH_AI_DeviceInfoHandle device_info) | Obtains whether the float16 inference mode is enabled. This API is available only for CPU/GPU devices. |
| OH_AI_API void OH_AI_DeviceInfoSetFrequency(OH_AI_DeviceInfoHandle device_info, int frequency) | Sets the NPU frequency. This API is available only for NPU devices. |
| OH_AI_API int OH_AI_DeviceInfoGetFrequency(const OH_AI_DeviceInfoHandle device_info) | Obtains the NPU frequency type. This API is available only for NPU devices. |
| OH_AI_API NNRTDeviceDesc *OH_AI_GetAllNNRTDeviceDescs(size_t *num) | Obtains the description information of all NNRt hardware devices in the system. |
| OH_AI_API NNRTDeviceDesc *OH_AI_GetElementOfNNRTDeviceDescs(NNRTDeviceDesc *descs, size_t index) | Obtains the pointer to an element in the NNRt device description information array. |
| OH_AI_API void OH_AI_DestroyAllNNRTDeviceDescs(NNRTDeviceDesc **desc) | Destroys the NNRt description information instance array obtained from OH_AI_GetAllNNRTDeviceDescs. |
| OH_AI_API size_t OH_AI_GetDeviceIdFromNNRTDeviceDesc(const NNRTDeviceDesc *desc) | Obtains the NNRt device ID from a specific NNRt device description information instance. Note: This ID is valid only for NNRt. |
| OH_AI_API const char *OH_AI_GetNameFromNNRTDeviceDesc(const NNRTDeviceDesc *desc) | Obtains the NNRt device name from a specific NNRt device description information instance. |
| OH_AI_API OH_AI_NNRTDeviceType OH_AI_GetTypeFromNNRTDeviceDesc(const NNRTDeviceDesc *desc) | Obtains the NNRt device type from a specific NNRt device description information instance. |
| OH_AI_API OH_AI_DeviceInfoHandle OH_AI_CreateNNRTDeviceInfoByName(const char *name) | Finds the NNRt device with the specified name and creates NNRt device information based on the first device found. |
| OH_AI_API OH_AI_DeviceInfoHandle OH_AI_CreateNNRTDeviceInfoByType(OH_AI_NNRTDeviceType type) | Finds the NNRt device of the specified type and creates NNRt device information based on the first device found. |
| OH_AI_API void OH_AI_DeviceInfoSetDeviceId(OH_AI_DeviceInfoHandle device_info, size_t device_id) | Sets the NNRt device ID. This API is available only for NNRt devices. |
| OH_AI_API size_t OH_AI_DeviceInfoGetDeviceId(const OH_AI_DeviceInfoHandle device_info) | Obtains the NNRt device ID. This API is available only for NNRt devices. |
| OH_AI_API void OH_AI_DeviceInfoSetPerformanceMode(OH_AI_DeviceInfoHandle device_info, OH_AI_PerformanceMode mode) | Sets the NNRt performance mode. This API is available only for NNRt devices. |
| OH_AI_API OH_AI_PerformanceMode OH_AI_DeviceInfoGetPerformanceMode(const OH_AI_DeviceInfoHandle device_info) | Obtains the NNRt performance mode. This API is available only for NNRt devices. |
| OH_AI_API void OH_AI_DeviceInfoSetPriority(OH_AI_DeviceInfoHandle device_info, OH_AI_Priority priority) | Sets the NNRt task priority. This API is available only for NNRt devices. |
| OH_AI_API OH_AI_Priority OH_AI_DeviceInfoGetPriority(const OH_AI_DeviceInfoHandle device_info) | Obtains the NNRt task priority. This API is available only for NNRt devices. |
| OH_AI_API OH_AI_Status OH_AI_DeviceInfoAddExtension(OH_AI_DeviceInfoHandle device_info, const char *name,const char *value, size_t value_size) | Adds an extension configuration in key/value pair form to the device information. This API is valid only for NNRt device information. Currently, only the following 11 keys are supported: {"CachePath": "YourCachePath"}, {"CacheVersion": "YourCacheVersion"}, {"QuantBuffer": "YourQuantBuffer"}, {"ModelName": "YourModelName"}, {"isProfiling": "YourProfilingSwitch"}, {"opLayout": "YourOpLayout"}, {"InputDims": "YourInputDims"}, {"DynamicDims": "YourDynamicDims"}, {"QuantConfigData": "YourQuantConfigData"}, {"BandMode": "YourBandMode"}, {"NPU_FM_SHARED": "YourNPU_FM_SHARED"}. You can configure the value of each key based on your usage. |
OH_AI_API OH_AI_ContextHandle OH_AI_ContextCreate()
Description
Creates a context object. Note: This interface must be used together with OH_AI_ContextDestroy.
Since: 9
Return
| Type | Description |
|---|---|
| OH_AI_API OH_AI_ContextHandle | Pointer to the OH_AI_ContextHandle of the context information. |
OH_AI_API void OH_AI_ContextDestroy(OH_AI_ContextHandle *context)
Description
Destroys the context object.
Since: 9
Parameters
| Name | Description |
|---|---|
| OH_AI_ContextHandle *context | Double pointer to OH_AI_ContextHandle. After the context is destroyed, context is set to a null pointer. |
OH_AI_API void OH_AI_ContextSetThreadNum(OH_AI_ContextHandle context, int32_t thread_num)
Description
Sets the number of threads at runtime.
Since: 9
Parameters
| Name | Description |
|---|---|
| OH_AI_ContextHandle context | Pointer to the OH_AI_ContextHandle of the context information instance. |
| int32_t thread_num | Number of threads at runtime. The length is subject to the system limitation. |
OH_AI_API int32_t OH_AI_ContextGetThreadNum(const OH_AI_ContextHandle context)
Description
Gets the number of threads.
Since: 9
Parameters
| Name | Description |
|---|---|
| const OH_AI_ContextHandle context | Pointer to the OH_AI_ContextHandle of the context information instance. |
Return
| Type | Description |
|---|---|
| OH_AI_API int32_t | Current number of threads. |
OH_AI_API void OH_AI_ContextSetThreadAffinityMode(OH_AI_ContextHandle context, int mode)
Description
Sets the policy for binding runtime threads to CPU cores. CPU physical cores are classified into big, medium, and small cores by frequency. Only big cores or medium cores need to be bound, and small cores do not need to be bound.
Since: 9
Parameters
| Name | Description |
|---|---|
| OH_AI_ContextHandle context | Pointer to the OH_AI_ContextHandle of the context information instance. |
| int mode | Core binding policy. There are three policies: 0 means no core binding, 1 means big cores first, and 2 means medium cores first. |
OH_AI_API int OH_AI_ContextGetThreadAffinityMode(const OH_AI_ContextHandle context)
Description
Obtains the policy for binding runtime threads to CPU cores.
Since: 9
Parameters
| Name | Description |
|---|---|
| const OH_AI_ContextHandle context | Pointer to the OH_AI_ContextHandle of the context information instance. |
Return
| Type | Description |
|---|---|
| OH_AI_API int | Core binding policy. There are three policies: 0 indicates no core binding, 1 indicates big cores first, and 2 indicates medium cores first. |
OH_AI_API void OH_AI_ContextSetThreadAffinityCoreList(OH_AI_ContextHandle context, const int32_t *core_list,size_t core_num)
Description
Sets the list of CPU cores to which runtime threads are bound.
For example, when core_list=[2,6,8], the threads run on CPU cores 2, 6, and 8.
If both OH_AI_ContextSetThreadAffinityMode and OH_AI_ContextSetThreadAffinityCoreList are called for the same context object, only the core_list parameter of OH_AI_ContextSetThreadAffinityCoreList takes effect, while the mode parameter of OH_AI_ContextSetThreadAffinityMode does not.
Since: 9
Parameters
| Name | Description |
|---|---|
| OH_AI_ContextHandle context | Pointer to the OH_AI_ContextHandle context information instance. |
| const int32_t *core_list | List of CPU cores to which threads are bound. |
| size_t core_num | Number of cores, which represents the length of core_list. |
OH_AI_API const int32_t *OH_AI_ContextGetThreadAffinityCoreList(const OH_AI_ContextHandle context, size_t *core_num)
Description
Gets the CPU core binding list.
Since: 9
Parameters
| Name | Description |
|---|---|
| const OH_AI_ContextHandle context | Pointer to the OH_AI_ContextHandle of the context information instance. |
| size_t *core_num | Output parameter, which indicates the number of cores. |
Return
| Type | Description |
|---|---|
| OH_AI_API const int32_t * | CPU core binding list. This list object is managed by OH_AI_ContextHandle, and the caller does not need to release it manually. |
OH_AI_API void OH_AI_ContextSetEnableParallel(OH_AI_ContextHandle context, bool is_parallel)
Description
Sets whether to enable parallel execution at runtime. This feature is not enabled yet, so the setting does not take effect.
Since: 9
Parameters
| Name | Description |
|---|---|
| OH_AI_ContextHandle context | Pointer to the context information instance OH_AI_ContextHandle. |
| bool is_parallel | Whether to enable parallel execution. The value true means parallel execution is supported, and false means the opposite. |
OH_AI_API bool OH_AI_ContextGetEnableParallel(const OH_AI_ContextHandle context)
Description
Obtains whether parallel execution between operators is supported.
Since: 9
Parameters
| Name | Description |
|---|---|
| const OH_AI_ContextHandle context | Pointer to the OH_AI_ContextHandle of the context information instance. |
Return
| Type | Description |
|---|---|
| OH_AI_API bool | Whether parallel execution is supported. The value true indicates that parallel execution is supported, and false indicates the opposite. |
OH_AI_API void OH_AI_ContextAddDeviceInfo(OH_AI_ContextHandle context, OH_AI_DeviceInfoHandle device_info)
Description
Attaches a user-defined running device information to the inference context.
Since: 9
Parameters
| Name | Description |
|---|---|
| OH_AI_ContextHandle context | Pointer to the OH_AI_ContextHandle of the context information instance. |
| OH_AI_DeviceInfoHandle device_info | Pointer to the OH_AI_DeviceInfoHandle of the device information instance. |
OH_AI_API OH_AI_DeviceInfoHandle OH_AI_DeviceInfoCreate(OH_AI_DeviceType device_type)
Description
Creates a device information object.
Since: 9
Parameters
| Name | Description |
|---|---|
| OH_AI_DeviceType device_type | Device type. For details, see OH_AI_DeviceType. |
Return
| Type | Description |
|---|---|
| OH_AI_API OH_AI_DeviceInfoHandle | Pointer to the OH_AI_DeviceInfoHandle of the device information instance. |
OH_AI_API void OH_AI_DeviceInfoDestroy(OH_AI_DeviceInfoHandle *device_info)
Description
Releases a device information instance. Note: After a device information instance is added to the context, the caller does not need to release it manually.
Since: 9
Parameters
| Name | Description |
|---|---|
| OH_AI_DeviceInfoHandle *device_info | Pointer to the OH_AI_DeviceInfoHandle of the device information instance. |
OH_AI_API void OH_AI_DeviceInfoSetProvider(OH_AI_DeviceInfoHandle device_info, const char *provider)
Description
Sets the manufacturer name.
Since: 9
Parameters
| Name | Description |
|---|---|
| OH_AI_DeviceInfoHandle device_info | Pointer to the OH_AI_DeviceInfoHandle of the device information instance. |
| const char *provider | Manufacturer name. The string length is subject to system limitations. |
OH_AI_API const char *OH_AI_DeviceInfoGetProvider(const OH_AI_DeviceInfoHandle device_info)
Description
Gets the name of the manufacturer.
Since: 9
Parameters
| Name | Description |
|---|---|
| const OH_AI_DeviceInfoHandle device_info | Pointer to the OH_AI_DeviceInfoHandle of the device information instance. |
Return
| Type | Description |
|---|---|
| OH_AI_API const char * | Name of the manufacturer. |
OH_AI_API void OH_AI_DeviceInfoSetProviderDevice(OH_AI_DeviceInfoHandle device_info, const char *device)
Description
Sets the name of the manufacturer device.
Since: 9
Parameters
| Name | Description |
|---|---|
| OH_AI_DeviceInfoHandle device_info | Pointer to the OH_AI_DeviceInfoHandle of the device information instance. |
| const char *device | Name of the manufacturer device, for example, CPU. The string length is subject to the system limitation. |
OH_AI_API const char *OH_AI_DeviceInfoGetProviderDevice(const OH_AI_DeviceInfoHandle device_info)
Description
Gets the name of the manufacturer device.
Since: 9
Parameters
| Name | Description |
|---|---|
| const OH_AI_DeviceInfoHandle device_info | Pointer to the OH_AI_DeviceInfoHandle that points to the device information instance. |
Return
| Type | Description |
|---|---|
| OH_AI_API const char * | Name of the manufacturer device. |
OH_AI_API OH_AI_DeviceType OH_AI_DeviceInfoGetDeviceType(const OH_AI_DeviceInfoHandle device_info)
Description
Obtains the device type.
Since: 9
Parameters
| Name | Description |
|---|---|
| const OH_AI_DeviceInfoHandle device_info | Pointer to the OH_AI_DeviceInfoHandle of the device information instance. |
Return
| Type | Description |
|---|---|
| OH_AI_API OH_AI_DeviceType | Manufacturer device type. |
OH_AI_API void OH_AI_DeviceInfoSetEnableFP16(OH_AI_DeviceInfoHandle device_info, bool is_fp16)
Description
Sets whether to enable the float16 inference mode. This interface is available only for CPU and GPU devices.
Since: 9
Parameters
| Name | Description |
|---|---|
| OH_AI_DeviceInfoHandle device_info | Pointer to the OH_AI_DeviceInfoHandle instance of the device information. |
| bool is_fp16 | Whether to enable the float16 inference mode. The value true means to enable the float16 inference mode, and false means not to enable it. |
OH_AI_API bool OH_AI_DeviceInfoGetEnableFP16(const OH_AI_DeviceInfoHandle device_info)
Description
Gets whether to enable the float16 inference mode. This mode is available only on CPU/GPU devices.
Since: 9
Parameters
| Name | Description |
|---|---|
| const OH_AI_DeviceInfoHandle device_info | Pointer to the OH_AI_DeviceInfoHandle of the device information instance. |
Return
| Type | Description |
|---|---|
| OH_AI_API bool | Whether to enable the float16 inference mode. The value true means to enable the float16 inference mode, and false means not to enable it. |
OH_AI_API void OH_AI_DeviceInfoSetFrequency(OH_AI_DeviceInfoHandle device_info, int frequency)
Description
Sets the frequency of the NPU. This interface is available only for NPU devices.
Since: 9
Parameters
| Name | Description |
|---|---|
| OH_AI_DeviceInfoHandle device_info | Pointer to the OH_AI_DeviceInfoHandle of the device information instance. |
| int frequency | Frequency type. The value ranges from 0 to 4, and the default value is 3. 0 means not set, and the frequency is adjusted by the system; 1 means low power consumption; 2 means balanced; 3 means high performance; 4 means ultra-high performance. |
OH_AI_API int OH_AI_DeviceInfoGetFrequency(const OH_AI_DeviceInfoHandle device_info)
Description
Obtains the frequency type of the NPU. This interface is available only for NPU devices.
Since: 9
Parameters
| Name | Description |
|---|---|
| const OH_AI_DeviceInfoHandle device_info | Pointer to the OH_AI_DeviceInfoHandle of the device information instance. |
Return
| Type | Description |
|---|---|
| OH_AI_API int | Frequency type of the NPU. The value ranges from 0 to 4, where 0 indicates no setting and the frequency is adjusted by the system, 1 indicates low power consumption, 2 indicates balanced, 3 indicates high performance, and 4 indicates ultra-high performance. |
OH_AI_API NNRTDeviceDesc *OH_AI_GetAllNNRTDeviceDescs(size_t *num)
Description
Obtains the description information of all NNRt hardware devices in the system.
Since: 10
Parameters
| Name | Description |
|---|---|
| size_t *num | Output parameter, which is a pointer to the quantity of devices. |
Return
| Type | Description |
|---|---|
| OH_AI_API NNRTDeviceDesc * | Pointer to the array of NNRt device description information instances. NULL is returned if the acquisition fails. |
OH_AI_API NNRTDeviceDesc *OH_AI_GetElementOfNNRTDeviceDescs(NNRTDeviceDesc *descs, size_t index)
Description
Obtains the element pointer in the NNRt device description information array.
Since: 10
Parameters
| Name | Description |
|---|---|
| NNRTDeviceDesc *descs | Pointer to the NNRt device description information array. |
| size_t index | Index of the element in the array. |
Return
| Type | Description |
|---|---|
| OH_AI_API NNRTDeviceDesc * | Pointer to the NNRt device description information type. |
OH_AI_API void OH_AI_DestroyAllNNRTDeviceDescs(NNRTDeviceDesc **desc)
Description
Destroys the array of NNRt description information instances obtained from OH_AI_GetAllNNRTDeviceDescs.
Since: 10
Parameters
| Name | Description |
|---|---|
| NNRTDeviceDesc **desc | Double pointer to the array of NNRt device description information instances. After the destruction is complete, the content pointed to by desc is set to NULL. |
OH_AI_API size_t OH_AI_GetDeviceIdFromNNRTDeviceDesc(const NNRTDeviceDesc *desc)
Description
Gets the NNRt device ID from a specific NNRt device description information instance. Note that this ID is valid only for NNRt.
Since: 10
Parameters
| Name | Description |
|---|---|
| const NNRTDeviceDesc *desc | Pointer to the NNRt device description information instance. |
Return
| Type | Description |
|---|---|
| OH_AI_API size_t | NNRt device ID. |
OH_AI_API const char *OH_AI_GetNameFromNNRTDeviceDesc(const NNRTDeviceDesc *desc)
Description
Obtains the NNRt device name from a specific NNRt device description information instance.
Since: 10
Parameters
| Name | Description |
|---|---|
| const NNRTDeviceDesc *desc | Pointer to the NNRt device description information instance. |
Return
| Type | Description |
|---|---|
| OH_AI_API const char * | NNRt device name, a pointer to a constant string held by desc. The caller does not need to release this pointer separately. |
OH_AI_API OH_AI_NNRTDeviceType OH_AI_GetTypeFromNNRTDeviceDesc(const NNRTDeviceDesc *desc)
Description
Obtains the NNRt device type from a specific NNRt device description information instance.
Since: 10
Parameters
| Name | Description |
|---|---|
| const NNRTDeviceDesc *desc | Pointer to the NNRt device description information instance. |
Return
| Type | Description |
|---|---|
| OH_AI_API OH_AI_NNRTDeviceType | OH_AI_NNRTDeviceType NNRt device type. |
OH_AI_API OH_AI_DeviceInfoHandle OH_AI_CreateNNRTDeviceInfoByName(const char *name)
Description
Searches for the NNRt device with the specified name and creates NNRt device information based on the first device information found.
Since: 10
Parameters
| Name | Description |
|---|---|
| const char *name | Name of the target NNRt device. The string length is subject to the system limitation. |
Return
| Type | Description |
|---|---|
| OH_AI_API OH_AI_DeviceInfoHandle | Pointer to the OH_AI_DeviceInfoHandle of the device information instance. |
OH_AI_API OH_AI_DeviceInfoHandle OH_AI_CreateNNRTDeviceInfoByType(OH_AI_NNRTDeviceType type)
Description
Searches for an NNRt device of the specified type and creates NNRt device information based on the first device found.
Since: 10
Parameters
| Name | Description |
|---|---|
| OH_AI_NNRTDeviceType type | Target NNRt device type of OH_AI_NNRTDeviceType. |
Return
| Type | Description |
|---|---|
| OH_AI_API OH_AI_DeviceInfoHandle | OH_AI_DeviceInfoHandle pointing to the device information instance. |
OH_AI_API void OH_AI_DeviceInfoSetDeviceId(OH_AI_DeviceInfoHandle device_info, size_t device_id)
Description
Sets the NNRt device ID. This interface is available only for NNRt devices.
Since: 10
Parameters
| Name | Description |
|---|---|
| OH_AI_DeviceInfoHandle device_info | Pointer to the OH_AI_DeviceInfoHandle of the device information instance. |
| size_t device_id | NNRt device ID. |
OH_AI_API size_t OH_AI_DeviceInfoGetDeviceId(const OH_AI_DeviceInfoHandle device_info)
Description
Gets the NNRt device ID, available only for NNRt devices.
Since: 10
Parameters
| Name | Description |
|---|---|
| const OH_AI_DeviceInfoHandle device_info | Pointer to the OH_AI_DeviceInfoHandle of the device information instance. |
Return
| Type | Description |
|---|---|
| OH_AI_API size_t | NNRt device ID. |
OH_AI_API void OH_AI_DeviceInfoSetPerformanceMode(OH_AI_DeviceInfoHandle device_info, OH_AI_PerformanceMode mode)
Description
Sets the NNRt performance mode, which is available only for NNRt devices.
Since: 10
Parameters
| Name | Description |
|---|---|
| OH_AI_DeviceInfoHandle device_info | Pointer to the OH_AI_DeviceInfoHandle of the device information instance. |
| OH_AI_PerformanceMode mode | OH_AI_PerformanceMode NNRt performance mode. |
OH_AI_API OH_AI_PerformanceMode OH_AI_DeviceInfoGetPerformanceMode(const OH_AI_DeviceInfoHandle device_info)
Description
Obtains the NNRt performance mode. This interface is available only for NNRt devices.
Since: 10
Parameters
| Name | Description |
|---|---|
| const OH_AI_DeviceInfoHandle device_info | Pointer to the OH_AI_DeviceInfoHandle of the device information instance. |
Return
| Type | Description |
|---|---|
| OH_AI_API OH_AI_PerformanceMode | OH_AI_PerformanceMode NNRt performance mode. |
OH_AI_API void OH_AI_DeviceInfoSetPriority(OH_AI_DeviceInfoHandle device_info, OH_AI_Priority priority)
Description
Sets the NNRt task priority. This interface is available only for NNRt devices.
Since: 10
Parameters
| Name | Description |
|---|---|
| OH_AI_DeviceInfoHandle device_info | Pointer to the OH_AI_DeviceInfoHandle of the device information instance. |
| OH_AI_Priority priority | OH_AI_Priority NNRt task priority. |
OH_AI_API OH_AI_Priority OH_AI_DeviceInfoGetPriority(const OH_AI_DeviceInfoHandle device_info)
Description
Gets the NNRt task priority. This interface is available only for NNRt devices.
Since: 23
Parameters
| Name | Description |
|---|---|
| const OH_AI_DeviceInfoHandle device_info | Pointer to the OH_AI_DeviceInfoHandle of the device information instance. |
Return
| Type | Description |
|---|---|
| OH_AI_API OH_AI_Priority | OH_AI_Priority NNRt task priority. |
OH_AI_API OH_AI_Status OH_AI_DeviceInfoAddExtension(OH_AI_DeviceInfoHandle device_info, const char *name,const char *value, size_t value_size)
Description
Adds an extension configuration in the form of key/value pairs to the device information. This interface is valid only for NNRt device information.
Currently, only the following 11 keys are supported: {"CachePath": "YourCachePath"}, {"CacheVersion": "YourCacheVersion"},
{"QuantBuffer": "YourQuantBuffer"}, {"ModelName": "YourModelName"},
{"isProfiling": "YourProfilingSwitch"}, {"opLayout": "YourOpLayout"},
{"InputDims": "YourInputDims"}, {"DynamicDims": "YourDynamicDims"},
{"QuantConfigData": "YourQuantConfigData"}, {"BandMode": "YourBandMode"},
{"NPU_FM_SHARED": "YourNPU_FM_SHARED"}. You can configure the value of each key based on your usage.
Since: 10
Parameters
| Name | Description |
|---|---|
| OH_AI_DeviceInfoHandle device_info | Pointer to the OH_AI_DeviceInfoHandle of the device information instance. |
| const char *name | Key of a single extension item, in the C string format. The string length is limited to 128. |
| const char *value | Start address of the value content of a single extension item. The string length is subject to the system limitation. |
| size_t value_size | Length of the value content of a single extension item. |
Return
| Type | Description |
|---|---|
| OH_AI_API OH_AI_Status | OH_AI_Status result code. Returns OH_AI_STATUS_SUCCESS if the operation is successful; returns a specific error code otherwise. |