harmony 鸿蒙context.h

  • 2023-06-24
  • 浏览 (443)

context.h

Overview

Provides Context APIs for configuring runtime information.

Since

9

Related Modules

MindSpore

Summary

Types

Name Description
OH_AI_ContextHandle Defines the pointer to the MindSpore context.
OH_AI_DeviceInfoHandle Defines the pointer to the MindSpore device information.

Functions

Name Description
OH_AI_ContextCreate () Creates a context object.
OH_AI_ContextDestroy (OH_AI_ContextHandle *context) Destroys a context object.
OH_AI_ContextSetThreadNum (OH_AI_ContextHandle context, int32_t thread_num) Sets the number of runtime threads.
OH_AI_ContextGetThreadNum (const OH_AI_ContextHandle context) Obtains the number of threads.
OH_AI_ContextSetThreadAffinityMode (OH_AI_ContextHandle context, int mode) Sets the affinity mode for binding runtime threads to CPU cores, which are classified into large, medium, and small cores based on the CPU frequency. You only need to bind the large or medium cores, but not small cores.
OH_AI_ContextGetThreadAffinityMode (const OH_AI_ContextHandle context) Obtains the affinity mode for binding runtime threads to CPU cores.
OH_AI_ContextSetThreadAffinityCoreList (OH_AI_ContextHandle context, const int32_t *core_list, size_t core_num) Sets the list of CPU cores bound to a runtime thread.
OH_AI_ContextGetThreadAffinityCoreList (const OH_AI_ContextHandle context, size_t *core_num) Obtains the list of bound CPU cores.
OH_AI_ContextSetEnableParallel (OH_AI_ContextHandle context, bool is_parallel) Sets whether to enable parallelism between operators. The setting is ineffective because the feature of this API is not yet available.
OH_AI_ContextGetEnableParallel (const OH_AI_ContextHandle context) Checks whether parallelism between operators is supported.
OH_AI_ContextAddDeviceInfo (OH_AI_ContextHandle context, OH_AI_DeviceInfoHandle device_info) Attaches the custom device information to the inference context.
OH_AI_DeviceInfoCreate (OH_AI_DeviceType device_type) Creates a device information object.
OH_AI_DeviceInfoDestroy (OH_AI_DeviceInfoHandle *device_info) Destroys a device information object. Note: After the device information instance is added to the context, the caller does not need to destroy it manually.
OH_AI_DeviceInfoSetProvider (OH_AI_DeviceInfoHandle device_info, const char *provider) Sets the provider name.
OH_AI_DeviceInfoGetProvider (const OH_AI_DeviceInfoHandle device_info) Obtains the provider name.
OH_AI_DeviceInfoSetProviderDevice (OH_AI_DeviceInfoHandle device_info, const char *device) Sets the name of a provider device.
OH_AI_DeviceInfoGetProviderDevice (const OH_AI_DeviceInfoHandle device_info) Obtains the name of a provider device.
OH_AI_DeviceInfoGetDeviceType (const OH_AI_DeviceInfoHandle device_info) Obtains the device type.
OH_AI_DeviceInfoSetEnableFP16 (OH_AI_DeviceInfoHandle device_info, bool is_fp16) Sets whether to enable float16 inference. This function is available only for CPU and GPU devices.
OH_AI_DeviceInfoGetEnableFP16 (const OH_AI_DeviceInfoHandle device_info) Checks whether float16 inference is enabled. This function is available only for CPU and GPU devices.
OH_AI_DeviceInfoSetFrequency (OH_AI_DeviceInfoHandle device_info, int frequency) Sets the NPU frequency type. This function is available only for NPU devices.
OH_AI_DeviceInfoGetFrequency (const OH_AI_DeviceInfoHandle device_info) Obtains the NPU frequency type. This function is available only for NPU devices.
OH_AI_GetAllNNRTDeviceDescs (size_t *num) Obtains the descriptions of all NNRt devices in the system.
OH_AI_GetElementOfNNRTDeviceDescs (NNRTDeviceDesc *descs, size_t index) Obtains the pointer to an element in the NNRt device description array.
OH_AI_DestroyAllNNRTDeviceDescs (NNRTDeviceDesc **desc) Destroys the NNRt device description array obtained by OH_AI_GetAllNNRTDeviceDescs.
OH_AI_GetDeviceIdFromNNRTDeviceDesc (const NNRTDeviceDesc *desc) Obtains the NNRt device ID from the specified NNRt device description. Note that this ID is valid only for NNRt devices.
OH_AI_GetNameFromNNRTDeviceDesc (const NNRTDeviceDesc *desc) Obtains the NNRt device name from the specified NNRt device description.
OH_AI_GetTypeFromNNRTDeviceDesc (const NNRTDeviceDesc *desc) Obtains the NNRt device type from the specified NNRt device description.
OH_AI_CreateNNRTDeviceInfoByName (const char *name) Searches for the NNRt device with the specified name and creates the NNRt device information based on the information about the first found NNRt device.
OH_AI_CreateNNRTDeviceInfoByType (OH_AI_NNRTDeviceType type) Searches for the NNRt device with the specified type and creates the NNRt device information based on the information about the first found NNRt device.
OH_AI_DeviceInfoSetDeviceId (OH_AI_DeviceInfoHandle device_info, size_t device_id) Sets the ID of an NNRt device. This function is available only for NNRt devices.
OH_AI_DeviceInfoGetDeviceId (const OH_AI_DeviceInfoHandle device_info) Obtains the ID of an NNRt device. This function is available only for NNRt devices.
OH_AI_DeviceInfoSetPerformanceMode (OH_AI_DeviceInfoHandle device_info, OH_AI_PerformanceMode mode) Sets the performance mode of an NNRt device. This function is available only for NNRt devices.
OH_AI_DeviceInfoGetPerformanceMode (const OH_AI_DeviceInfoHandle device_info) Obtains the performance mode of an NNRt device. This function is available only for NNRt devices.
OH_AI_DeviceInfoSetPriority (OH_AI_DeviceInfoHandle device_info, OH_AI_Priority priority) Sets the priority of an NNRt task. This function is available only for NNRt devices.
OH_AI_DeviceInfoGetPriority (const OH_AI_DeviceInfoHandle device_info) Obtains the priority of an NNRt task. This function is available only for NNRt devices.
OH_AI_DeviceInfoAddExtension (OH_AI_DeviceInfoHandle device_info, const char *name, const char *value, size_t value_size) Adds extended configuration in the form of key/value pairs to the device information. This function is available only for NNRt device information.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Native APIs

harmony 鸿蒙AVCapability

harmony 鸿蒙AVDemuxer

harmony 鸿蒙AVMuxer

harmony 鸿蒙AVScreenCapture

harmony 鸿蒙AVSource

harmony 鸿蒙AudioDecoder

harmony 鸿蒙AudioEncoder

harmony 鸿蒙CodecBase

harmony 鸿蒙Core

0  赞