提交 fc08582e 编写于 作者: X xinking129

Merge remote-tracking branch 'upstream/master'

...@@ -38,7 +38,7 @@ Log level. ...@@ -38,7 +38,7 @@ Log level.
| Name | Value | Description | | Name | Value | Description |
| ----- | ------ | ------------------------------------------------------------ | | ----- | ------ | ------------------------------------------------------------ |
| DEBUG | 3 | Log level used to record more detailed process information than INFO logs to help developers analyze service processes and locate faults.| | DEBUG | 3 | Log level used to record more detailed process information than INFO logs to help developers analyze service processes and locate faults.|
| INFO | 4 | Log level used to record key service process nodes and exceptions that occur during service running,<br>Log level used to record information about unexpected exceptions, such as network signal loss and login failure.<br>These logs should be recorded by the dominant module in the service to avoid repeated logging conducted by multiple invoked modules or low-level functions.| | INFO | 4 | Log level used to record key service process nodes and exceptions that occur during service running as well as information about unexpected exceptions, such as network signal loss and login failure.<br>These logs should be recorded by the dominant module in the service to avoid repeated logging conducted by multiple invoked modules or low-level functions.|
| WARN | 5 | Log level used to record severe, unexpected faults that have little impact on users and can be rectified by the programs themselves or through simple operations.| | WARN | 5 | Log level used to record severe, unexpected faults that have little impact on users and can be rectified by the programs themselves or through simple operations.|
| ERROR | 6 | Log level used to record program or functional errors that affect the normal running or use of the functionality and can be fixed at a high cost, for example, by resetting data.| | ERROR | 6 | Log level used to record program or functional errors that affect the normal running or use of the functionality and can be fixed at a high cost, for example, by resetting data.|
| FATAL | 7 | Log level used to record program or functionality crashes that cannot be rectified. | FATAL | 7 | Log level used to record program or functionality crashes that cannot be rectified.
......
...@@ -5,5 +5,6 @@ ...@@ -5,5 +5,6 @@
- [Raw File Development](rawfile-guidelines.md) - [Raw File Development](rawfile-guidelines.md)
- [Native Window Development](native-window-guidelines.md) - [Native Window Development](native-window-guidelines.md)
- [Using MindSpore Lite for Model Inference](mindspore-lite-guidelines.md) - [Using MindSpore Lite for Model Inference](mindspore-lite-guidelines.md)
- [Using MindSpore Lite for Offline Model Conversion and Inference](mindspore-lite-offline-model-guidelines.md)
- [Connecting the Neural Network Runtime to an AI Inference Framework](neural-network-runtime-guidelines.md) - [Connecting the Neural Network Runtime to an AI Inference Framework](neural-network-runtime-guidelines.md)
- [Purgeable Memory Development](purgeable-memory-guidelines.md) - [Purgeable Memory Development](purgeable-memory-guidelines.md)
# Using MindSpore Lite for Offline Model Conversion and Inference
## Basic Concepts
- MindSpore Lite: a built-in AI inference engine of OpenHarmony that provides inference deployment for deep learning models.
- Neural Network Runtime (NNRt): a bridge that connects the upper-layer AI inference framework to the bottom-layer acceleration chip to implement cross-chip inference and computing of AI models.
- Offline model: a model obtained using the offline model conversion tool of the AI hardware vendor. The hardware vendor is responsible for parsing and inference of AI models.
## When to Use
The common process for MindSpore Lite AI model deployment is as follows:
- Use the MindSpore Lite model conversion tool to convert third-party models (such as ONNX and CAFFE) to `.ms` models.
- Call APIs of the MindSpore Lite inference engine to perform model inference. By specifying NNRt as the inference device, you can then use the AI hardware in the system to accelerate inference.
When MindSpore Lite + NNRt inference is used, dynamic image composition in the initial phase will introduce a certain model loading delay.
If you want to reduce the loading delay to meet the requirements of the deployment scenario, you can use offline model-based inference as an alternative. The operation procedure is as follows:
- Use the offline model conversion tool provided by the AI hardware vendor to compile an offline model in advance.
- Use the MindSpore Lite conversion tool to encapsulate the offline model as a black box into the `.ms` model.
- Pass the `.ms` model to MindSpore Lite for inference.
During inference, MindSpore Lite directly sends the offline model to the AI hardware connected to NNRt. This way, the model can be loaded without the need for online image composition, greatly reducing the model loading delay. In addition, MindSpore Lite can provide additional hardware-specific information to assist the AI hardware in model inference.
The following sections describe the offline model inference and conversion process in detail.
## Constraints
- Offline model inference can only be implemented at the NNRt backend. The AI hardware needs to connect to NNRt and supports offline model inference.
## Offline Model Conversion
### 1. Building the MindSpore Lite Release Package
Obtain the [MindSpore Lite source code](https://gitee.com/openharmony/third_party_mindspore). The source code is managed in "compressed package + patch" mode. Run the following commands to decompress the source code package and install the patch:
```bash
cd mindspore
python3 build_helper.py --in_zip_path=./mindspore-v1.8.1.zip --patch_dir=./patches/ --out_src_path=./mindspore-src
```
If the command execution is successful, the complete MindSpore Lite source code is generated in `mindspore-src/source/`.
Run the following commands to start building:
```bash
cd mindspore-src/source/
bash build.sh -I x86_64 -j 8
```
After the building is complete, you can obtain the MindSpore Lite release package from the `output/` directory in the root directory of the source code.
### 2. Writing Extended Configuration File of the Conversion Tool
The offline model comes as a black box and cannot be parsed by the conversion tool to obtain its input and output tensor information. Therefore, you need to manually configure the tensor information in the extended configuration file of the conversion tool. Based on the extended configuration, the conversion tool can then generate the `.ms` model file for encapsulating the offline model.
An example of the extended configuration is as follows:
- `[third_party_model]` in the first line is a fixed keyword that indicates the section of offline model configuration.
- The following lines exhibit the name, data type, shape, and memory format of the input and output tensors of the model respectively. Each field occupies a line and is expressed in the key-value pair format. The sequence of fields is not limited.
- Among the fields, data type and shape are mandatory, and other parameters are optional.
- Extended parameters are also provided. They are used to encapsulate custom configuration of the offline model into an `.ms` file in the the key-value pair format. The `.ms` file is passed to the AI hardware by NNRt during inference.
```text
[third_party_model]
input_names=in_0;in_1
input_dtypes=float32;float32
input_shapes=8,256,256;8,256,256,3
input_formats=NCHW;NCHW
output_names=out_0
output_dtypes=float32
output_shapes=8,64
output_formats=NCHW
extended_parameters=key_foo:value_foo;key_bar:value_bar
```
The related fields are described as follows:
- `input_names` (optional): model input name, which is in the string format. If multiple names are specified, use a semicolon (`;`) to separate them.
- `input_dtypes` (mandatory): model input data type, which is in the type format. If multiple data types are specified, use a semicolon (`;`) to separate them.
- `input_shapes` (mandatory): model input shape, which is in the integer array format. If multiple input shapes are specified, use a semicolon (`;`) to separate them.
- `input_formats` (optional): model input memory format, which is in the string format. If multiple formats are specified, use a semicolon (`;`) to separate them. The default value is `NHWC`.
- `output_names` (optional): model output name, which is in the string format. If multiple names are specified, use a semicolon (`;`) to separate them.
- `output_dtypes` (mandatory): model output data type, which is in the type format. If multiple data types are specified, use a semicolon (`;`) to separate them.
- `output_shapes` (mandatory): model output shape, which is in the integer array format. If multiple output shapes are specified, use a semicolon (`;`) to separate them.
- `output_formats` (optional): model output memory format, which is in the string format. If multiple formats are specified, use a semicolon (`;`) to separate them. The default value is `NHWC`.
- `extended_parameters` (optional): custom configuration of the inference hardware, which is in the key-value pair format. It is passed to the AI hardware through the NNRt backend during inference.
### 3. Converting an Offline Model
Decompress the MindSpore Lite release package obtained in step 1. Go to the directory where the conversion tool is located (that is, `tools/converter/converter/`), and run the following commands:
```bash
export LD_LIBRARY_PATH=${PWD}/../lib
./converter_lite --fmk=THIRDPARTY --modelFile=/path/to/your_model --configFile=/path/to/your_config --outputFile=/path/to/output_model
```
The offline model conversion is complete.
The related parameters are described as follows:
- `--fmk`: original format of the input model. `THIRDPARTY` indicates an offline model.
- `--modelFile`: path of the input model.
- `--configFile`: path of the extended configuration file. The file is used to configure offline model information.
- `--outputFile`: path of the output model. You do not need to add the file name extension. The `.ms` suffix is generated automatically.
> **NOTE**
>
> If `fmk` is set to `THIRDPARTY`, offline model conversion is performed. In this case, only the preceding four parameters and the extended configuration file take effect.
## Offline Model Inference
Offline model inference is the same as common MindSpore Lite model inference except that only NNRt devices can be added to the inference context.
For details about the MindSpore Lite model inference process, see [Using MindSpore Lite for Model Inference](./mindspore-lite-guidelines.md).
...@@ -1766,7 +1766,7 @@ promise.then(() => { ...@@ -1766,7 +1766,7 @@ promise.then(() => {
setExtraOptions(options: TCPExtraOptions, callback: AsyncCallback\<void\>): void setExtraOptions(options: TCPExtraOptions, callback: AsyncCallback\<void\>): void
Sets other properties of the TCPSocket connection after successful binding of the local IP address and port number of the TLSSocket connection. This API uses an asynchronous callback to return the result. Sets other properties of the TCPSocket connection after successful binding of the local IP address and port number of the connection. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Communication.NetStack **System capability**: SystemCapability.Communication.NetStack
...@@ -1818,7 +1818,7 @@ tls.setExtraOptions({ ...@@ -1818,7 +1818,7 @@ tls.setExtraOptions({
setExtraOptions(options: TCPExtraOptions): Promise\<void\> setExtraOptions(options: TCPExtraOptions): Promise\<void\>
Sets other properties of the TCPSocket connection after successful binding of the local IP address and port number of the TLSSocket connection. This API uses a promise to return the result. Sets other properties of the TCPSocket connection after successful binding of the local IP address and port number of the connection. This API uses a promise to return the result.
**System capability**: SystemCapability.Communication.NetStack **System capability**: SystemCapability.Communication.NetStack
......
...@@ -7,125 +7,146 @@ Provides APIs related to MindSpore Lite model inference. ...@@ -7,125 +7,146 @@ Provides APIs related to MindSpore Lite model inference.
\@Syscap SystemCapability.Ai.MindSpore \@Syscap SystemCapability.Ai.MindSpore
**Since:** **Since**
9 9
## Summary ## Summary
### Files ### File
| Name | Description | | Name | Description |
| -------- | -------- | | ------------------------------- | ------------------------------------------------------------ |
| [context.h](context_8h.md) | Provides **Context** APIs for configuring runtime information. <br>File to Include: <mindspore/context.h> | | [context.h](context_8h.md) | Provides **Context** APIs for configuring runtime information.<br>File to include: \<mindspore/context.h>|
| [data_type.h](data__type_8h.md) | Declares tensor data types. <br>File to Include: <mindspore/data_type.h> | | [data_type.h](data__type_8h.md) | Declares tensor data types.<br>File to include: \<mindspore/data_type.h>|
| [format.h](format_8h.md) | Declares tensor data formats. <br>File to Include: <mindspore/format.h> | | [format.h](format_8h.md) | Declares tensor data formats.<br>File to include: \<mindspore/format.h> |
| [model.h](model_8h.md) | Provides model-related APIs for model creation and inference. <br>File to Include: <mindspore/model.h> | | [model.h](model_8h.md) | Provides model-related APIs for model creation and inference.<br>File to include: \<mindspore/model.h>|
| [status.h](status_8h.md) | Provides the status codes of MindSpore Lite. <br>File to Include: <mindspore/status.h> | | [status.h](status_8h.md) | Provides the status codes of MindSpore Lite.<br>File to include: \<mindspore/status.h>|
| [tensor.h](tensor_8h.md) | Provides APIs for creating and modifying tensor information. <br>File to Include: <mindspore/tensor.h> | | [tensor.h](tensor_8h.md) | Provides APIs for creating and modifying tensor information.<br>File to include: \<mindspore/tensor.h>|
| [types.h](types_8h.md) | Provides the model file types and device types supported by MindSpore Lite. <br>File to Include: <mindspore/types.h> | | [types.h](types_8h.md) | Provides the model file types and device types supported by MindSpore Lite.<br>File to include: \<mindspore/types.h>|
### Structs ### Structs
| Name | Description | | Name | Description |
| -------- | -------- | | ------------------------------------------------------------ | ---------------------------------------------------- |
| [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) | Defines the tensor array structure, which is used to store the tensor array pointer and tensor array length. | | [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) | Defines the tensor array structure, which is used to store the tensor array pointer and tensor array length.|
| [OH_AI_ShapeInfo](_o_h___a_i___shape_info.md) | Defines dimension information. The maximum dimension is set by **MS_MAX_SHAPE_NUM**. | | [OH_AI_ShapeInfo](_o_h___a_i___shape_info.md) | Dimension information. The maximum dimension is set by **MS_MAX_SHAPE_NUM**. |
| [OH_AI_CallBackParam](_o_h___a_i___call_back_param.md) | Defines the operator information passed in a callback. | | [OH_AI_CallBackParam](_o_h___a_i___call_back_param.md) | Defines the operator information passed in a callback. |
### Macros ### Macro Definition
| Name | Description |
| -------- | -------- |
| [OH_AI_MAX_SHAPE_NUM](#oh_ai_max_shape_num) 32 | Defines dimension information. The maximum dimension is set by **MS_MAX_SHAPE_NUM**. |
| Name | Description |
| ------------------------------------------------ | -------------------------------------------- |
| [OH_AI_MAX_SHAPE_NUM](#oh_ai_max_shape_num) 32 | Defines dimension information. The maximum dimension is set by **MS_MAX_SHAPE_NUM**.|
### Types ### Types
| Name | Description | | Name | Description |
| -------- | -------- | | ------------------------------------------------------------ | -------------------------------------------------- |
| [OH_AI_ContextHandle](#oh_ai_contexthandle) | Defines the pointer to the MindSpore context. | | [OH_AI_ContextHandle](#oh_ai_contexthandle) | Defines the pointer to the MindSpore context. |
| [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) | Defines the pointer to the MindSpore device information. | | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) | Defines the pointer to the MindSpore device information. |
| [OH_AI_DataType](#oh_ai_datatype) | Declares data types supported by MSTensor. | | [OH_AI_DataType](#oh_ai_datatype) | Declares data types supported by MSTensor. |
| [OH_AI_Format](#oh_ai_format) | Declares data formats supported by MSTensor. | | [OH_AI_Format](#oh_ai_format) | Declares data formats supported by MSTensor. |
| [OH_AI_ModelHandle](#oh_ai_modelhandle) | Defines the pointer to a model object. | | [OH_AI_ModelHandle](#oh_ai_modelhandle) | Defines the pointer to a model object. |
| [OH_AI_TensorHandleArray](#oh_ai_tensorhandlearray) | Defines the tensor array structure, which is used to store the tensor array pointer and tensor array length. | | [OH_AI_TensorHandleArray](#oh_ai_tensorhandlearray) | Defines the tensor array structure, which is used to store the tensor array pointer and tensor array length.|
| **OH_AI_ShapeInfo** | Defines dimension information. The maximum dimension is set by **MS_MAX_SHAPE_NUM**. | | [OH_AI_ShapeInfo](_o_h___a_i___shape_info.md) | Defines dimension information. The maximum dimension is set by **MS_MAX_SHAPE_NUM**. |
| [OH_AI_CallBackParam](#oh_ai_callbackparam) | Defines the operator information passed in a callback. | | [OH_AI_CallBackParam](#oh_ai_callbackparam) | Defines the operator information passed in a callback. |
| [OH_AI_KernelCallBack](#oh_ai_kernelcallback)) (const [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) inputs, const [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) outputs, const [OH_AI_CallBackParam](_o_h___a_i___call_back_param.md) kernel_Info) | Defines the pointer to a callback. | | [OH_AI_KernelCallBack](#oh_ai_kernelcallback) | Defines the pointer to a callback. |
| [OH_AI_Status](#oh_ai_status) | Defines MindSpore status codes. | | [OH_AI_Status](#oh_ai_status) | Defines MindSpore status codes. |
| [OH_AI_TensorHandle](#oh_ai_tensorhandle) | Defines the handle of a tensor object. | | [OH_AI_TensorHandle](#oh_ai_tensorhandle) | Defines the handle of a tensor object. |
| [OH_AI_ModelType](#oh_ai_modeltype) | Defines model file types. | | [OH_AI_ModelType](#oh_ai_modeltype) | Defines model file types. |
| [OH_AI_DeviceType](#oh_ai_devicetype) | Defines the supported device types. | | [OH_AI_DeviceType](#oh_ai_devicetype) | Defines the supported device types. |
| [OH_AI_NNRTDeviceType](#oh_ai_nnrtdevicetype) | Defines NNRt device types. |
| [OH_AI_PerformanceMode](#oh_ai_performancemode) | Defines performance modes of the NNRt device. |
| [OH_AI_Priority](#oh_ai_priority) | Defines NNRt inference task priorities. |
| [NNRTDeviceDesc](#nnrtdevicedesc) | Defines the NNRt device information, including the device ID and device name. |
### Enums ### Enums
| Name | Description | | Name | Description |
| -------- | -------- | | ------------------------------------------------------------ | ---------------------------------------- |
| [OH_AI_DataType](#oh_ai_datatype) {<br/>OH_AI_DATATYPE_UNKNOWN = 0, OH_AI_DATATYPE_OBJECTTYPE_STRING = 12, OH_AI_DATATYPE_OBJECTTYPE_LIST = 13, OH_AI_DATATYPE_OBJECTTYPE_TUPLE = 14,<br/>OH_AI_DATATYPE_OBJECTTYPE_TENSOR = 17, OH_AI_DATATYPE_NUMBERTYPE_BEGIN = 29, OH_AI_DATATYPE_NUMBERTYPE_BOOL = 30, OH_AI_DATATYPE_NUMBERTYPE_INT8 = 32,<br/>OH_AI_DATATYPE_NUMBERTYPE_INT16 = 33, OH_AI_DATATYPE_NUMBERTYPE_INT32 = 34, OH_AI_DATATYPE_NUMBERTYPE_INT64 = 35, OH_AI_DATATYPE_NUMBERTYPE_UINT8 = 37,<br/>OH_AI_DATATYPE_NUMBERTYPE_UINT16 = 38, OH_AI_DATATYPE_NUMBERTYPE_UINT32 = 39, OH_AI_DATATYPE_NUMBERTYPE_UINT64 = 40, OH_AI_DATATYPE_NUMBERTYPE_FLOAT16 = 42,<br/>OH_AI_DATATYPE_NUMBERTYPE_FLOAT32 = 43, OH_AI_DATATYPE_NUMBERTYPE_FLOAT64 = 44, OH_AI_DATATYPE_NUMBERTYPE_END = 46, OH_AI_DataTypeInvalid = INT32_MAX<br/>} | Declares data types supported by MSTensor. | | [OH_AI_DataType](#oh_ai_datatype-1) {<br>OH_AI_DATATYPE_UNKNOWN = 0, <br>OH_AI_DATATYPE_OBJECTTYPE_STRING = 12, <br>OH_AI_DATATYPE_OBJECTTYPE_LIST = 13, <br>OH_AI_DATATYPE_OBJECTTYPE_TUPLE = 14,<br>OH_AI_DATATYPE_OBJECTTYPE_TENSOR = 17, <br>OH_AI_DATATYPE_NUMBERTYPE_BEGIN = 29,<br> OH_AI_DATATYPE_NUMBERTYPE_BOOL = 30,<br> OH_AI_DATATYPE_NUMBERTYPE_INT8 = 32,<br>OH_AI_DATATYPE_NUMBERTYPE_INT16 = 33, <br>OH_AI_DATATYPE_NUMBERTYPE_INT32 = 34, <br>OH_AI_DATATYPE_NUMBERTYPE_INT64 = 35, <br>OH_AI_DATATYPE_NUMBERTYPE_UINT8 = 37,<br>OH_AI_DATATYPE_NUMBERTYPE_UINT16 = 38, <br>OH_AI_DATATYPE_NUMBERTYPE_UINT32 = 39,<br> OH_AI_DATATYPE_NUMBERTYPE_UINT64 = 40, <br>OH_AI_DATATYPE_NUMBERTYPE_FLOAT16 = 42,<br>OH_AI_DATATYPE_NUMBERTYPE_FLOAT32 = 43, <br>OH_AI_DATATYPE_NUMBERTYPE_FLOAT64 = 44, <br>OH_AI_DATATYPE_NUMBERTYPE_END = 46,<br> OH_AI_DataTypeInvalid = INT32_MAX<br>} | Declares data types supported by MSTensor. |
| [OH_AI_Format](#oh_ai_format) {<br/>OH_AI_FORMAT_NCHW = 0, OH_AI_FORMAT_NHWC = 1, OH_AI_FORMAT_NHWC4 = 2, OH_AI_FORMAT_HWKC = 3,<br/>OH_AI_FORMAT_HWCK = 4, OH_AI_FORMAT_KCHW = 5, OH_AI_FORMAT_CKHW = 6, OH_AI_FORMAT_KHWC = 7,<br/>OH_AI_FORMAT_CHWK = 8, OH_AI_FORMAT_HW = 9, OH_AI_FORMAT_HW4 = 10, OH_AI_FORMAT_NC = 11,<br/>OH_AI_FORMAT_NC4 = 12, OH_AI_FORMAT_NC4HW4 = 13, OH_AI_FORMAT_NCDHW = 15, OH_AI_FORMAT_NWC = 16,<br/>OH_AI_FORMAT_NCW = 17<br/>} | Declares data formats supported by MSTensor. | | [OH_AI_Format](#oh_ai_format-1) {<br>OH_AI_FORMAT_NCHW = 0,<br> OH_AI_FORMAT_NHWC = 1, <br>OH_AI_FORMAT_NHWC4 = 2, <br>OH_AI_FORMAT_HWKC = 3,<br>OH_AI_FORMAT_HWCK = 4, <br>OH_AI_FORMAT_KCHW = 5, <br>OH_AI_FORMAT_CKHW = 6,<br> OH_AI_FORMAT_KHWC = 7,<br>OH_AI_FORMAT_CHWK = 8,<br> OH_AI_FORMAT_HW = 9, <br>OH_AI_FORMAT_HW4 = 10,<br> OH_AI_FORMAT_NC = 11,<br>OH_AI_FORMAT_NC4 = 12, <br>OH_AI_FORMAT_NC4HW4 = 13, <br>OH_AI_FORMAT_NCDHW = 15,<br> OH_AI_FORMAT_NWC = 16,<br>OH_AI_FORMAT_NCW = 17<br>} | Declares data formats supported by MSTensor. |
| [OH_AI_CompCode](#oh_ai_compcode) { OH_AI_COMPCODE_CORE = 0x00000000u, OH_AI_COMPCODE_LITE = 0xF0000000u } | Defines MinSpore component codes. | | [OH_AI_CompCode](#oh_ai_compcode) { <br>OH_AI_COMPCODE_CORE = 0x00000000u, <br>OH_AI_COMPCODE_LITE = 0xF0000000u<br> } | Defines MindSpore component codes. |
| [OH_AI_Status](#oh_ai_status) {<br/>OH_AI_STATUS_SUCCESS = 0, OH_AI_STATUS_CORE_FAILED = OH_AI_COMPCODE_CORE \| 0x1, OH_AI_STATUS_LITE_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -1), OH_AI_STATUS_LITE_NULLPTR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -2),<br/>OH_AI_STATUS_LITE_PARAM_INVALID = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -3), OH_AI_STATUS_LITE_NO_CHANGE = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -4), OH_AI_STATUS_LITE_SUCCESS_EXIT = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -5), OH_AI_STATUS_LITE_MEMORY_FAILED = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -6),<br/>OH_AI_STATUS_LITE_NOT_SUPPORT = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -7), OH_AI_STATUS_LITE_THREADPOOL_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -8), OH_AI_STATUS_LITE_UNINITIALIZED_OBJ = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -9), OH_AI_STATUS_LITE_OUT_OF_TENSOR_RANGE = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -100),<br/>OH_AI_STATUS_LITE_INPUT_TENSOR_ERROR, OH_AI_STATUS_LITE_REENTRANT_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -102), OH_AI_STATUS_LITE_GRAPH_FILE_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -200), OH_AI_STATUS_LITE_NOT_FIND_OP = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -300),<br/>OH_AI_STATUS_LITE_INVALID_OP_NAME = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -301), OH_AI_STATUS_LITE_INVALID_OP_ATTR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -302), OH_AI_STATUS_LITE_OP_EXECUTE_FAILURE, OH_AI_STATUS_LITE_FORMAT_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -400),<br/>OH_AI_STATUS_LITE_INFER_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -500), OH_AI_STATUS_LITE_INFER_INVALID, OH_AI_STATUS_LITE_INPUT_PARAM_INVALID<br/>} | Defines MindSpore status codes. | | [OH_AI_Status](#oh_ai_status-1) {<br>OH_AI_STATUS_SUCCESS = 0, OH_AI_STATUS_CORE_FAILED = OH_AI_COMPCODE_CORE \| 0x1, OH_AI_STATUS_LITE_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -1), OH_AI_STATUS_LITE_NULLPTR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -2),<br>OH_AI_STATUS_LITE_PARAM_INVALID = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -3), OH_AI_STATUS_LITE_NO_CHANGE = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -4), OH_AI_STATUS_LITE_SUCCESS_EXIT = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -5), OH_AI_STATUS_LITE_MEMORY_FAILED = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -6),<br>OH_AI_STATUS_LITE_NOT_SUPPORT = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -7), OH_AI_STATUS_LITE_THREADPOOL_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -8), OH_AI_STATUS_LITE_UNINITIALIZED_OBJ = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -9), OH_AI_STATUS_LITE_OUT_OF_TENSOR_RANGE = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -100),<br>OH_AI_STATUS_LITE_INPUT_TENSOR_ERROR, OH_AI_STATUS_LITE_REENTRANT_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -102), OH_AI_STATUS_LITE_GRAPH_FILE_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -200), OH_AI_STATUS_LITE_NOT_FIND_OP = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -300),<br>OH_AI_STATUS_LITE_INVALID_OP_NAME = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -301), OH_AI_STATUS_LITE_INVALID_OP_ATTR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -302), OH_AI_STATUS_LITE_OP_EXECUTE_FAILURE, OH_AI_STATUS_LITE_FORMAT_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -400),<br>OH_AI_STATUS_LITE_INFER_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF &amp; -500), OH_AI_STATUS_LITE_INFER_INVALID, OH_AI_STATUS_LITE_INPUT_PARAM_INVALID<br>} | Defines MindSpore status codes. |
| [OH_AI_ModelType](#oh_ai_modeltype) { OH_AI_MODELTYPE_MINDIR = 0, OH_AI_MODELTYPE_INVALID = 0xFFFFFFFF } | Defines model file types. | | [OH_AI_ModelType](#oh_ai_modeltype-1) { <br>OH_AI_MODELTYPE_MINDIR = 0, <br>OH_AI_MODELTYPE_INVALID = 0xFFFFFFFF <br>} | Defines model file types. |
| [OH_AI_DeviceType](#oh_ai_devicetype) {<br/>OH_AI_DEVICETYPE_CPU = 0, OH_AI_DEVICETYPE_GPU, OH_AI_DEVICETYPE_KIRIN_NPU, OH_AI_DEVICETYPE_NNRT = 60,<br/>OH_AI_DEVICETYPE_INVALID = 100<br/>} | Defines the supported device types. | | [OH_AI_DeviceType](#oh_ai_devicetype-1) {<br>OH_AI_DEVICETYPE_CPU = 0, <br>OH_AI_DEVICETYPE_GPU, <br>OH_AI_DEVICETYPE_KIRIN_NPU, <br>OH_AI_DEVICETYPE_NNRT = 60,<br>OH_AI_DEVICETYPE_INVALID = 100<br>} | Defines the supported device types.|
| [OH_AI_NNRTDeviceType](#oh_ai_nnrtdevicetype-1) { <br>OH_AI_NNRTDEVICE_OTHERS = 0, <br>OH_AI_NNRTDEVICE_CPU = 1, <br>OH_AI_NNRTDEVICE_GPU = 2, <br>OH_AI_NNRTDEVICE_ACCELERATOR = 3<br> } | Defines NNRt device types. |
| [OH_AI_PerformanceMode](#oh_ai_performancemode-1) {<br>OH_AI_PERFORMANCE_NONE = 0, <br>OH_AI_PERFORMANCE_LOW = 1, <br>OH_AI_PERFORMANCE_MEDIUM = 2,<br> OH_AI_PERFORMANCE_HIGH = 3,<br>OH_AI_PERFORMANCE_EXTREME = 4<br>} | Defines performance modes of the NNRt device. |
| [OH_AI_Priority](#oh_ai_priority-1) { <br>OH_AI_PRIORITY_NONE = 0, <br>OH_AI_PRIORITY_LOW = 1, <br>OH_AI_PRIORITY_MEDIUM = 2, <br>OH_AI_PRIORITY_HIGH = 3 <br>} | Defines NNRt inference task priorities. |
### Functions ### Functions
| Name | Description | | Name | Description |
| -------- | -------- | | ------------------------------------------------------------ | ------------------------------------------------------------ |
| [OH_AI_ContextCreate](#oh_ai_contextcreate) () | Creates a context object. | | [OH_AI_ContextCreate](#oh_ai_contextcreate) () | Creates a context object. |
| [OH_AI_ContextDestroy](#oh_ai_contextdestroy) ([OH_AI_ContextHandle](#oh_ai_contexthandle) \*context) | Destroys a context object. | | [OH_AI_ContextDestroy](#oh_ai_contextdestroy) ([OH_AI_ContextHandle](#oh_ai_contexthandle) \*context) | Destroys a context object. |
| [OH_AI_ContextSetThreadNum](#oh_ai_contextsetthreadnum) ([OH_AI_ContextHandle](#oh_ai_contexthandle) context, int32_t thread_num) | Sets the number of runtime threads. | | [OH_AI_ContextSetThreadNum](#oh_ai_contextsetthreadnum) ([OH_AI_ContextHandle](#oh_ai_contexthandle) context, int32_t thread_num) | Sets the number of runtime threads. |
| [OH_AI_ContextGetThreadNum](#oh_ai_contextgetthreadnum) (const [OH_AI_ContextHandle](#oh_ai_contexthandle) context) | Obtains the number of threads. | | [OH_AI_ContextGetThreadNum](#oh_ai_contextgetthreadnum) (const [OH_AI_ContextHandle](#oh_ai_contexthandle) context) | Obtains the number of threads. |
| [OH_AI_ContextSetThreadAffinityMode](#oh_ai_contextsetthreadaffinitymode) ([OH_AI_ContextHandle](#oh_ai_contexthandle) context, int mode) | Sets the affinity mode for binding runtime threads to CPU cores, which are categorized into little cores and big cores depending on the CPU frequency. | | [OH_AI_ContextSetThreadAffinityMode](#oh_ai_contextsetthreadaffinitymode) ([OH_AI_ContextHandle](#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](#oh_ai_contextgetthreadaffinitymode) (const [OH_AI_ContextHandle](#oh_ai_contexthandle) context) | Obtains the affinity mode for binding runtime threads to CPU cores. | | [OH_AI_ContextGetThreadAffinityMode](#oh_ai_contextgetthreadaffinitymode) (const [OH_AI_ContextHandle](#oh_ai_contexthandle) context) | Obtains the affinity mode for binding runtime threads to CPU cores. |
| [OH_AI_ContextSetThreadAffinityCoreList](#oh_ai_contextsetthreadaffinitycorelist) ([OH_AI_ContextHandle](#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_ContextSetThreadAffinityCoreList](#oh_ai_contextsetthreadaffinitycorelist) ([OH_AI_ContextHandle](#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](#oh_ai_contextgetthreadaffinitycorelist) (const [OH_AI_ContextHandle](#oh_ai_contexthandle) context, size_t \*core_num) | Obtains the list of bound CPU cores. | | [OH_AI_ContextGetThreadAffinityCoreList](#oh_ai_contextgetthreadaffinitycorelist) (const [OH_AI_ContextHandle](#oh_ai_contexthandle) context, size_t \*core_num) | Obtains the list of bound CPU cores. |
| [OH_AI_ContextSetEnableParallel](#oh_ai_contextsetenableparallel) ([OH_AI_ContextHandle](#oh_ai_contexthandle) context, bool is_parallel) | Sets whether to enable parallelism between operators. | | [OH_AI_ContextSetEnableParallel](#oh_ai_contextsetenableparallel) ([OH_AI_ContextHandle](#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](#oh_ai_contextgetenableparallel) (const [OH_AI_ContextHandle](#oh_ai_contexthandle) context) | Checks whether parallelism between operators is supported. | | [OH_AI_ContextGetEnableParallel](#oh_ai_contextgetenableparallel) (const [OH_AI_ContextHandle](#oh_ai_contexthandle) context) | Checks whether parallelism between operators is supported. |
| [OH_AI_ContextAddDeviceInfo](#oh_ai_contextadddeviceinfo) ([OH_AI_ContextHandle](#oh_ai_contexthandle) context, [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Adds information about a running device. | | [OH_AI_ContextAddDeviceInfo](#oh_ai_contextadddeviceinfo) ([OH_AI_ContextHandle](#oh_ai_contexthandle) context, [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Attaches the custom device information to the inference context. |
| [OH_AI_DeviceInfoCreate](#oh_ai_deviceinfocreate) ([OH_AI_DeviceType](#oh_ai_devicetype) device_type) | Creates a device information object. | | [OH_AI_DeviceInfoCreate](#oh_ai_deviceinfocreate) ([OH_AI_DeviceType](#oh_ai_devicetype) device_type) | Creates a device information object. |
| [OH_AI_DeviceInfoDestroy](#oh_ai_deviceinfodestroy) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) \*device_info) | Destroys a device information instance. | | [OH_AI_DeviceInfoDestroy](#oh_ai_deviceinfodestroy) ([OH_AI_DeviceInfoHandle](#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_deviceinfosetprovider) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, const char \*provider) | Sets the name of a provider. | | [OH_AI_DeviceInfoSetProvider](#oh_ai_deviceinfosetprovider) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, const char \*provider) | Sets the provider name. |
| [OH_AI_DeviceInfoGetProvider](#oh_ai_deviceinfogetprovider) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the provider name. | | [OH_AI_DeviceInfoGetProvider](#oh_ai_deviceinfogetprovider) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the provider name. |
| [OH_AI_DeviceInfoSetProviderDevice](#oh_ai_deviceinfosetproviderdevice) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, const char \*device) | Sets the name of a provider device. | | [OH_AI_DeviceInfoSetProviderDevice](#oh_ai_deviceinfosetproviderdevice) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, const char \*device) | Sets the name of a provider device. |
| [OH_AI_DeviceInfoGetProviderDevice](#oh_ai_deviceinfogetproviderdevice) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the name of a provider device. | | [OH_AI_DeviceInfoGetProviderDevice](#oh_ai_deviceinfogetproviderdevice) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the name of a provider device. |
| [OH_AI_DeviceInfoGetDeviceType](#oh_ai_deviceinfogetdevicetype) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the type of a provider device. | | [OH_AI_DeviceInfoGetDeviceType](#oh_ai_deviceinfogetdevicetype) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the device type. |
| [OH_AI_DeviceInfoSetEnableFP16](#oh_ai_deviceinfosetenablefp16) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, bool is_fp16) | Sets whether to enable float16 inference. This function is available only for CPU/GPU devices. | | [OH_AI_DeviceInfoSetEnableFP16](#oh_ai_deviceinfosetenablefp16) ([OH_AI_DeviceInfoHandle](#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](#oh_ai_deviceinfogetenablefp16) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Checks whether float16 inference is enabled. This function is available only for CPU/GPU devices. | | [OH_AI_DeviceInfoGetEnableFP16](#oh_ai_deviceinfogetenablefp16) (const [OH_AI_DeviceInfoHandle](#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_deviceinfosetfrequency) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, int frequency) | Sets the NPU frequency type. This function is available only for NPU devices. | | [OH_AI_DeviceInfoSetFrequency](#oh_ai_deviceinfosetfrequency) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, int frequency) | Sets the NPU frequency type. This function is available only for NPU devices. |
| [OH_AI_DeviceInfoGetFrequency](#oh_ai_deviceinfogetfrequency) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the NPU frequency type. This function is available only for NPU devices. | | [OH_AI_DeviceInfoGetFrequency](#oh_ai_deviceinfogetfrequency) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the NPU frequency type. This function is available only for NPU devices. |
| [OH_AI_ModelCreate](#oh_ai_modelcreate) () | Creates a model object. | | [OH_AI_GetAllNNRTDeviceDescs](#oh_ai_getallnnrtdevicedescs) (size_t \*num) | Obtains the descriptions of all NNRt devices in the system. |
| [OH_AI_ModelDestroy](#oh_ai_modeldestroy) ([OH_AI_ModelHandle](#oh_ai_modelhandle) \*model) | Destroys a model object. | | [OH_AI_DestroyAllNNRTDeviceDescs](#oh_ai_destroyallnnrtdevicedescs) ([NNRTDeviceDesc](#nnrtdevicedesc) \*\*desc) | Destroys the array of NNRT descriptions obtained by [OH_AI_GetAllNNRTDeviceDescs](#oh_ai_getallnnrtdevicedescs).|
| [OH_AI_ModelBuild](#oh_ai_modelbuild) ([OH_AI_ModelHandle](#oh_ai_modelhandle) model, const void \*model_data, size_t data_size, [OH_AI_ModelType](#oh_ai_modeltype) model_type, const [OH_AI_ContextHandle](#oh_ai_contexthandle) model_context) | Loads and builds a MindSpore model from the memory buffer. | | [OH_AI_GetDeviceIdFromNNRTDeviceDesc](#oh_ai_getdeviceidfromnnrtdevicedesc) (const [NNRTDeviceDesc](#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_ModelBuildFromFile](#oh_ai_modelbuildfromfile) ([OH_AI_ModelHandle](#oh_ai_modelhandle) model, const char \*model_path, [OH_AI_ModelType](#oh_ai_modeltype) model_type, const [OH_AI_ContextHandle](#oh_ai_contexthandle) model_context) | Loads and builds a MindSpore model from a model file. | | [OH_AI_GetNameFromNNRTDeviceDesc](#oh_ai_getnamefromnnrtdevicedesc) (const [NNRTDeviceDesc](#nnrtdevicedesc) \*desc) | Obtains the NNRt device name from the specified NNRt device description. |
| [OH_AI_ModelResize](#oh_ai_modelresize) ([OH_AI_ModelHandle](#oh_ai_modelhandle) model, const [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) inputs, [OH_AI_ShapeInfo](_o_h___a_i___shape_info.md) \*shape_infos, size_t shape_info_num) | Adjusts the input tensor shapes of a built model. | | [OH_AI_GetTypeFromNNRTDeviceDesc](#oh_ai_gettypefromnnrtdevicedesc) (const [NNRTDeviceDesc](#nnrtdevicedesc) \*desc) | Obtains the NNRt device type from the specified NNRt device description. |
| [OH_AI_ModelPredict](#oh_ai_modelpredict) ([OH_AI_ModelHandle](#oh_ai_modelhandle) model, const [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) inputs, [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) \*outputs, const [OH_AI_KernelCallBack](#oh_ai_kernelcallback) before, const [OH_AI_KernelCallBack](#oh_ai_kernelcallback) after) | Performs model inference. | | [OH_AI_CreateNNRTDeviceInfoByName](#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_ModelGetInputs](#oh_ai_modelgetinputs) (const [OH_AI_ModelHandle](#oh_ai_modelhandle) model) | Obtains the input tensor array structure of a model. | | [OH_AI_CreateNNRTDeviceInfoByType](#oh_ai_creatennrtdeviceinfobytype) ([OH_AI_NNRTDeviceType](#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_ModelGetOutputs](#oh_ai_modelgetoutputs) (const [OH_AI_ModelHandle](#oh_ai_modelhandle) model) | Obtains the output tensor array structure of a model. | | [OH_AI_DeviceInfoSetDeviceId](#oh_ai_deviceinfosetdeviceid) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, size_t device_id) | Sets the ID of an NNRt device. This API is available only for NNRt devices. |
| [OH_AI_ModelGetInputByTensorName](#oh_ai_modelgetinputbytensorname) (const [OH_AI_ModelHandle](#oh_ai_modelhandle) model, const char \*tensor_name) | Obtains the input tensor of a model by tensor name. | | [OH_AI_DeviceInfoGetDeviceId](#oh_ai_deviceinfogetdeviceid) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the ID of an NNRt device. This API is available only for NNRt devices. |
| [OH_AI_ModelGetOutputByTensorName](#oh_ai_modelgetoutputbytensorname) (const [OH_AI_ModelHandle](#oh_ai_modelhandle) model, const char \*tensor_name) | Obtains the output tensor of a model by tensor name. | | [OH_AI_DeviceInfoSetPerformanceMode](#oh_ai_deviceinfosetperformancemode) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, [OH_AI_PerformanceMode](#oh_ai_performancemode) mode) | Sets the performance mode of an NNRt device. This API is available only for NNRt devices. |
| [OH_AI_TensorCreate](#oh_ai_tensorcreate) (const char \*name, [OH_AI_DataType](#oh_ai_datatype) type, const int64_t \*shape, size_t shape_num, const void \*data, size_t data_len) | Creates a tensor object. | | [OH_AI_DeviceInfoGetPerformanceMode](#oh_ai_deviceinfogetperformancemode) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the performance mode of an NNRt device. This API is available only for NNRt devices. |
| [OH_AI_TensorDestroy](#oh_ai_tensordestroy) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) \*tensor) | Destroys a tensor object. | | [OH_AI_DeviceInfoSetPriority](#oh_ai_deviceinfosetpriority) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, [OH_AI_Priority](#oh_ai_priority) priority) | Sets the priority of an NNRT task. This API is available only for NNRt devices. |
| [OH_AI_TensorClone](#oh_ai_tensorclone) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Clones a tensor. | | [OH_AI_DeviceInfoGetPriority](#oh_ai_deviceinfogetpriority) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the priority of an NNRT task. This API is available only for NNRt devices. |
| [OH_AI_TensorSetName](#oh_ai_tensorsetname) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, const char \*name) | Sets the name of a tensor. | | [OH_AI_ModelCreate](#oh_ai_modelcreate) () | Creates a model object. |
| [OH_AI_TensorGetName](#oh_ai_tensorgetname) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the name of a tensor. | | [OH_AI_ModelDestroy](#oh_ai_modeldestroy) ([OH_AI_ModelHandle](#oh_ai_modelhandle) \*model) | Destroys a model object. |
| [OH_AI_TensorSetDataType](#oh_ai_tensorsetdatatype) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, [OH_AI_DataType](#oh_ai_datatype) type) | Sets the data type of a tensor. | | [OH_AI_ModelBuild](#oh_ai_modelbuild) ([OH_AI_ModelHandle](#oh_ai_modelhandle) model, const void \*model_data, size_t data_size, [OH_AI_ModelType](#oh_ai_modeltype) model_type, const [OH_AI_ContextHandle](#oh_ai_contexthandle) model_context) | Loads and builds a MindSpore model from the memory buffer. |
| [OH_AI_TensorGetDataType](#oh_ai_tensorgetdatatype) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the data type of a tensor. | | [OH_AI_ModelBuildFromFile](#oh_ai_modelbuildfromfile) ([OH_AI_ModelHandle](#oh_ai_modelhandle) model, const char \*model_path, [OH_AI_ModelType](#oh_ai_modeltype) model_type, const [OH_AI_ContextHandle](#oh_ai_contexthandle) model_context) | Loads and builds a MindSpore model from a model file. |
| [OH_AI_TensorSetShape](#oh_ai_tensorsetshape) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, const int64_t \*shape, size_t shape_num) | Sets the shape of a tensor. | | [OH_AI_ModelResize](#oh_ai_modelresize) ([OH_AI_ModelHandle](#oh_ai_modelhandle) model, const [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) inputs, [OH_AI_ShapeInfo](_o_h___a_i___shape_info.md) \*shape_infos, size_t shape_info_num) | Adjusts the input tensor shapes of a built model. |
| [OH_AI_TensorGetShape](#oh_ai_tensorgetshape) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, size_t \*shape_num) | Obtains the shape of a tensor. | | [OH_AI_ModelPredict](#oh_ai_modelpredict) ([OH_AI_ModelHandle](#oh_ai_modelhandle) model, const [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) inputs, [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) \*outputs, const [OH_AI_KernelCallBack](#oh_ai_kernelcallback) before, const [OH_AI_KernelCallBack](#oh_ai_kernelcallback) after) | Performs model inference. |
| [OH_AI_TensorSetFormat](#oh_ai_tensorsetformat) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, [OH_AI_Format](#oh_ai_format) format) | Sets the tensor data format. | | [OH_AI_ModelGetInputs](#oh_ai_modelgetinputs) (const [OH_AI_ModelHandle](#oh_ai_modelhandle) model) | Obtains the input tensor array structure of a model. |
| [OH_AI_TensorGetFormat](#oh_ai_tensorgetformat) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the tensor data format. | | [OH_AI_ModelGetOutputs](#oh_ai_modelgetoutputs) (const [OH_AI_ModelHandle](#oh_ai_modelhandle) model) | Obtains the output tensor array structure of a model. |
| [OH_AI_TensorSetData](#oh_ai_tensorsetdata) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, void \*data) | Sets the tensor data. | | [OH_AI_ModelGetInputByTensorName](#oh_ai_modelgetinputbytensorname) (const [OH_AI_ModelHandle](#oh_ai_modelhandle) model, const char \*tensor_name) | Obtains the input tensor of a model by tensor name. |
| [OH_AI_TensorGetData](#oh_ai_tensorgetdata) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the pointer to tensor data. | | [OH_AI_ModelGetOutputByTensorName](#oh_ai_modelgetoutputbytensorname) (const [OH_AI_ModelHandle](#oh_ai_modelhandle) model, const char \*tensor_name) | Obtains the output tensor of a model by tensor name. |
| [OH_AI_TensorGetMutableData](#oh_ai_tensorgetmutabledata) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the pointer to variable tensor data. If the data is empty, memory will be allocated. | | [OH_AI_TensorCreate](#oh_ai_tensorcreate) (const char \*name, [OH_AI_DataType](#oh_ai_datatype) type, const int64_t \*shape, size_t shape_num, const void \*data, size_t data_len) | Creates a tensor object. |
| [OH_AI_TensorGetElementNum](#oh_ai_tensorgetelementnum) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the number of tensor elements. | | [OH_AI_TensorDestroy](#oh_ai_tensordestroy) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) \*tensor) | Destroys a tensor object. |
| [OH_AI_TensorGetDataSize](#oh_ai_tensorgetdatasize) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the number of bytes of the tensor data. | | [OH_AI_TensorClone](#oh_ai_tensorclone) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Deeply copies a tensor. |
| [OH_AI_TensorSetName](#oh_ai_tensorsetname) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, const char \*name) | Sets the tensor name. |
| [OH_AI_TensorGetName](#oh_ai_tensorgetname) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the tensor name. |
| [OH_AI_TensorSetDataType](#oh_ai_tensorsetdatatype) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, [OH_AI_DataType](#oh_ai_datatype) type) | Sets the data type of a tensor. |
| [OH_AI_TensorGetDataType](#oh_ai_tensorgetdatatype) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the tensor type. |
| [OH_AI_TensorSetShape](#oh_ai_tensorsetshape) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, const int64_t \*shape, size_t shape_num) | Sets the tensor shape. |
| [OH_AI_TensorGetShape](#oh_ai_tensorgetshape) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, size_t \*shape_num) | Obtains the tensor shape. |
| [OH_AI_TensorSetFormat](#oh_ai_tensorsetformat) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, [OH_AI_Format](#oh_ai_format) format) | Sets the tensor data format. |
| [OH_AI_TensorGetFormat](#oh_ai_tensorgetformat) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the tensor data format. |
| [OH_AI_TensorSetData](#oh_ai_tensorsetdata) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, void \*data) | Sets the tensor data. |
| [OH_AI_TensorGetData](#oh_ai_tensorgetdata) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the pointer to tensor data. |
| [OH_AI_TensorGetMutableData](#oh_ai_tensorgetmutabledata) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the pointer to variable tensor data. If the data is empty, memory will be allocated. |
| [OH_AI_TensorGetElementNum](#oh_ai_tensorgetelementnum) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the number of tensor elements. |
| [OH_AI_TensorGetDataSize](#oh_ai_tensorgetdatasize) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the number of bytes of the tensor data. |
## Macro Description ## Macro Description
...@@ -133,84 +154,116 @@ Provides APIs related to MindSpore Lite model inference. ...@@ -133,84 +154,116 @@ Provides APIs related to MindSpore Lite model inference.
### OH_AI_MAX_SHAPE_NUM ### OH_AI_MAX_SHAPE_NUM
``` ```
#define OH_AI_MAX_SHAPE_NUM 32 #define OH_AI_MAX_SHAPE_NUM 32
``` ```
**Description**<br>
**Description**
Defines dimension information. The maximum dimension is set by **MS_MAX_SHAPE_NUM**. Defines dimension information. The maximum dimension is set by **MS_MAX_SHAPE_NUM**.
## Type Description ## Type Description
### NNRTDeviceDesc
```
typedef struct NNRTDeviceDesc NNRTDeviceDesc
```
**Description**
Defines the NNRt device information, including the device ID and device name.
**Since**
10
### OH_AI_CallBackParam ### OH_AI_CallBackParam
``` ```
typedef struct OH_AI_CallBackParamOH_AI_CallBackParam typedef struct OH_AI_CallBackParam OH_AI_CallBackParam
``` ```
**Description**<br>
**Description**
Defines the operator information passed in a callback. Defines the operator information passed in a callback.
### OH_AI_ContextHandle ### OH_AI_ContextHandle
``` ```
typedef void* OH_AI_ContextHandle typedef void* OH_AI_ContextHandle
``` ```
**Description**<br>
Defines the pointer to the MindSpore context. **Description**
Defines the pointer to the MindSpore context.
### OH_AI_DataType ### OH_AI_DataType
``` ```
typedef enum OH_AI_DataTypeOH_AI_DataType typedef enum OH_AI_DataType OH_AI_DataType
``` ```
**Description**<br>
**Description**
Declares data types supported by MSTensor. Declares data types supported by MSTensor.
### OH_AI_DeviceInfoHandle ### OH_AI_DeviceInfoHandle
``` ```
typedef void* OH_AI_DeviceInfoHandle typedef void* OH_AI_DeviceInfoHandle
``` ```
**Description**<br>
**Description**
Defines the pointer to the MindSpore device information. Defines the pointer to the MindSpore device information.
### OH_AI_DeviceType ### OH_AI_DeviceType
``` ```
typedef enum OH_AI_DeviceTypeOH_AI_DeviceType typedef enum OH_AI_DeviceType OH_AI_DeviceType
``` ```
**Description**<br>
**Description**
Defines the supported device types. Defines the supported device types.
### OH_AI_Format ### OH_AI_Format
``` ```
typedef enum OH_AI_FormatOH_AI_Format typedef enum OH_AI_Format OH_AI_Format
``` ```
**Description**<br>
**Description**
Declares data formats supported by MSTensor. Declares data formats supported by MSTensor.
### OH_AI_KernelCallBack ### OH_AI_KernelCallBack
``` ```
typedef bool(* OH_AI_KernelCallBack) (const OH_AI_TensorHandleArray inputs, const OH_AI_TensorHandleArray outputs, const OH_AI_CallBackParam kernel_Info) typedef bool(* OH_AI_KernelCallBack) (const OH_AI_TensorHandleArray inputs, const OH_AI_TensorHandleArray outputs, const OH_AI_CallBackParam kernel_Info)
``` ```
**Description**<br>
**Description**
Defines the pointer to a callback. Defines the pointer to a callback.
This pointer is used to set the two callback functions in [OH_AI_ModelPredict](#oh_ai_modelpredict). Each callback function must contain three parameters, where **inputs** and **outputs** indicate the input and output tensors of the operator, and **kernel_Info** indicates information about the current operator. You can use the callback functions to monitor the operator execution status, for example, operator execution time and the operator correctness. This pointer is used to set the two callback functions in [OH_AI_ModelPredict](#oh_ai_modelpredict). Each callback function must contain three parameters, where **inputs** and **outputs** indicate the input and output tensors of the operator, and **kernel_Info** indicates information about the current operator. You can use the callback functions to monitor the operator execution status, for example, operator execution time and the operator correctness.
...@@ -218,51 +271,109 @@ This pointer is used to set the two callback functions in [OH_AI_ModelPredict](# ...@@ -218,51 +271,109 @@ This pointer is used to set the two callback functions in [OH_AI_ModelPredict](#
### OH_AI_ModelHandle ### OH_AI_ModelHandle
``` ```
typedef void* OH_AI_ModelHandle typedef void* OH_AI_ModelHandle
``` ```
**Description**<br>
**Description**
Defines the pointer to a model object. Defines the pointer to a model object.
### OH_AI_ModelType ### OH_AI_ModelType
``` ```
typedef enum OH_AI_ModelTypeOH_AI_ModelType typedef enum OH_AI_ModelType OH_AI_ModelType
``` ```
**Description**<br>
**Description**
Defines model file types. Defines model file types.
### OH_AI_NNRTDeviceType
```
typedef enum OH_AI_NNRTDeviceType OH_AI_NNRTDeviceType
```
**Description**
Defines NNRt device types.
**Since**
10
### OH_AI_PerformanceMode
```
typedef enum OH_AI_PerformanceMode OH_AI_PerformanceMode
```
**Description**
Defines performance modes of the NNRt device.
**Since**
10
### OH_AI_Priority
```
typedef enum OH_AI_Priority OH_AI_Priority
```
**Description**
Defines NNRt inference task priorities.
**Since**
10
### OH_AI_Status ### OH_AI_Status
``` ```
typedef enum OH_AI_StatusOH_AI_Status typedef enum OH_AI_Status OH_AI_Status
``` ```
**Description**<br>
**Description**
Defines MindSpore status codes. Defines MindSpore status codes.
### OH_AI_TensorHandle ### OH_AI_TensorHandle
``` ```
typedef void* OH_AI_TensorHandle typedef void* OH_AI_TensorHandle
``` ```
**Description**<br>
**Description**
Defines the handle of a tensor object. Defines the handle of a tensor object.
### OH_AI_TensorHandleArray ### OH_AI_TensorHandleArray
``` ```
typedef struct OH_AI_TensorHandleArrayOH_AI_TensorHandleArray typedef struct OH_AI_TensorHandleArray OH_AI_TensorHandleArray
``` ```
**Description**<br>
**Description**
Defines the tensor array structure, which is used to store the tensor array pointer and tensor array length. Defines the tensor array structure, which is used to store the tensor array pointer and tensor array length.
...@@ -271,215 +382,304 @@ Defines the tensor array structure, which is used to store the tensor array poin ...@@ -271,215 +382,304 @@ Defines the tensor array structure, which is used to store the tensor array poin
### OH_AI_CompCode ### OH_AI_CompCode
``` ```
enum OH_AI_CompCode enum OH_AI_CompCode
``` ```
**Description**<br>
Defines MinSpore component codes.
| Name | Description | **Description**
| -------- | -------- |
| OH_AI_COMPCODE_CORE | MindSpore Core code | Defines MindSpore component codes.
| OH_AI_COMPCODE_LITE | MindSpore Lite code |
| Value | Description |
| ------------------- | --------------------- |
| OH_AI_COMPCODE_CORE | MindSpore Core code|
| OH_AI_COMPCODE_LITE | MindSpore Lite code|
### OH_AI_DataType ### OH_AI_DataType
``` ```
enum OH_AI_DataType enum OH_AI_DataType
``` ```
**Description**<br>
**Description**
Declares data types supported by MSTensor. Declares data types supported by MSTensor.
| Name | Description | | Value | Description |
| -------- | -------- | | --------------------------------- | ---------------------- |
| OH_AI_DATATYPE_UNKNOWN | Unknown data type | | OH_AI_DATATYPE_UNKNOWN | Unknown data type. |
| OH_AI_DATATYPE_OBJECTTYPE_STRING | String data type | | OH_AI_DATATYPE_OBJECTTYPE_STRING | String data. |
| OH_AI_DATATYPE_OBJECTTYPE_LIST | List data type | | OH_AI_DATATYPE_OBJECTTYPE_LIST | List data. |
| OH_AI_DATATYPE_OBJECTTYPE_TUPLE | Tuple data type | | OH_AI_DATATYPE_OBJECTTYPE_TUPLE | Tuple data. |
| OH_AI_DATATYPE_OBJECTTYPE_TENSOR | TensorList data type | | OH_AI_DATATYPE_OBJECTTYPE_TENSOR | TensorList data. |
| OH_AI_DATATYPE_NUMBERTYPE_BEGIN | Beginning of the number type | | OH_AI_DATATYPE_NUMBERTYPE_BEGIN | Beginning of the number type. |
| OH_AI_DATATYPE_NUMBERTYPE_BOOL | Bool data type | | OH_AI_DATATYPE_NUMBERTYPE_BOOL | Bool data. |
| OH_AI_DATATYPE_NUMBERTYPE_INT8 | Int8 data type | | OH_AI_DATATYPE_NUMBERTYPE_INT8 | Int8 data. |
| OH_AI_DATATYPE_NUMBERTYPE_INT16 | Int16 data type | | OH_AI_DATATYPE_NUMBERTYPE_INT16 | Int16 data. |
| OH_AI_DATATYPE_NUMBERTYPE_INT32 | Int32 data type | | OH_AI_DATATYPE_NUMBERTYPE_INT32 | Int32 data. |
| OH_AI_DATATYPE_NUMBERTYPE_INT64 | Int64 data type | | OH_AI_DATATYPE_NUMBERTYPE_INT64 | Int64 data. |
| OH_AI_DATATYPE_NUMBERTYPE_UINT8 | UInt8 data type | | OH_AI_DATATYPE_NUMBERTYPE_UINT8 | UInt8 data. |
| OH_AI_DATATYPE_NUMBERTYPE_UINT16 | UInt16 data type | | OH_AI_DATATYPE_NUMBERTYPE_UINT16 | UInt16 data . |
| OH_AI_DATATYPE_NUMBERTYPE_UINT32 | UInt32 data type | | OH_AI_DATATYPE_NUMBERTYPE_UINT32 | UInt32 data. |
| OH_AI_DATATYPE_NUMBERTYPE_UINT64 | UInt64 data type | | OH_AI_DATATYPE_NUMBERTYPE_UINT64 | UInt64 data. |
| OH_AI_DATATYPE_NUMBERTYPE_FLOAT16 | Float16 data type | | OH_AI_DATATYPE_NUMBERTYPE_FLOAT16 | Float16 data. |
| OH_AI_DATATYPE_NUMBERTYPE_FLOAT32 | Float32 data type | | OH_AI_DATATYPE_NUMBERTYPE_FLOAT32 | Float32 data. |
| OH_AI_DATATYPE_NUMBERTYPE_FLOAT64 | Float64 data type | | OH_AI_DATATYPE_NUMBERTYPE_FLOAT64 | Float64 data. |
| OH_AI_DATATYPE_NUMBERTYPE_END | End of the number type | | OH_AI_DATATYPE_NUMBERTYPE_END | End of the number type.|
| OH_AI_DataTypeInvalid | Invalid data type | | OH_AI_DataTypeInvalid | Invalid data type. |
### OH_AI_DeviceType ### OH_AI_DeviceType
``` ```
enum OH_AI_DeviceType enum OH_AI_DeviceType
``` ```
**Description**<br>
**Description**
Defines the supported device types. Defines the supported device types.
| Name | Description | | Value | Description |
| -------- | -------- | | -------------------------- | --------------------------------------- |
| OH_AI_DEVICETYPE_CPU | Device type: CPU<br/>since 9 | | OH_AI_DEVICETYPE_CPU | Device type: CPU |
| OH_AI_DEVICETYPE_GPU | Device type: GPU<br/>Reserved, not support yet.<br/>since 9 | | OH_AI_DEVICETYPE_GPU | Device type: GPU Reserved |
| OH_AI_DEVICETYPE_KIRIN_NPU | Device type: Kirin NPU<br/>Reserved, not support yet.<br/>since 9 | | OH_AI_DEVICETYPE_KIRIN_NPU | Device type: Kirin NPU Reserved|
| OH_AI_DEVICETYPE_NNRT | Device type: NNRt<br/>OHOS-only device range[60,80).<br/>since 9 | | OH_AI_DEVICETYPE_NNRT | Device type: NNRt OHOS device range: [60, 80)|
| OH_AI_DEVICETYPE_INVALID | Invalid device type<br/>since 9 | | OH_AI_DEVICETYPE_INVALID | Invalid device type |
### OH_AI_Format ### OH_AI_Format
``` ```
enum OH_AI_Format enum OH_AI_Format
``` ```
**Description**<br>
**Description**
Declares data formats supported by MSTensor. Declares data formats supported by MSTensor.
| Name | Description | | Value | Description |
| -------- | -------- | | ------------------- | ---------------- |
| OH_AI_FORMAT_NCHW | NCHW format | | OH_AI_FORMAT_NCHW | Tensor data is stored in the sequence of batch number N, channel C, height H, and width W. |
| OH_AI_FORMAT_NHWC | NHWC format | | OH_AI_FORMAT_NHWC | Tensor data is stored in the sequence of batch number N, height H, width W, and channel C. |
| OH_AI_FORMAT_NHWC4 | NHWC4 format | | OH_AI_FORMAT_NHWC4 | Tensor data is stored in the sequence of batch number N, height H, width W, and channel C. The C axis is 4-byte aligned. |
| OH_AI_FORMAT_HWKC | HWKC format | | OH_AI_FORMAT_HWKC | Tensor data is stored in the sequence of height H, width W, core count K, and channel C. |
| OH_AI_FORMAT_HWCK | HWCK format | | OH_AI_FORMAT_HWCK | Tensor data is stored in the sequence of height H, width W, channel C, and core count K. |
| OH_AI_FORMAT_KCHW | KCHW format | | OH_AI_FORMAT_KCHW | Tensor data is stored in the sequence of core count K, channel C, height H, and width W. |
| OH_AI_FORMAT_CKHW | CKHW format | | OH_AI_FORMAT_CKHW | Tensor data is stored in the sequence of channel C, core count K, height H, and width W. |
| OH_AI_FORMAT_KHWC | KHWC format | | OH_AI_FORMAT_KHWC | Tensor data is stored in the sequence of core count K, height H, width W, and channel C. |
| OH_AI_FORMAT_CHWK | CHWK format | | OH_AI_FORMAT_CHWK | Tensor data is stored in the sequence of channel C, height H, width W, and core count K. |
| OH_AI_FORMAT_HW | HW format | | OH_AI_FORMAT_HW | Tensor data is stored in the sequence of height H and width W. |
| OH_AI_FORMAT_HW4 | HW4 format | | OH_AI_FORMAT_HW4 | Tensor data is stored in the sequence of height H and width W. The W axis is 4-byte aligned. |
| OH_AI_FORMAT_NC | NC format | | OH_AI_FORMAT_NC | Tensor data is stored in the sequence of batch number N and channel C. |
| OH_AI_FORMAT_NC4 | NC4 format | | OH_AI_FORMAT_NC4 | Tensor data is stored in the sequence of batch number N and channel C. The C axis is 4-byte aligned. |
| OH_AI_FORMAT_NC4HW4 | NC4HW4 format | | OH_AI_FORMAT_NC4HW4 | Tensor data is stored in the sequence of batch number N, channel C, height H, and width W. The C axis and W axis are 4-byte aligned.|
| OH_AI_FORMAT_NCDHW | NCDHW format | | OH_AI_FORMAT_NCDHW | Tensor data is stored in the sequence of batch number N, channel C, depth D, height H, and width W. |
| OH_AI_FORMAT_NWC | NWC format | | OH_AI_FORMAT_NWC | Tensor data is stored in the sequence of batch number N, width W, and channel C. |
| OH_AI_FORMAT_NCW | NCW format | | OH_AI_FORMAT_NCW | Tensor data is stored in the sequence of batch number N, channel C, and width W. |
### OH_AI_ModelType ### OH_AI_ModelType
``` ```
enum OH_AI_ModelType enum OH_AI_ModelType
``` ```
**Description**<br>
**Description**
Defines model file types. Defines model file types.
| Name | Description | | Value | Description |
| -------- | -------- | | ----------------------- | ------------------ |
| OH_AI_MODELTYPE_MINDIR | Model type: MindIR<br/>since 9 | | OH_AI_MODELTYPE_MINDIR | Model type of MindIR. The extension of the model file name is **.ms**.|
| OH_AI_MODELTYPE_INVALID | Invalid model type<br/>since 9 | | OH_AI_MODELTYPE_INVALID | Invalid model type. |
### OH_AI_NNRTDeviceType
```
enum OH_AI_NNRTDeviceType
```
**Description**
Defines NNRt device types.
**Since**
10
| Value | Description |
| ---------------------------- | ----------------------------------- |
| OH_AI_NNRTDEVICE_OTHERS | Others (any device type except the following three types).|
| OH_AI_NNRTDEVICE_CPU | CPU. |
| OH_AI_NNRTDEVICE_GPU | GPU. |
| OH_AI_NNRTDEVICE_ACCELERATOR | Specific acceleration device. |
### OH_AI_PerformanceMode
```
enum OH_AI_PerformanceMode
```
**Description**
Defines performance modes of the NNRt device.
**Since**
10
| Value | Description |
| ------------------------- | ------------------- |
| OH_AI_PERFORMANCE_NONE | No special settings. |
| OH_AI_PERFORMANCE_LOW | Low power consumption. |
| OH_AI_PERFORMANCE_MEDIUM | Power consumption and performance balancing.|
| OH_AI_PERFORMANCE_HIGH | High performance. |
| OH_AI_PERFORMANCE_EXTREME | Ultimate performance. |
### OH_AI_Priority
```
enum OH_AI_Priority
```
**Description**
Defines NNRt inference task priorities.
**Since**
10
| Value | Description |
| --------------------- | -------------- |
| OH_AI_PRIORITY_NONE | No priority preference.|
| OH_AI_PRIORITY_LOW | Low priority.|
| OH_AI_PRIORITY_MEDIUM | Medium priority|
| OH_AI_PRIORITY_HIGH | High priority. |
### OH_AI_Status ### OH_AI_Status
``` ```
enum OH_AI_Status enum OH_AI_Status
``` ```
**Description**<br>
Defines MindSpore status codes.
| Name | Description | **Description**
| -------- | -------- |
| OH_AI_STATUS_SUCCESS | Success | Defines MindSpore status codes.
| OH_AI_STATUS_CORE_FAILED | MindSpore Core failure |
| OH_AI_STATUS_LITE_ERROR | MindSpore Lite error |
| OH_AI_STATUS_LITE_NULLPTR | MindSpore Lite null pointer |
| OH_AI_STATUS_LITE_PARAM_INVALID | MindSpore Lite invalid parameters |
| OH_AI_STATUS_LITE_NO_CHANGE | MindSpore Lite no change |
| OH_AI_STATUS_LITE_SUCCESS_EXIT | MindSpore Lite exit without errors |
| OH_AI_STATUS_LITE_MEMORY_FAILED | MindSpore Lite memory allocation failure |
| OH_AI_STATUS_LITE_NOT_SUPPORT | MindSpore Lite not supported |
| OH_AI_STATUS_LITE_THREADPOOL_ERROR | MindSpore Lite thread pool error |
| OH_AI_STATUS_LITE_UNINITIALIZED_OBJ | MindSpore Lite uninitialized |
| OH_AI_STATUS_LITE_OUT_OF_TENSOR_RANGE | MindSpore Lite tensor overflow |
| OH_AI_STATUS_LITE_INPUT_TENSOR_ERROR | MindSpore Lite input tensor error |
| OH_AI_STATUS_LITE_REENTRANT_ERROR | MindSpore Lite reentry error |
| OH_AI_STATUS_LITE_GRAPH_FILE_ERROR | MindSpore Lite file error |
| OH_AI_STATUS_LITE_NOT_FIND_OP | MindSpore Lite operator not found |
| OH_AI_STATUS_LITE_INVALID_OP_NAME | MindSpore Lite invalid operators |
| OH_AI_STATUS_LITE_INVALID_OP_ATTR | MindSpore Lite invalid operator hyperparameters |
| OH_AI_STATUS_LITE_OP_EXECUTE_FAILURE | MindSpore Lite operator execution failure |
| OH_AI_STATUS_LITE_FORMAT_ERROR | MindSpore Lite tensor format error |
| OH_AI_STATUS_LITE_INFER_ERROR | MindSpore Lite shape inference error |
| OH_AI_STATUS_LITE_INFER_INVALID | MindSpore Lite invalid shape inference |
| OH_AI_STATUS_LITE_INPUT_PARAM_INVALID | MindSpore Lite invalid input parameters |
| Value | Description |
| ------------------------------------- | ----------------------------------------- |
| OH_AI_STATUS_SUCCESS | Success. |
| OH_AI_STATUS_CORE_FAILED | MindSpore Core failure. |
| OH_AI_STATUS_LITE_ERROR | MindSpore Lite error. |
| OH_AI_STATUS_LITE_NULLPTR | MindSpore Lite null pointer. |
| OH_AI_STATUS_LITE_PARAM_INVALID | MindSpore Lite invalid parameters. |
| OH_AI_STATUS_LITE_NO_CHANGE | MindSpore Lite no change. |
| OH_AI_STATUS_LITE_SUCCESS_EXIT | MindSpore Lite exit without errors.|
| OH_AI_STATUS_LITE_MEMORY_FAILED | MindSpore Lite memory allocation failure. |
| OH_AI_STATUS_LITE_NOT_SUPPORT | MindSpore Lite not supported. |
| OH_AI_STATUS_LITE_THREADPOOL_ERROR | MindSpore Lite thread pool error. |
| OH_AI_STATUS_LITE_UNINITIALIZED_OBJ | MindSpore Lite uninitialized. |
| OH_AI_STATUS_LITE_OUT_OF_TENSOR_RANGE | MindSpore Lite tensor overflow. |
| OH_AI_STATUS_LITE_INPUT_TENSOR_ERROR | MindSpore Lite input tensor error. |
| OH_AI_STATUS_LITE_REENTRANT_ERROR | MindSpore Lite reentry error. |
| OH_AI_STATUS_LITE_GRAPH_FILE_ERROR | MindSpore Lite file error. |
| OH_AI_STATUS_LITE_NOT_FIND_OP | MindSpore Lite operator not found. |
| OH_AI_STATUS_LITE_INVALID_OP_NAME | MindSpore Lite invalid operators. |
| OH_AI_STATUS_LITE_INVALID_OP_ATTR | MindSpore Lite invalid operator hyperparameters. |
| OH_AI_STATUS_LITE_OP_EXECUTE_FAILURE | MindSpore Lite operator execution failure. |
| OH_AI_STATUS_LITE_FORMAT_ERROR | MindSpore Lite tensor format error. |
| OH_AI_STATUS_LITE_INFER_ERROR | MindSpore Lite shape inference error. |
| OH_AI_STATUS_LITE_INFER_INVALID | MindSpore Lite invalid shape inference. |
| OH_AI_STATUS_LITE_INPUT_PARAM_INVALID | MindSpore Lite invalid input parameters.|
## Function Description ## Function Description
### OH_AI_ContextAddDeviceInfo() ### OH_AI_ContextAddDeviceInfo()
``` ```
OH_AI_API void OH_AI_ContextAddDeviceInfo (OH_AI_ContextHandle context, OH_AI_DeviceInfoHandle device_info ) OH_AI_API void OH_AI_ContextAddDeviceInfo (OH_AI_ContextHandle context, OH_AI_DeviceInfoHandle device_info )
``` ```
**Description**<br>
Adds information about a running device.
**Parameters** **Description**
| Name | Description | Attaches the custom device information to the inference context.
| -------- | -------- |
| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. | **Parameters**
| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. |
| Name | Description |
| ----------- | ------------------------------------------------------------ |
| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance.|
| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.|
### OH_AI_ContextCreate() ### OH_AI_ContextCreate()
``` ```
OH_AI_API OH_AI_ContextHandle OH_AI_ContextCreate () OH_AI_API OH_AI_ContextHandle OH_AI_ContextCreate ()
``` ```
**Description**<br>
**Description**
Creates a context object. Creates a context object.
**Returns** **Returns**
[OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context. [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance.
### OH_AI_ContextDestroy() ### OH_AI_ContextDestroy()
``` ```
OH_AI_API void OH_AI_ContextDestroy (OH_AI_ContextHandle * context) OH_AI_API void OH_AI_ContextDestroy (OH_AI_ContextHandle * context)
``` ```
**Description**<br>
**Description**
Destroys a context object. Destroys a context object.
**Parameters** **Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | ------- | ------------------------------------------------------------ |
| context | Level-2 pointer to [OH_AI_ContextHandle](#oh_ai_contexthandle). After the context is destroyed, the pointer is set to null. | | context | Level-2 pointer to [OH_AI_ContextHandle](#oh_ai_contexthandle). After the context is destroyed, the pointer is set to null. |
### OH_AI_ContextGetEnableParallel() ### OH_AI_ContextGetEnableParallel()
``` ```
OH_AI_API bool OH_AI_ContextGetEnableParallel (const OH_AI_ContextHandle context) OH_AI_API bool OH_AI_ContextGetEnableParallel (const OH_AI_ContextHandle context)
``` ```
**Description**<br>
**Description**
Checks whether parallelism between operators is supported. Checks whether parallelism between operators is supported.
**Parameters** **Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | ------- | ------------------------------------------------------------ |
| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. | | context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance.|
**Returns** **Returns**
...@@ -488,59 +688,65 @@ Whether parallelism between operators is supported. The value **true** means tha ...@@ -488,59 +688,65 @@ Whether parallelism between operators is supported. The value **true** means tha
### OH_AI_ContextGetThreadAffinityCoreList() ### OH_AI_ContextGetThreadAffinityCoreList()
``` ```
OH_AI_API const int32_t* OH_AI_ContextGetThreadAffinityCoreList (const OH_AI_ContextHandle context, size_t * core_num ) OH_AI_API const int32_t* OH_AI_ContextGetThreadAffinityCoreList (const OH_AI_ContextHandle context, size_t * core_num )
``` ```
**Description**<br>
**Description**
Obtains the list of bound CPU cores. Obtains the list of bound CPU cores.
**Parameters** **Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | -------- | ------------------------------------------------------------ |
| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. | | context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance.|
| core_num | Number of CPU cores. | | core_num | Number of CPU cores. |
**Returns** **Returns**
List of bound CPU cores. Specifies the CPU core binding list. This list is managed by [OH_AI_ContextHandle](#oh_ai_contexthandle). The caller does not need to destroy it manually.
### OH_AI_ContextGetThreadAffinityMode() ### OH_AI_ContextGetThreadAffinityMode()
``` ```
OH_AI_API int OH_AI_ContextGetThreadAffinityMode (const OH_AI_ContextHandle context) OH_AI_API int OH_AI_ContextGetThreadAffinityMode (const OH_AI_ContextHandle context)
``` ```
**Description**<br>
**Description**
Obtains the affinity mode for binding runtime threads to CPU cores. Obtains the affinity mode for binding runtime threads to CPU cores.
**Parameters** **Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | ------- | ------------------------------------------------------------ |
| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. | | context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance.|
**Returns** **Returns**
Affinity mode. **0**: no affinities; **1**: big cores first; **2**: little cores first Affinity mode. **0**: no affinities; **1**: big cores first; **2**: medium cores first
### OH_AI_ContextGetThreadNum() ### OH_AI_ContextGetThreadNum()
``` ```
OH_AI_API int32_t OH_AI_ContextGetThreadNum (const OH_AI_ContextHandle context) OH_AI_API int32_t OH_AI_ContextGetThreadNum (const OH_AI_ContextHandle context)
``` ```
**Description**<br>
**Description**
Obtains the number of threads. Obtains the number of threads.
**Parameters** **Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | ------- | ------------------------------------------------------------ |
| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. | | context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance.|
**Returns** **Returns**
...@@ -549,125 +755,239 @@ Number of threads. ...@@ -549,125 +755,239 @@ Number of threads.
### OH_AI_ContextSetEnableParallel() ### OH_AI_ContextSetEnableParallel()
``` ```
OH_AI_API void OH_AI_ContextSetEnableParallel (OH_AI_ContextHandle context, bool is_parallel ) OH_AI_API void OH_AI_ContextSetEnableParallel (OH_AI_ContextHandle context, bool is_parallel )
``` ```
**Description**<br>
Sets whether to enable parallelism between operators.
**Parameters** **Description**
Sets whether to enable parallelism between operators. The setting is ineffective because the feature of this API is not yet available.
| Name | Description | **Parameters**
| -------- | -------- |
| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. | | Name | Description |
| is_parallel | Whether to enable parallelism between operators. The value **true** means to enable parallelism between operators, and the value **false** means the opposite. | | ----------- | ------------------------------------------------------------ |
| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance.|
| is_parallel | Whether parallelism between operators is supported. The value **true** means that parallelism between operators is supported, and the value **false** means the opposite. |
### OH_AI_ContextSetThreadAffinityCoreList() ### OH_AI_ContextSetThreadAffinityCoreList()
``` ```
OH_AI_API void OH_AI_ContextSetThreadAffinityCoreList (OH_AI_ContextHandle context, const int32_t * core_list, size_t core_num ) OH_AI_API void OH_AI_ContextSetThreadAffinityCoreList (OH_AI_ContextHandle context, const int32_t * core_list, size_t core_num )
``` ```
**Description**<br>
**Description**
Sets the list of CPU cores bound to a runtime thread. Sets the list of CPU cores bound to a runtime thread.
For example, if **core_list** is set to **[2,6,8]**, threads run on the 2nd, 6th, and 8th CPU cores. If [OH_AI_ContextSetThreadAffinityMode](#oh_ai_contextsetthreadaffinitymode) and [OH_AI_ContextSetThreadAffinityCoreList](#oh_ai_contextsetthreadaffinitycorelist) are called for the same context object, the **core_list** parameter of [OH_AI_ContextSetThreadAffinityCoreList](#oh_ai_contextsetthreadaffinitycorelist) takes effect, but the **mode** parameter of [OH_AI_ContextSetThreadAffinityMode](#oh_ai_contextsetthreadaffinitymode) does not. For example, if **core_list** is set to **[2,6,8]**, threads run on the 2nd, 6th, and 8th CPU cores. If [OH_AI_ContextSetThreadAffinityMode](#oh_ai_contextsetthreadaffinitymode) and [OH_AI_ContextSetThreadAffinityCoreList](#oh_ai_contextsetthreadaffinitycorelist) are called for the same context object, the **core_list** parameter of [OH_AI_ContextSetThreadAffinityCoreList](#oh_ai_contextsetthreadaffinitycorelist) takes effect, but the **mode** parameter of [OH_AI_ContextSetThreadAffinityMode](#oh_ai_contextsetthreadaffinitymode) does not.
**Parameters** **Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | --------- | ------------------------------------------------------------ |
| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. | | context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance.|
| core_list | List of bound CPU cores. | | core_list | List of bound CPU cores. |
| core_num | Number of cores, which indicates the length of **core_list**. | | core_num | Number of cores, which indicates the length of **core_list**. |
### OH_AI_ContextSetThreadAffinityMode() ### OH_AI_ContextSetThreadAffinityMode()
``` ```
OH_AI_API void OH_AI_ContextSetThreadAffinityMode (OH_AI_ContextHandle context, int mode ) OH_AI_API void OH_AI_ContextSetThreadAffinityMode (OH_AI_ContextHandle context, int mode )
``` ```
**Description**<br>
Sets the affinity mode for binding runtime threads to CPU cores, which are categorized into little cores and big cores depending on the CPU frequency.
**Parameters** **Description**
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.
**Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | ------- | ------------------------------------------------------------ |
| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. | | context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance.|
| mode | Affinity mode. **0**: no affinities; **1**: big cores first; **2**: little cores first | | mode | Affinity mode. **0**: no affinities; **1**: big cores first; **2**: medium cores first|
### OH_AI_ContextSetThreadNum() ### OH_AI_ContextSetThreadNum()
``` ```
OH_AI_API void OH_AI_ContextSetThreadNum (OH_AI_ContextHandle context, int32_t thread_num ) OH_AI_API void OH_AI_ContextSetThreadNum (OH_AI_ContextHandle context, int32_t thread_num )
``` ```
**Description**<br>
**Description**
Sets the number of runtime threads. Sets the number of runtime threads.
**Parameters** **Parameters**
| Name | Description |
| ---------- | ------------------------------------------------------------ |
| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance.|
| thread_num | Number of runtime threads. |
### OH_AI_CreateNNRTDeviceInfoByName()
```
OH_AI_API OH_AI_DeviceInfoHandle OH_AI_CreateNNRTDeviceInfoByName (const char * name)
```
**Description**
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.
**Parameters**
| Name| Description |
| ---- | ---------------- |
| name | Name of the NNRt device.|
**Returns**
[OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.
**Since**
10
### OH_AI_CreateNNRTDeviceInfoByType()
```
OH_AI_API OH_AI_DeviceInfoHandle OH_AI_CreateNNRTDeviceInfoByType (OH_AI_NNRTDeviceType type)
```
**Description**
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.
**Parameters**
| Name| Description |
| ---- | ------------------------------------------------------------ |
| type | NNRt device type, which is specified by [OH_AI_NNRTDeviceType](#oh_ai_nnrtdevicetype).|
**Returns**
[OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.
**Since**
10
### OH_AI_DestroyAllNNRTDeviceDescs()
```
OH_AI_API void OH_AI_DestroyAllNNRTDeviceDescs (NNRTDeviceDesc ** desc)
```
**Description**
Destroys the array of NNRT descriptions obtained by [OH_AI_GetAllNNRTDeviceDescs](#oh_ai_getallnnrtdevicedescs).
**Parameters**
| Name | Description | | Name| Description |
| -------- | -------- | | ---- | ------------------------------------------------------------ |
| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. | | desc | Double pointer to the array of the NNRt device descriptions. After the operation is complete, the content pointed to by **desc** is set to **NULL**.|
| thread_num | Number of runtime threads. |
**Since**
10
### OH_AI_DeviceInfoCreate() ### OH_AI_DeviceInfoCreate()
``` ```
OH_AI_API OH_AI_DeviceInfoHandle OH_AI_DeviceInfoCreate (OH_AI_DeviceType device_type) OH_AI_API OH_AI_DeviceInfoHandle OH_AI_DeviceInfoCreate (OH_AI_DeviceType device_type)
``` ```
**Description**<br>
**Description**
Creates a device information object. Creates a device information object.
**Parameters** **Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | ----------- | ------------------------------------------------------- |
| device_type | Device type. For details, see [OH_AI_DeviceType](#oh_ai_devicetype). | | device_type | Device type, which is specified by [OH_AI_DeviceType](#oh_ai_devicetype).|
**Returns** **Returns**
[OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to the device information instance. [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.
### OH_AI_DeviceInfoDestroy() ### OH_AI_DeviceInfoDestroy()
``` ```
OH_AI_API void OH_AI_DeviceInfoDestroy (OH_AI_DeviceInfoHandle * device_info) OH_AI_API void OH_AI_DeviceInfoDestroy (OH_AI_DeviceInfoHandle * device_info)
``` ```
**Description**<br>
Destroys a device information instance.
**Parameters** **Description**
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.
**Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | ----------- | ------------------------------------------------------------ |
| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | | device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.|
### OH_AI_DeviceInfoGetDeviceId()
```
OH_AI_API size_t OH_AI_DeviceInfoGetDeviceId (const OH_AI_DeviceInfoHandle device_info)
```
**Description**
Obtains the ID of an NNRt device. This API is available only for NNRt devices.
**Parameters**
| Name | Description |
| ----------- | ------------------------------------------------------------ |
| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.|
**Returns**
NNRt device ID.
**Since**
10
### OH_AI_DeviceInfoGetDeviceType() ### OH_AI_DeviceInfoGetDeviceType()
``` ```
OH_AI_API OH_AI_DeviceType OH_AI_DeviceInfoGetDeviceType (const OH_AI_DeviceInfoHandle device_info) OH_AI_API OH_AI_DeviceType OH_AI_DeviceInfoGetDeviceType (const OH_AI_DeviceInfoHandle device_info)
``` ```
**Description**<br>
Obtains the type of a provider device.
**Parameters** **Description**
Obtains the device type.
| Name | Description | **Parameters**
| -------- | -------- |
| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | | Name | Description |
| ----------- | ------------------------------------------------------------ |
| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.|
**Returns** **Returns**
...@@ -676,18 +996,20 @@ Type of the provider device. ...@@ -676,18 +996,20 @@ Type of the provider device.
### OH_AI_DeviceInfoGetEnableFP16() ### OH_AI_DeviceInfoGetEnableFP16()
``` ```
OH_AI_API bool OH_AI_DeviceInfoGetEnableFP16 (const OH_AI_DeviceInfoHandle device_info) OH_AI_API bool OH_AI_DeviceInfoGetEnableFP16 (const OH_AI_DeviceInfoHandle device_info)
``` ```
**Description**<br>
Checks whether float16 inference is enabled. This function is available only for CPU/GPU devices.
**Parameters** **Description**
Checks whether float16 inference is enabled. This function is available only for CPU and GPU devices.
**Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | ----------- | ------------------------------------------------------------ |
| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | | device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.|
**Returns** **Returns**
...@@ -696,38 +1018,94 @@ Whether float16 inference is enabled. ...@@ -696,38 +1018,94 @@ Whether float16 inference is enabled.
### OH_AI_DeviceInfoGetFrequency() ### OH_AI_DeviceInfoGetFrequency()
``` ```
OH_AI_API int OH_AI_DeviceInfoGetFrequency (const OH_AI_DeviceInfoHandle device_info) OH_AI_API int OH_AI_DeviceInfoGetFrequency (const OH_AI_DeviceInfoHandle device_info)
``` ```
**Description**<br>
Obtains the NPU frequency type. This function is available only for NPU devices.
**Parameters** **Description**
Obtains the NPU frequency type. This API is available only for NPU devices.
**Parameters**
| Name | Description |
| ----------- | ------------------------------------------------------------ |
| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.|
**Returns**
NPU frequency type. The value ranges from **0** to **4**. **1**: low power consumption; **2**: balanced; **3**: high performance; **4**: ultra-high performance
### OH_AI_DeviceInfoGetPerformanceMode()
```
OH_AI_API OH_AI_PerformanceMode OH_AI_DeviceInfoGetPerformanceMode (const OH_AI_DeviceInfoHandle device_info)
```
**Description**
Obtains the performance mode of an NNRt device. This API is available only for NNRt devices.
**Parameters**
| Name | Description |
| ----------- | ------------------------------------------------------------ |
| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.|
**Returns**
NNRt performance mode, which is specified by [OH_AI_PerformanceMode](#oh_ai_performancemode).
**Since**
10
### OH_AI_DeviceInfoGetPriority()
```
OH_AI_API OH_AI_Priority OH_AI_DeviceInfoGetPriority (const OH_AI_DeviceInfoHandle device_info)
```
**Description**
| Name | Description | Obtains the priority of an NNRT task. This API is available only for NNRt devices.
| -------- | -------- |
| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | **Parameters**
| Name | Description |
| ----------- | ------------------------------------------------------------ |
| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.|
**Returns** **Returns**
Frequency type of the NPU. The value ranges from **0** to **4**. **1**: low power consumption; **2**: balanced; **3**: high performance; **4**: ultra-high performance NNRt task priority, which is specified by [OH_AI_Priority](#oh_ai_priority).
**Since**
10
### OH_AI_DeviceInfoGetProvider() ### OH_AI_DeviceInfoGetProvider()
``` ```
OH_AI_API const char* OH_AI_DeviceInfoGetProvider (const OH_AI_DeviceInfoHandle device_info) OH_AI_API const char* OH_AI_DeviceInfoGetProvider (const OH_AI_DeviceInfoHandle device_info)
``` ```
**Description**<br>
**Description**
Obtains the provider name. Obtains the provider name.
**Parameters** **Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | ----------- | ------------------------------------------------------------ |
| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | | device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.|
**Returns** **Returns**
...@@ -736,150 +1114,339 @@ Provider name. ...@@ -736,150 +1114,339 @@ Provider name.
### OH_AI_DeviceInfoGetProviderDevice() ### OH_AI_DeviceInfoGetProviderDevice()
``` ```
OH_AI_API const char* OH_AI_DeviceInfoGetProviderDevice (const OH_AI_DeviceInfoHandle device_info) OH_AI_API const char* OH_AI_DeviceInfoGetProviderDevice (const OH_AI_DeviceInfoHandle device_info)
``` ```
**Description**<br>
**Description**
Obtains the name of a provider device. Obtains the name of a provider device.
**Parameters** **Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | ----------- | ------------------------------------------------------------ |
| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | | device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.|
**Returns** **Returns**
Name of the provider device. Name of the provider device.
### OH_AI_DeviceInfoSetDeviceId()
```
OH_AI_API void OH_AI_DeviceInfoSetDeviceId (OH_AI_DeviceInfoHandle device_info, size_t device_id )
```
**Description**
Sets the ID of an NNRt device. This API is available only for NNRt devices.
**Parameters**
| Name | Description |
| ----------- | ------------------------------------------------------------ |
| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.|
| device_id | NNRt device ID. |
**Since**
10
### OH_AI_DeviceInfoSetEnableFP16() ### OH_AI_DeviceInfoSetEnableFP16()
``` ```
OH_AI_API void OH_AI_DeviceInfoSetEnableFP16 (OH_AI_DeviceInfoHandle device_info, bool is_fp16 ) OH_AI_API void OH_AI_DeviceInfoSetEnableFP16 (OH_AI_DeviceInfoHandle device_info, bool is_fp16 )
``` ```
**Description**<br>
Sets whether to enable float16 inference. This function is available only for CPU/GPU devices.
**Parameters** **Description**
Sets whether to enable float16 inference. This function is available only for CPU and GPU devices.
**Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | ----------- | ------------------------------------------------------------ |
| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | | device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.|
| is_fp16 | Whether to enable float16 inference. | | is_fp16 | Whether to enable the float16 inference mode. |
### OH_AI_DeviceInfoSetFrequency() ### OH_AI_DeviceInfoSetFrequency()
``` ```
OH_AI_API void OH_AI_DeviceInfoSetFrequency (OH_AI_DeviceInfoHandle device_info, int frequency ) OH_AI_API void OH_AI_DeviceInfoSetFrequency (OH_AI_DeviceInfoHandle device_info, int frequency )
``` ```
**Description**<br>
**Description**
Sets the NPU frequency type. This function is available only for NPU devices. Sets the NPU frequency type. This function is available only for NPU devices.
**Parameters** **Parameters**
| Name | Description |
| ----------- | ------------------------------------------------------------ |
| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.|
| frequency | NPU frequency type. The value ranges from **0** to **4**. The default value is **3**. **1**: low power consumption; **2**: balanced; **3**: high performance; **4**: ultra-high performance|
### OH_AI_DeviceInfoSetPerformanceMode()
```
OH_AI_API void OH_AI_DeviceInfoSetPerformanceMode (OH_AI_DeviceInfoHandle device_info, OH_AI_PerformanceMode mode )
```
**Description**
Sets the performance mode of an NNRt device. This API is available only for NNRt devices.
**Parameters**
| Name | Description |
| ----------- | ------------------------------------------------------------ |
| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.|
| mode | NNRt performance mode, which is specified by [OH_AI_PerformanceMode](#oh_ai_performancemode).|
**Since**
| Name | Description | 10
| -------- | -------- |
| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. |
| frequency | NPU frequency type. The value ranges from **0** to **4**. The default value is **3**. **1**: low power consumption; **2**: balanced; **3**: high performance; **4**: ultra-high performance | ### OH_AI_DeviceInfoSetPriority()
```
OH_AI_API void OH_AI_DeviceInfoSetPriority (OH_AI_DeviceInfoHandle device_info, OH_AI_Priority priority )
```
**Description**
Sets the priority of an NNRt task. This API is available only for NNRt devices.
**Parameters**
| Name | Description |
| ----------- | ------------------------------------------------------------ |
| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.|
| priority | NNRt task priority, which is specified by [OH_AI_Priority](#oh_ai_priority). |
**Since**
10
### OH_AI_DeviceInfoSetProvider() ### OH_AI_DeviceInfoSetProvider()
``` ```
OH_AI_API void OH_AI_DeviceInfoSetProvider (OH_AI_DeviceInfoHandle device_info, const char * provider ) OH_AI_API void OH_AI_DeviceInfoSetProvider (OH_AI_DeviceInfoHandle device_info, const char * provider )
``` ```
**Description**<br>
Sets the name of a provider.
**Parameters** **Description**
Sets the provider name.
| Name | Description | **Parameters**
| -------- | -------- |
| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | | Name | Description |
| provider | Provider name. | | ----------- | ------------------------------------------------------------ |
| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.|
| provider | Provider name. |
### OH_AI_DeviceInfoSetProviderDevice() ### OH_AI_DeviceInfoSetProviderDevice()
``` ```
OH_AI_API void OH_AI_DeviceInfoSetProviderDevice (OH_AI_DeviceInfoHandle device_info, const char * device ) OH_AI_API void OH_AI_DeviceInfoSetProviderDevice (OH_AI_DeviceInfoHandle device_info, const char * device )
``` ```
**Description**<br>
**Description**
Sets the name of a provider device. Sets the name of a provider device.
**Parameters** **Parameters**
| Name | Description |
| ----------- | ------------------------------------------------------------ |
| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.|
| device | Name of the provider device, for example, CPU. |
### OH_AI_GetAllNNRTDeviceDescs()
```
OH_AI_API NNRTDeviceDesc* OH_AI_GetAllNNRTDeviceDescs (size_t * num)
```
**Description**
Obtains the descriptions of all NNRt devices in the system.
**Parameters**
| Name| Description |
| ---- | ------------------------ |
| num | Number of NNRt devices.|
**Returns**
Pointer to the array of the NNRt device descriptions. If the operation fails, **NULL** is returned.
**Since**
10
### OH_AI_GetDeviceIdFromNNRTDeviceDesc()
```
OH_AI_API size_t OH_AI_GetDeviceIdFromNNRTDeviceDesc (const NNRTDeviceDesc * desc)
```
**Description**
Obtains the NNRt device ID from the specified NNRt device description. Note that this ID is valid only for NNRt devices.
**Parameters**
| Name | Description | | Name| Description |
| -------- | -------- | | ---- | -------------------------------- |
| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | | desc | Pointer to the NNRt device description.|
| device | Name of the provider device, for example, CPU. |
**Returns**
NNRt device ID.
**Since**
10
### OH_AI_GetNameFromNNRTDeviceDesc()
```
OH_AI_API const char* OH_AI_GetNameFromNNRTDeviceDesc (const NNRTDeviceDesc * desc)
```
**Description**
Obtains the NNRt device name from the specified NNRt device description.
**Parameters**
| Name| Description |
| ---- | -------------------------------- |
| desc | Pointer to the NNRt device description.|
**Returns**
NNRt device name. The value is a pointer that points to a constant string, which is held by **desc**. The caller does not need to destroy it separately.
**Since**
10
### OH_AI_GetTypeFromNNRTDeviceDesc()
```
OH_AI_API OH_AI_NNRTDeviceType OH_AI_GetTypeFromNNRTDeviceDesc (const NNRTDeviceDesc * desc)
```
**Description**
Obtains the NNRt device type from the specified NNRt device description.
**Parameters**
| Name| Description |
| ---- | -------------------------------- |
| desc | Pointer to the NNRt device description.|
**Returns**
NNRt device type, which is specified by [OH_AI_NNRTDeviceType](#oh_ai_nnrtdevicetype).
**Since**
10
### OH_AI_ModelBuild() ### OH_AI_ModelBuild()
``` ```
OH_AI_API OH_AI_Status OH_AI_ModelBuild (OH_AI_ModelHandle model, const void * model_data, size_t data_size, OH_AI_ModelType model_type, const OH_AI_ContextHandle model_context ) OH_AI_API OH_AI_Status OH_AI_ModelBuild (OH_AI_ModelHandle model, const void * model_data, size_t data_size, OH_AI_ModelType model_type, const OH_AI_ContextHandle model_context )
``` ```
**Description**<br>
**Description**
Loads and builds a MindSpore model from the memory buffer. Loads and builds a MindSpore model from the memory buffer.
Note that the same {\@Link OH_AI_ContextHandle} object can only be passed to {\@Link OH_AI_ModelBuild} or {\@Link OH_AI_ModelBuildFromFile} once. If you call this function multiple times, make sure that you create multiple {\@Link OH_AI_ContextHandle} objects accordingly. Note that the same {\@Link OH_AI_ContextHandle} object can only be passed to {\@Link OH_AI_ModelBuild} or {\@Link OH_AI_ModelBuildFromFile} once. If you call this function multiple times, make sure that you create multiple {\@Link OH_AI_ContextHandle} objects accordingly.
**Parameters** **Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | ------------- | ------------------------------------------------------------ |
| model | Pointer to the model object. | | model | Pointer to the model object. |
| model_data | Address of the loaded model data in the memory. | | model_data | Address of the loaded model data in the memory. |
| data_size | Length of the model data. | | data_size | Length of the model data. |
| model_type | Type of the model file. For details, see [OH_AI_ModelType](#oh_ai_modeltype). | | model_type | Model file type, which is specified by [OH_AI_ModelType](#oh_ai_modeltype). |
| model_context | Context for model running. For details, see [OH_AI_ContextHandle](#oh_ai_contexthandle). | | model_context | Model runtime context, which is specified by [OH_AI_ContextHandle](#oh_ai_contexthandle).|
**Returns** **Returns**
Status code enumerated by [OH_AI_Status](#oh_ai_status). The value **MSStatus::kMSStatusSuccess** indicates that the operation is successful. Status code enumerated by [OH_AI_Status](#oh_ai_status-1). The value **MSStatus::kMSStatusSuccess** indicates that the operation is successful.
### OH_AI_ModelBuildFromFile() ### OH_AI_ModelBuildFromFile()
``` ```
OH_AI_API OH_AI_Status OH_AI_ModelBuildFromFile (OH_AI_ModelHandle model, const char * model_path, OH_AI_ModelType model_type, const OH_AI_ContextHandle model_context ) OH_AI_API OH_AI_Status OH_AI_ModelBuildFromFile (OH_AI_ModelHandle model, const char * model_path, OH_AI_ModelType model_type, const OH_AI_ContextHandle model_context )
``` ```
**Description**<br>
**Description**
Loads and builds a MindSpore model from a model file. Loads and builds a MindSpore model from a model file.
Note that the same {\@Link OH_AI_ContextHandle} object can only be passed to {\@Link OH_AI_ModelBuild} or {\@Link OH_AI_ModelBuildFromFile} once. If you call this function multiple times, make sure that you create multiple {\@Link OH_AI_ContextHandle} objects accordingly. Note that the same {\@Link OH_AI_ContextHandle} object can only be passed to {\@Link OH_AI_ModelBuild} or {\@Link OH_AI_ModelBuildFromFile} once. If you call this function multiple times, make sure that you create multiple {\@Link OH_AI_ContextHandle} objects accordingly.
**Parameters** **Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | ------------- | ------------------------------------------------------------ |
| model | Pointer to the model object. | | model | Pointer to the model object. |
| model_path | Path of the model file. | | model_path | Path of the model file. |
| model_type | Type of the model file. For details, see [OH_AI_ModelType](#oh_ai_modeltype). | | model_type | Model file type, which is specified by [OH_AI_ModelType](#oh_ai_modeltype). |
| model_context | Context for model running. For details, see [OH_AI_ContextHandle](#oh_ai_contexthandle). | | model_context | Model runtime context, which is specified by [OH_AI_ContextHandle](#oh_ai_contexthandle).|
**Returns** **Returns**
Status code enumerated by [OH_AI_Status](#oh_ai_status). The value **MSStatus::kMSStatusSuccess** indicates that the operation is successful. Status code enumerated by [OH_AI_Status](#oh_ai_status-1). The value **MSStatus::kMSStatusSuccess** indicates that the operation is successful.
### OH_AI_ModelCreate() ### OH_AI_ModelCreate()
``` ```
OH_AI_API OH_AI_ModelHandle OH_AI_ModelCreate () OH_AI_API OH_AI_ModelHandle OH_AI_ModelCreate ()
``` ```
**Description**<br>
**Description**
Creates a model object. Creates a model object.
**Returns** **Returns**
...@@ -889,35 +1456,39 @@ Pointer to the model object. ...@@ -889,35 +1456,39 @@ Pointer to the model object.
### OH_AI_ModelDestroy() ### OH_AI_ModelDestroy()
``` ```
OH_AI_API void OH_AI_ModelDestroy (OH_AI_ModelHandle * model) OH_AI_API void OH_AI_ModelDestroy (OH_AI_ModelHandle * model)
``` ```
**Description**<br>
**Description**
Destroys a model object. Destroys a model object.
**Parameters** **Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | ----- | -------------- |
| model | Pointer to the model object. | | model | Pointer to the model object.|
### OH_AI_ModelGetInputByTensorName() ### OH_AI_ModelGetInputByTensorName()
``` ```
OH_AI_API OH_AI_TensorHandle OH_AI_ModelGetInputByTensorName (const OH_AI_ModelHandle model, const char * tensor_name ) OH_AI_API OH_AI_TensorHandle OH_AI_ModelGetInputByTensorName (const OH_AI_ModelHandle model, const char * tensor_name )
``` ```
**Description**<br>
**Description**
Obtains the input tensor of a model by tensor name. Obtains the input tensor of a model by tensor name.
**Parameters** **Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | ----------- | -------------- |
| model | Pointer to the model object. | | model | Pointer to the model object.|
| tensor_name | Tensor name. | | tensor_name | Tensor name. |
**Returns** **Returns**
...@@ -926,18 +1497,20 @@ Pointer to the input tensor indicated by **tensor_name**. If the tensor does not ...@@ -926,18 +1497,20 @@ Pointer to the input tensor indicated by **tensor_name**. If the tensor does not
### OH_AI_ModelGetInputs() ### OH_AI_ModelGetInputs()
``` ```
OH_AI_API OH_AI_TensorHandleArray OH_AI_ModelGetInputs (const OH_AI_ModelHandle model) OH_AI_API OH_AI_TensorHandleArray OH_AI_ModelGetInputs (const OH_AI_ModelHandle model)
``` ```
**Description**<br>
**Description**
Obtains the input tensor array structure of a model. Obtains the input tensor array structure of a model.
**Parameters** **Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | ----- | -------------- |
| model | Pointer to the model object. | | model | Pointer to the model object.|
**Returns** **Returns**
...@@ -946,39 +1519,43 @@ Tensor array structure corresponding to the model input. ...@@ -946,39 +1519,43 @@ Tensor array structure corresponding to the model input.
### OH_AI_ModelGetOutputByTensorName() ### OH_AI_ModelGetOutputByTensorName()
``` ```
OH_AI_API OH_AI_TensorHandle OH_AI_ModelGetOutputByTensorName (const OH_AI_ModelHandle model, const char * tensor_name ) OH_AI_API OH_AI_TensorHandle OH_AI_ModelGetOutputByTensorName (const OH_AI_ModelHandle model, const char * tensor_name )
``` ```
**Description**<br>
**Description**
Obtains the output tensor of a model by tensor name. Obtains the output tensor of a model by tensor name.
**Parameters** **Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | ----------- | -------------- |
| model | Pointer to the model object. | | model | Pointer to the model object.|
| tensor_name | Tensor name. | | tensor_name | Tensor name. |
**Returns** **Returns**
Pointer to the output tensor indicated by **tensor_name**. If the tensor does not exist in the input, **null** will be returned. Pointer to the input tensor indicated by **tensor_name**. If the tensor does not exist, **null** will be returned.
### OH_AI_ModelGetOutputs() ### OH_AI_ModelGetOutputs()
``` ```
OH_AI_API OH_AI_TensorHandleArray OH_AI_ModelGetOutputs (const OH_AI_ModelHandle model) OH_AI_API OH_AI_TensorHandleArray OH_AI_ModelGetOutputs (const OH_AI_ModelHandle model)
``` ```
**Description**<br>
**Description**
Obtains the output tensor array structure of a model. Obtains the output tensor array structure of a model.
**Parameters** **Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | ----- | -------------- |
| model | Pointer to the model object. | | model | Pointer to the model object.|
**Returns** **Returns**
...@@ -987,126 +1564,138 @@ Tensor array structure corresponding to the model output. ...@@ -987,126 +1564,138 @@ Tensor array structure corresponding to the model output.
### OH_AI_ModelPredict() ### OH_AI_ModelPredict()
``` ```
OH_AI_API OH_AI_Status OH_AI_ModelPredict (OH_AI_ModelHandle model, const OH_AI_TensorHandleArray inputs, OH_AI_TensorHandleArray * outputs, const OH_AI_KernelCallBack before, const OH_AI_KernelCallBack after ) OH_AI_API OH_AI_Status OH_AI_ModelPredict (OH_AI_ModelHandle model, const OH_AI_TensorHandleArray inputs, OH_AI_TensorHandleArray * outputs, const OH_AI_KernelCallBack before, const OH_AI_KernelCallBack after )
``` ```
**Description**<br>
**Description**
Performs model inference. Performs model inference.
**Parameters** **Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | ------- | ------------------------------------ |
| model | Pointer to the model object. | | model | Pointer to the model object. |
| inputs | Tensor array structure corresponding to the model input. | | inputs | Tensor array structure corresponding to the model input. |
| outputs | Pointer to the tensor array structure corresponding to the model output. | | outputs | Pointer to the tensor array structure corresponding to the model output.|
| before | Callback function executed before model inference. | | before | Callback function executed before model inference. |
| after | Callback function executed after model inference. | | after | Callback function executed after model inference. |
**Returns** **Returns**
Status code enumerated by [OH_AI_Status](#oh_ai_status). The value **MSStatus::kMSStatusSuccess** indicates that the operation is successful. Status code enumerated by [OH_AI_Status](#oh_ai_status-1). The value **MSStatus::kMSStatusSuccess** indicates that the operation is successful.
### OH_AI_ModelResize() ### OH_AI_ModelResize()
``` ```
OH_AI_API OH_AI_Status OH_AI_ModelResize (OH_AI_ModelHandle model, const OH_AI_TensorHandleArray inputs, OH_AI_ShapeInfo * shape_infos, size_t shape_info_num ) OH_AI_API OH_AI_Status OH_AI_ModelResize (OH_AI_ModelHandle model, const OH_AI_TensorHandleArray inputs, OH_AI_ShapeInfo * shape_infos, size_t shape_info_num )
``` ```
**Description**<br>
**Description**
Adjusts the input tensor shapes of a built model. Adjusts the input tensor shapes of a built model.
**Parameters** **Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | -------------- | ------------------------------------------------------------ |
| model | Pointer to the model object. | | model | Pointer to the model object. |
| inputs | Tensor array structure corresponding to the model input. | | inputs | Tensor array structure corresponding to the model input. |
| shape_infos | Input shape array, which consists of tensor shapes arranged in the model input sequence. The model adjusts the tensor shapes in sequence. | | shape_infos | Input shape information array, which consists of tensor shapes arranged in the model input sequence. The model adjusts the tensor shapes in sequence.|
| shape_info_num | Length of the input shape array. | | shape_info_num | Length of the shape information array. |
**Returns** **Returns**
Status code enumerated by [OH_AI_Status](#oh_ai_status). The value **MSStatus::kMSStatusSuccess** indicates that the operation is successful. Status code enumerated by [OH_AI_Status](#oh_ai_status-1). The value **MSStatus::kMSStatusSuccess** indicates that the operation is successful.
### OH_AI_TensorClone() ### OH_AI_TensorClone()
``` ```
OH_AI_API OH_AI_TensorHandle OH_AI_TensorClone (OH_AI_TensorHandle tensor) OH_AI_API OH_AI_TensorHandle OH_AI_TensorClone (OH_AI_TensorHandle tensor)
``` ```
**Description**<br>
**Description**
Clones a tensor. Clones a tensor.
**Parameters** **Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | ------ | ------------------ |
| tensor | Pointer to the tensor to clone. | | tensor | Pointer to the tensor to clone.|
**Returns** **Returns**
Handle of the new tensor object. Defines the handle of a tensor object.
### OH_AI_TensorCreate() ### OH_AI_TensorCreate()
``` ```
OH_AI_API OH_AI_TensorHandle OH_AI_TensorCreate (const char * name, OH_AI_DataType type, const int64_t * shape, size_t shape_num, const void * data, size_t data_len ) OH_AI_API OH_AI_TensorHandle OH_AI_TensorCreate (const char * name, OH_AI_DataType type, const int64_t * shape, size_t shape_num, const void * data, size_t data_len )
``` ```
**Description**<br>
**Description**
Creates a tensor object. Creates a tensor object.
**Parameters** **Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | --------- | ------------------ |
| name | Tensor name. | | name | Tensor name. |
| type | Tensor data type. | | type | Tensor data type. |
| shape | Tensor dimension array. | | shape | Tensor dimension array. |
| shape_num | Length of the tensor dimension array. | | shape_num | Length of the tensor dimension array.|
| data | Data pointer. | | data | Data pointer. |
| data_len | Data length. | | data_len | Data length. |
**Returns** **Returns**
Handle of the tensor object. Defines the handle of a tensor object.
### OH_AI_TensorDestroy() ### OH_AI_TensorDestroy()
``` ```
OH_AI_API void OH_AI_TensorDestroy (OH_AI_TensorHandle * tensor) OH_AI_API void OH_AI_TensorDestroy (OH_AI_TensorHandle * tensor)
``` ```
**Description**<br>
**Description**
Destroys a tensor object. Destroys a tensor object.
**Parameters** **Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | ------ | ------------------------ |
| tensor | Level-2 pointer to the tensor handle. | | tensor | Level-2 pointer to the tensor handle.|
### OH_AI_TensorGetData() ### OH_AI_TensorGetData()
``` ```
OH_AI_API const void* OH_AI_TensorGetData (const OH_AI_TensorHandle tensor) OH_AI_API const void* OH_AI_TensorGetData (const OH_AI_TensorHandle tensor)
``` ```
**Description**<br>
**Description**
Obtains the pointer to tensor data. Obtains the pointer to tensor data.
**Parameters** **Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | ------ | -------------- |
| tensor | Handle of the tensor object. | | tensor | Handle of the tensor object.|
**Returns** **Returns**
...@@ -1115,18 +1704,20 @@ Pointer to tensor data. ...@@ -1115,18 +1704,20 @@ Pointer to tensor data.
### OH_AI_TensorGetDataSize() ### OH_AI_TensorGetDataSize()
``` ```
OH_AI_API size_t OH_AI_TensorGetDataSize (const OH_AI_TensorHandle tensor) OH_AI_API size_t OH_AI_TensorGetDataSize (const OH_AI_TensorHandle tensor)
``` ```
**Description**<br>
**Description**
Obtains the number of bytes of the tensor data. Obtains the number of bytes of the tensor data.
**Parameters** **Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | ------ | -------------- |
| tensor | Handle of the tensor object. | | tensor | Handle of the tensor object.|
**Returns** **Returns**
...@@ -1135,38 +1726,42 @@ Number of bytes of the tensor data. ...@@ -1135,38 +1726,42 @@ Number of bytes of the tensor data.
### OH_AI_TensorGetDataType() ### OH_AI_TensorGetDataType()
``` ```
OH_AI_API OH_AI_DataType OH_AI_TensorGetDataType (const OH_AI_TensorHandle tensor) OH_AI_API OH_AI_DataType OH_AI_TensorGetDataType (const OH_AI_TensorHandle tensor)
``` ```
**Description**<br>
Obtains the data type of a tensor.
**Parameters** **Description**
Obtains the tensor type.
| Name | Description | **Parameters**
| -------- | -------- |
| tensor | Handle of the tensor object. | | Name | Description |
| ------ | -------------- |
| tensor | Handle of the tensor object.|
**Returns** **Returns**
Data type of the tensor. Tensor data type.
### OH_AI_TensorGetElementNum() ### OH_AI_TensorGetElementNum()
``` ```
OH_AI_API int64_t OH_AI_TensorGetElementNum (const OH_AI_TensorHandle tensor) OH_AI_API int64_t OH_AI_TensorGetElementNum (const OH_AI_TensorHandle tensor)
``` ```
**Description**<br>
**Description**
Obtains the number of tensor elements. Obtains the number of tensor elements.
**Parameters** **Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | ------ | -------------- |
| tensor | Handle of the tensor object. | | tensor | Handle of the tensor object.|
**Returns** **Returns**
...@@ -1175,18 +1770,20 @@ Number of tensor elements. ...@@ -1175,18 +1770,20 @@ Number of tensor elements.
### OH_AI_TensorGetFormat() ### OH_AI_TensorGetFormat()
``` ```
OH_AI_API OH_AI_Format OH_AI_TensorGetFormat (const OH_AI_TensorHandle tensor) OH_AI_API OH_AI_Format OH_AI_TensorGetFormat (const OH_AI_TensorHandle tensor)
``` ```
**Description**<br>
**Description**
Obtains the tensor data format. Obtains the tensor data format.
**Parameters** **Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | ------ | -------------- |
| tensor | Handle of the tensor object. | | tensor | Handle of the tensor object.|
**Returns** **Returns**
...@@ -1195,38 +1792,42 @@ Tensor data format. ...@@ -1195,38 +1792,42 @@ Tensor data format.
### OH_AI_TensorGetMutableData() ### OH_AI_TensorGetMutableData()
``` ```
OH_AI_API void* OH_AI_TensorGetMutableData (const OH_AI_TensorHandle tensor) OH_AI_API void* OH_AI_TensorGetMutableData (const OH_AI_TensorHandle tensor)
``` ```
**Description**<br>
**Description**
Obtains the pointer to variable tensor data. If the data is empty, memory will be allocated. Obtains the pointer to variable tensor data. If the data is empty, memory will be allocated.
**Parameters** **Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | ------ | -------------- |
| tensor | Handle of the tensor object. | | tensor | Handle of the tensor object.|
**Returns** **Returns**
Pointer to variable tensor data. Pointer to tensor data.
### OH_AI_TensorGetName() ### OH_AI_TensorGetName()
``` ```
OH_AI_API const char* OH_AI_TensorGetName (const OH_AI_TensorHandle tensor) OH_AI_API const char* OH_AI_TensorGetName (const OH_AI_TensorHandle tensor)
``` ```
**Description**<br>
**Description**
Obtains the name of a tensor. Obtains the name of a tensor.
**Parameters** **Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | ------ | -------------- |
| tensor | Handle of the tensor object. | | tensor | Handle of the tensor object.|
**Returns** **Returns**
...@@ -1235,106 +1836,118 @@ Tensor name. ...@@ -1235,106 +1836,118 @@ Tensor name.
### OH_AI_TensorGetShape() ### OH_AI_TensorGetShape()
``` ```
OH_AI_API const int64_t* OH_AI_TensorGetShape (const OH_AI_TensorHandle tensor, size_t * shape_num ) OH_AI_API const int64_t* OH_AI_TensorGetShape (const OH_AI_TensorHandle tensor, size_t * shape_num )
``` ```
**Description**<br>
Obtains the shape of a tensor.
**Parameters** **Description**
| Name | Description | Obtains the tensor shape.
| -------- | -------- |
| tensor | Handle of the tensor object. | **Parameters**
| shape_num | Length of the tensor shape array. |
| Name | Description |
| --------- | ---------------------------------------------- |
| tensor | Handle of the tensor object. |
| shape_num | Length of the tensor shape array.|
**Returns** **Returns**
Tensor shape array. Shape array.
### OH_AI_TensorSetData() ### OH_AI_TensorSetData()
``` ```
OH_AI_API void OH_AI_TensorSetData (OH_AI_TensorHandle tensor, void * data ) OH_AI_API void OH_AI_TensorSetData (OH_AI_TensorHandle tensor, void * data )
``` ```
**Description**<br>
**Description**
Sets the tensor data. Sets the tensor data.
**Parameters** **Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | ------ | ---------------- |
| tensor | Handle of the tensor object. | | tensor | Handle of the tensor object. |
| data | Data pointer. | | data | Data pointer.|
### OH_AI_TensorSetDataType() ### OH_AI_TensorSetDataType()
``` ```
OH_AI_API void OH_AI_TensorSetDataType (OH_AI_TensorHandle tensor, OH_AI_DataType type ) OH_AI_API void OH_AI_TensorSetDataType (OH_AI_TensorHandle tensor, OH_AI_DataType type )
``` ```
**Description**<br>
Sets the data type of a tensor.
**Parameters** **Description**
Sets the tensor data type.
| Name | Description | **Parameters**
| -------- | -------- |
| tensor | Handle of the tensor object. | | Name | Description |
| type | Data type. For details, see [OH_AI_DataType](#oh_ai_datatype). | | ------ | --------------------------------------------------- |
| tensor | Handle of the tensor object. |
| type | Data type, which is specified by [OH_AI_DataType](#oh_ai_datatype).|
### OH_AI_TensorSetFormat() ### OH_AI_TensorSetFormat()
``` ```
OH_AI_API void OH_AI_TensorSetFormat (OH_AI_TensorHandle tensor, OH_AI_Format format ) OH_AI_API void OH_AI_TensorSetFormat (OH_AI_TensorHandle tensor, OH_AI_Format format )
``` ```
**Description**<br>
**Description**
Sets the tensor data format. Sets the tensor data format.
**Parameters** **Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | ------ | ------------------ |
| tensor | Handle of the tensor object. | | tensor | Handle of the tensor object. |
| format | Tensor data format. | | format | Tensor data format.|
### OH_AI_TensorSetName() ### OH_AI_TensorSetName()
``` ```
OH_AI_API void OH_AI_TensorSetName (OH_AI_TensorHandle tensor, const char * name ) OH_AI_API void OH_AI_TensorSetName (OH_AI_TensorHandle tensor, const char *name )
``` ```
**Description**<br>
Sets the name of a tensor.
**Parameters** **Description**
Sets the tensor name.
**Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | ------ | -------------- |
| tensor | Handle of the tensor object. | | tensor | Handle of the tensor object.|
| name | Tensor name. | | name | Tensor name. |
### OH_AI_TensorSetShape() ### OH_AI_TensorSetShape()
``` ```
OH_AI_API void OH_AI_TensorSetShape (OH_AI_TensorHandle tensor, const int64_t * shape, size_t shape_num ) OH_AI_API void OH_AI_TensorSetShape (OH_AI_TensorHandle tensor, const int64_t * shape, size_t shape_num )
``` ```
**Description**<br>
Sets the shape of a tensor.
**Parameters** **Description**
Sets the tensor shape.
**Parameters**
| Name | Description | | Name | Description |
| -------- | -------- | | --------- | ------------------ |
| tensor | Handle of the tensor object. | | tensor | Handle of the tensor object. |
| shape | Tensor shape array. | | shape | Shape array. |
| shape_num | Length of the tensor shape array. | | shape_num | Length of the tensor shape array.|
...@@ -5,10 +5,11 @@ ...@@ -5,10 +5,11 @@
Provides **Context** APIs for configuring runtime information. Provides **Context** APIs for configuring runtime information.
**Since:** **Since**
9 9
**Related Modules:** **Related Modules**
[MindSpore](_mind_spore.md) [MindSpore](_mind_spore.md)
...@@ -18,35 +19,48 @@ Provides **Context** APIs for configuring runtime information. ...@@ -18,35 +19,48 @@ Provides **Context** APIs for configuring runtime information.
### Types ### Types
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) | Defines the pointer to the MindSpore context. | | [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) | Defines the pointer to the MindSpore context. |
| [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) | Defines the pointer to the MindSpore device information. | | [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) | Defines the pointer to the MindSpore device information.|
### Functions ### Functions
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| [OH_AI_ContextCreate](_mind_spore.md#oh_ai_contextcreate) () | Creates a context object. | | [OH_AI_ContextCreate](_mind_spore.md#oh_ai_contextcreate) () | Creates a context object.|
| [OH_AI_ContextDestroy](_mind_spore.md#oh_ai_contextdestroy) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) \*context) | Destroys a context object. | | [OH_AI_ContextDestroy](_mind_spore.md#oh_ai_contextdestroy) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) \*context) | Destroys a context object.|
| [OH_AI_ContextSetThreadNum](_mind_spore.md#oh_ai_contextsetthreadnum) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, int32_t thread_num) | Sets the number of runtime threads. | | [OH_AI_ContextSetThreadNum](_mind_spore.md#oh_ai_contextsetthreadnum) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, int32_t thread_num) | Sets the number of runtime threads.|
| [OH_AI_ContextGetThreadNum](_mind_spore.md#oh_ai_contextgetthreadnum) (const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context) | Obtains the number of threads. | | [OH_AI_ContextGetThreadNum](_mind_spore.md#oh_ai_contextgetthreadnum) (const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context) | Obtains the number of threads.|
| [OH_AI_ContextSetThreadAffinityMode](_mind_spore.md#oh_ai_contextsetthreadaffinitymode) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, int mode) | Sets the affinity mode for binding runtime threads to CPU cores, which are categorized into little cores and big cores depending on the CPU frequency. | | [OH_AI_ContextSetThreadAffinityMode](_mind_spore.md#oh_ai_contextsetthreadaffinitymode) ([OH_AI_ContextHandle](_mind_spore.md#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](_mind_spore.md#oh_ai_contextgetthreadaffinitymode) (const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context) | Obtains the affinity mode for binding runtime threads to CPU cores. | | [OH_AI_ContextGetThreadAffinityMode](_mind_spore.md#oh_ai_contextgetthreadaffinitymode) (const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context) | Obtains the affinity mode for binding runtime threads to CPU cores.|
| [OH_AI_ContextSetThreadAffinityCoreList](_mind_spore.md#oh_ai_contextsetthreadaffinitycorelist) ([OH_AI_ContextHandle](_mind_spore.md#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_ContextSetThreadAffinityCoreList](_mind_spore.md#oh_ai_contextsetthreadaffinitycorelist) ([OH_AI_ContextHandle](_mind_spore.md#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](_mind_spore.md#oh_ai_contextgetthreadaffinitycorelist) (const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, size_t \*core_num) | Obtains the list of bound CPU cores. | | [OH_AI_ContextGetThreadAffinityCoreList](_mind_spore.md#oh_ai_contextgetthreadaffinitycorelist) (const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, size_t \*core_num) | Obtains the list of bound CPU cores.|
| [OH_AI_ContextSetEnableParallel](_mind_spore.md#oh_ai_contextsetenableparallel) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, bool is_parallel) | Sets whether to enable parallelism between operators. | | [OH_AI_ContextSetEnableParallel](_mind_spore.md#oh_ai_contextsetenableparallel) ([OH_AI_ContextHandle](_mind_spore.md#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](_mind_spore.md#oh_ai_contextgetenableparallel) (const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context) | Checks whether parallelism between operators is supported. | | [OH_AI_ContextGetEnableParallel](_mind_spore.md#oh_ai_contextgetenableparallel) (const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context) | Checks whether parallelism between operators is supported.|
| [OH_AI_ContextAddDeviceInfo](_mind_spore.md#oh_ai_contextadddeviceinfo) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Adds information about a running device. | | [OH_AI_ContextAddDeviceInfo](_mind_spore.md#oh_ai_contextadddeviceinfo) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Attaches the custom device information to the inference context.|
| [OH_AI_DeviceInfoCreate](_mind_spore.md#oh_ai_deviceinfocreate) ([OH_AI_DeviceType](_mind_spore.md#oh_ai_devicetype) device_type) | Creates a device information object. | | [OH_AI_DeviceInfoCreate](_mind_spore.md#oh_ai_deviceinfocreate) ([OH_AI_DeviceType](_mind_spore.md#oh_ai_devicetype) device_type) | Creates a device information object.|
| [OH_AI_DeviceInfoDestroy](_mind_spore.md#oh_ai_deviceinfodestroy) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) \*device_info) | Destroys a device information instance. | | [OH_AI_DeviceInfoDestroy](_mind_spore.md#oh_ai_deviceinfodestroy) ([OH_AI_DeviceInfoHandle](_mind_spore.md#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](_mind_spore.md#oh_ai_deviceinfosetprovider) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, const char \*provider) | Sets the name of a provider. | | [OH_AI_DeviceInfoSetProvider](_mind_spore.md#oh_ai_deviceinfosetprovider) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, const char \*provider) | Sets the provider name.|
| [OH_AI_DeviceInfoGetProvider](_mind_spore.md#oh_ai_deviceinfogetprovider) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the provider name. | | [OH_AI_DeviceInfoGetProvider](_mind_spore.md#oh_ai_deviceinfogetprovider) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the provider name.|
| [OH_AI_DeviceInfoSetProviderDevice](_mind_spore.md#oh_ai_deviceinfosetproviderdevice) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, const char \*device) | Sets the name of a provider device. | | [OH_AI_DeviceInfoSetProviderDevice](_mind_spore.md#oh_ai_deviceinfosetproviderdevice) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, const char \*device) | Sets the name of a provider device.|
| [OH_AI_DeviceInfoGetProviderDevice](_mind_spore.md#oh_ai_deviceinfogetproviderdevice) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the name of a provider device. | | [OH_AI_DeviceInfoGetProviderDevice](_mind_spore.md#oh_ai_deviceinfogetproviderdevice) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the name of a provider device.|
| [OH_AI_DeviceInfoGetDeviceType](_mind_spore.md#oh_ai_deviceinfogetdevicetype) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the type of a provider device. | | [OH_AI_DeviceInfoGetDeviceType](_mind_spore.md#oh_ai_deviceinfogetdevicetype) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the device type.|
| [OH_AI_DeviceInfoSetEnableFP16](_mind_spore.md#oh_ai_deviceinfosetenablefp16) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, bool is_fp16) | Sets whether to enable float16 inference. This function is available only for CPU/GPU devices. | | [OH_AI_DeviceInfoSetEnableFP16](_mind_spore.md#oh_ai_deviceinfosetenablefp16) ([OH_AI_DeviceInfoHandle](_mind_spore.md#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](_mind_spore.md#oh_ai_deviceinfogetenablefp16) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Checks whether float16 inference is enabled. This function is available only for CPU/GPU devices. | | [OH_AI_DeviceInfoGetEnableFP16](_mind_spore.md#oh_ai_deviceinfogetenablefp16) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Checks whether float16 inference is enabled. This function is available only for CPU and GPU devices.|
| [OH_AI_DeviceInfoSetFrequency](_mind_spore.md#oh_ai_deviceinfosetfrequency) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, int frequency) | Sets the NPU frequency type. This function is available only for NPU devices. | | [OH_AI_DeviceInfoSetFrequency](_mind_spore.md#oh_ai_deviceinfosetfrequency) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, int frequency) | Sets the NPU frequency type. This function is available only for NPU devices.|
| [OH_AI_DeviceInfoGetFrequency](_mind_spore.md#oh_ai_deviceinfogetfrequency) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the NPU frequency type. This function is available only for NPU devices. | | [OH_AI_DeviceInfoGetFrequency](_mind_spore.md#oh_ai_deviceinfogetfrequency) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the NPU frequency type. This function is available only for NPU devices.|
| [OH_AI_GetAllNNRTDeviceDescs](_mind_spore.md#oh_ai_getallnnrtdevicedescs) (size_t \*num) | Obtains the descriptions of all NNRt devices in the system.|
| [OH_AI_DestroyAllNNRTDeviceDescs](_mind_spore.md#oh_ai_destroyallnnrtdevicedescs) ([NNRTDeviceDesc](_mind_spore.md#nnrtdevicedesc) \*\*desc) | Destroys the array of NNRT descriptions obtained by [OH_AI_GetAllNNRTDeviceDescs](_mind_spore.md#oh_ai_getallnnrtdevicedescs).|
| [OH_AI_GetDeviceIdFromNNRTDeviceDesc](_mind_spore.md#oh_ai_getdeviceidfromnnrtdevicedesc) (const [NNRTDeviceDesc](_mind_spore.md#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](_mind_spore.md#oh_ai_getnamefromnnrtdevicedesc) (const [NNRTDeviceDesc](_mind_spore.md#nnrtdevicedesc) \*desc) | Obtains the NNRt device name from the specified NNRt device description.|
| [OH_AI_GetTypeFromNNRTDeviceDesc](_mind_spore.md#oh_ai_gettypefromnnrtdevicedesc) (const [NNRTDeviceDesc](_mind_spore.md#nnrtdevicedesc) \*desc) | Obtains the NNRt device type from the specified NNRt device description.|
| [OH_AI_CreateNNRTDeviceInfoByName](_mind_spore.md#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](_mind_spore.md#oh_ai_creatennrtdeviceinfobytype) ([OH_AI_NNRTDeviceType](_mind_spore.md#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](_mind_spore.md#oh_ai_deviceinfosetdeviceid) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, size_t device_id) | Sets the ID of an NNRt device. This API is available only for NNRt devices.|
| [OH_AI_DeviceInfoGetDeviceId](_mind_spore.md#oh_ai_deviceinfogetdeviceid) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the ID of an NNRt device. This API is available only for NNRt devices.|
| [OH_AI_DeviceInfoSetPerformanceMode](_mind_spore.md#oh_ai_deviceinfosetperformancemode) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, [OH_AI_PerformanceMode](_mind_spore.md#oh_ai_performancemode) mode) | Sets the performance mode of an NNRt device. This API is available only for NNRt devices.|
| [OH_AI_DeviceInfoGetPerformanceMode](_mind_spore.md#oh_ai_deviceinfogetperformancemode) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the performance mode of an NNRt device. This API is available only for NNRt devices.|
| [OH_AI_DeviceInfoSetPriority](_mind_spore.md#oh_ai_deviceinfosetpriority) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, [OH_AI_Priority](_mind_spore.md#oh_ai_priority) priority) | Sets the priority of an NNRT task. This API is available only for NNRt devices.|
| [OH_AI_DeviceInfoGetPriority](_mind_spore.md#oh_ai_deviceinfogetpriority) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the priority of an NNRT task. This API is available only for NNRt devices.|
# DriverExtensionAbility
[DriverExtensionAbility](../reference/apis/js-apis-app-ability-driverExtensionAbility.md)是DRIVER类型的ExtensionAbility组件,提供驱动相关扩展框架。对于部分设备,支持插入外接的硬件模块来扩展设备能力, 此时可以以应用方式安装该硬件模块的驱动程序。通过DriverExtensionAbility可实现此类应用的开发。
[DriverExtensionAbility](../reference/apis/js-apis-app-ability-driverExtensionAbility.md)可以通过DriverExtensionManager被应用绑定,并根据应用的请求信息在后台处理相关事务。
每个类型的ExtensionAbility都有自己的Context,DriverExtensionAbility通过[DriverExtensionContext](../reference/apis/js-apis-inner-application-driverExtensionContext.md)提供相关能力。
本章节将从如下场景来介绍DriverExtensionAbility的基本使用。
- [DriverExtensionAbility](#driverextensionability)
- [开发步骤](#开发步骤)
## 开发步骤
开发者在实现一个驱动时,需要在DevEco Studio工程中手动新建一个DriverExtensionAbility,具体步骤如下。
1. 在工程Module对应的ets目录下,右键选择“New &gt; Directory”,新建一个目录并命名为driverextability。
2. 在driverextability目录,右键选择“New &gt; TypeScript File”,新建一个TypeScript文件并命名为DriverExtAbility.ts。
3. 打开DriverExtAbility.ts文件,导入[RPC通信模块](../reference/apis/js-apis-rpc.md),重载onRemoteMessageRequest()方法,接收应用传递过来的消息,并将处理的结果返回给应用。REQUEST_VALUE用于校验应用发送的服务请求码。
```ts
import rpc from '@ohos.rpc';
const REQUEST_CODE = 99;
class StubTest extends rpc.RemoteObject {
constructor(des) {
super(des);
}
// 接收应用传递过来的消息处理,以及将处理的结果返回给应用
onRemoteMessageRequest(code, data, reply, option) {
if (code === REQUEST_CODE) {
// 接收应用传递过来的数据
// 应用使用多次调用data.writeInt()写入多个数据时,驱动可以通过多次调用data.readInt()方法接收对应的数据
let optFir = data.readInt();
let optSec = data.readInt();
// 驱动将数据的处理结果返回给应用
// 示例中为接收了两个数据,并将两个数据的求和返回给应用
reply.writeInt(optFir + optSec);
}
return true;
}
}
```
4. 在DriverExtAbility.ts文件中,增加导入[DriverExtensionAbility](../reference/apis/js-apis-app-ability-driverExtensionAbility.md)的依赖包,该包提供了onInit()、onRelease()、onConnect()和onDisconnect()生命周期回调,自定义类继承[DriverExtensionAbility](../reference/apis/js-apis-app-ability-driverExtensionAbility.md)并根据需要重写需要的生命周期回调。
```ts
import DriverExtensionAbility from '@ohos.app.ability.DriverExtensionAbility';
import rpc from '@ohos.rpc';
const TAG: string = '[Example].[Entry].[DriverExtAbility]';
const REQUEST_CODE = 99;
class StubTest extends rpc.RemoteObject {
// ...
}
export default class DriverExtAbility extends DriverExtensionAbility {
onInit(want) {
console.info(TAG, `onInit, want: ${want.abilityName}`);
}
onRelease() {
console.info(TAG, `onRelease, want: ${want.abilityName}`);
}
onConnect(want) {
console.info(TAG, `onConnect, want: ${want.abilityName}`);
return new StubTest("test");
}
onDisconnect(want) {
console.info(TAG, `onDisconnect, want: ${want.abilityName}`);
}
onDump() {
console.info(TAG, `onDump, params:` + JSON.stringify(params));
return ['params'];
}
}
```
5. 在工程Module对应的[module.json5配置文件](../quick-start/module-configuration-file.md)中注册DriverExtensionAbility,type标签需要设置为“driver”,srcEntry标签表示当前ExtensionAbility组件所对应的代码路径。
```json
{
"module": {
// ...
"extensionAbilities": [
{
"name": "DriverExtAbility",
"icon": "$media:icon",
"description": "driver",
"type": "driver",
"exported": true,
"srcEntry": "./ets/driverextability/DriverExtAbility.ts",
"metadata": [
{
"name": "bus", // 必填项,所属总线
"value": "USB",
},
{
"name": "desc", // 必填项,必要的驱动描述
"value": "the sample of driverExtensionAbility",
},
{
"name": "vendor", // 必填项,驱动厂商名称
"value": "string",
},
{
"name": "vid", // 支持 USB vendor id 列表,用逗号分隔,不可为空
"value": "string, string",
},
{
"name": "pid", // 支持的 USB product id 列表,用逗号分隔,不可为空
"value": "string, string",
}
]
}
]
}
}
```
\ No newline at end of file
...@@ -24,6 +24,7 @@ PersistentStorage和AppStorage中的属性建立双向同步。应用开发通 ...@@ -24,6 +24,7 @@ PersistentStorage和AppStorage中的属性建立双向同步。应用开发通
当持久化更改的过程变得太繁重时,PersistentStorage实现可能会限制持久化属性更改的频率。 当持久化更改的过程变得太繁重时,PersistentStorage实现可能会限制持久化属性更改的频率。
PersistentStorage和UIContext相关联,需要在[UIContext](../reference/apis/js-apis-arkui-UIContext.md#uicontext)明确的时候才可以调用,可以通过在[runScopedTask](../reference/apis/js-apis-arkui-UIContext.md#runscopedtask)里明确上下文。如果没有在UIContext明确的地方调用,将导致无法持久化数据。
## 使用场景 ## 使用场景
......
...@@ -336,6 +336,7 @@ ...@@ -336,6 +336,7 @@
- [@ohos.accessibility.GesturePath (手势路径)](js-apis-accessibility-GesturePath.md) - [@ohos.accessibility.GesturePath (手势路径)](js-apis-accessibility-GesturePath.md)
- [@ohos.accessibility.GesturePoint (手势触摸点)](js-apis-accessibility-GesturePoint.md) - [@ohos.accessibility.GesturePoint (手势触摸点)](js-apis-accessibility-GesturePoint.md)
- [@ohos.application.AccessibilityExtensionAbility (辅助功能扩展能力)](js-apis-application-accessibilityExtensionAbility.md) - [@ohos.application.AccessibilityExtensionAbility (辅助功能扩展能力)](js-apis-application-accessibilityExtensionAbility.md)
- [@ohos.base (公共回调信息)](js-apis-base.md)
- [@ohos.faultLogger (故障日志获取)](js-apis-faultLogger.md) - [@ohos.faultLogger (故障日志获取)](js-apis-faultLogger.md)
- [@ohos.hichecker (检测模式)](js-apis-hichecker.md) - [@ohos.hichecker (检测模式)](js-apis-hichecker.md)
- [@ohos.hidebug (Debug调试)](js-apis-hidebug.md) - [@ohos.hidebug (Debug调试)](js-apis-hidebug.md)
...@@ -388,7 +389,6 @@ ...@@ -388,7 +389,6 @@
- [@ohos.multimodalInput.shortKey(快捷键)](js-apis-shortKey.md) - [@ohos.multimodalInput.shortKey(快捷键)](js-apis-shortKey.md)
- [@ohos.power (系统电源管理)](js-apis-power.md) - [@ohos.power (系统电源管理)](js-apis-power.md)
- [@ohos.runningLock (Runninglock锁)](js-apis-runninglock.md) - [@ohos.runningLock (Runninglock锁)](js-apis-runninglock.md)
- [@ohos.resourceschedule.deviceStandby(设备待机模块)](js-apis-resourceschedule-deviceStandby.md)
- [@ohos.sensor (传感器)](js-apis-sensor.md) - [@ohos.sensor (传感器)](js-apis-sensor.md)
- [@ohos.settings (设置数据项名称)](js-apis-settings.md) - [@ohos.settings (设置数据项名称)](js-apis-settings.md)
- [@ohos.stationary (设备状态感知框架)](js-apis-stationary.md) - [@ohos.stationary (设备状态感知框架)](js-apis-stationary.md)
......
...@@ -137,11 +137,11 @@ import accessibility from '@ohos.accessibility'; ...@@ -137,11 +137,11 @@ import accessibility from '@ohos.accessibility';
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| --------------- | ---------------------------------------- | ---- | ---- | ----------- | | --------------- | ---------------------------------------- | ---- | ---- | ----------- |
| fontFamily | [CaptionsFontFamily](#captionsfontfamily8) | 是 | 否 | 描述字幕字体。 | | fontFamily | [CaptionsFontFamily](#captionsfontfamily8) | 是 | 否 | 描述字幕字体。 |
| fontScale | number | 是 | 否 | 描述字幕字体缩放系数。 | | fontScale | number | 是 | 否 | 描述字幕字体缩放系数,单位%,参数范围1~200。 |
| fontColor | number \| string | 是 | 否 | 描述字幕字体颜色。 | | fontColor | number \| string | 是 | 否 | 描述字幕字体颜色,例如red对应#FF0000。 |
| fontEdgeType | [CaptionsFontEdgeType](#captionsfontedgetype8) | 是 | 否 | 描述字幕字体边缘。 | | fontEdgeType | [CaptionsFontEdgeType](#captionsfontedgetype8) | 是 | 否 | 描述字幕字体边缘。 |
| backgroundColor | number \| string | 是 | 否 | 描述字幕背景颜色。 | | backgroundColor | number \| string | 是 | 否 | 描述字幕背景颜色,例如red对应#FF0000。 |
| windowColor | number \| string | 是 | 否 | 描述字幕窗口颜色。 | | windowColor | number \| string | 是 | 否 | 描述字幕窗口颜色,例如red对应#FF0000。 |
## CaptionsManager<sup>8+</sup> ## CaptionsManager<sup>8+</sup>
...@@ -162,6 +162,8 @@ on(type: 'enableChange', callback: Callback&lt;boolean&gt;): void; ...@@ -162,6 +162,8 @@ on(type: 'enableChange', callback: Callback&lt;boolean&gt;): void;
监听字幕配置启用状态变化事件,使用callback异步回调。 监听字幕配置启用状态变化事件,使用callback异步回调。
**系统能力**:SystemCapability.BarrierFree.Accessibility.Hearing
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -188,6 +190,8 @@ on(type: 'styleChange', callback: Callback&lt;CaptionsStyle&gt;): void; ...@@ -188,6 +190,8 @@ on(type: 'styleChange', callback: Callback&lt;CaptionsStyle&gt;): void;
监听字幕风格变化事件,使用callback异步回调。 监听字幕风格变化事件,使用callback异步回调。
**系统能力**:SystemCapability.BarrierFree.Accessibility.Hearing
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -216,6 +220,8 @@ off(type: 'enableChange', callback?: Callback&lt;boolean&gt;): void; ...@@ -216,6 +220,8 @@ off(type: 'enableChange', callback?: Callback&lt;boolean&gt;): void;
取消监听字幕配置启用状态变化事件,使用callback异步回调。 取消监听字幕配置启用状态变化事件,使用callback异步回调。
**系统能力**:SystemCapability.BarrierFree.Accessibility.Hearing
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -242,6 +248,8 @@ off(type: 'styleChange', callback?: Callback&lt;CaptionsStyle&gt;): void; ...@@ -242,6 +248,8 @@ off(type: 'styleChange', callback?: Callback&lt;CaptionsStyle&gt;): void;
取消字幕风格变化监听事件,使用callback异步回调。 取消字幕风格变化监听事件,使用callback异步回调。
**系统能力**:SystemCapability.BarrierFree.Accessibility.Hearing
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -573,7 +581,7 @@ on(type: 'accessibilityStateChange', callback: Callback&lt;boolean&gt;): void ...@@ -573,7 +581,7 @@ on(type: 'accessibilityStateChange', callback: Callback&lt;boolean&gt;): void
监听辅助应用启用状态变化事件,使用callback异步回调。 监听辅助应用启用状态变化事件,使用callback异步回调。
**系统能力**以下各项对应的系统能力有所不同,详见下表。 **系统能力**SystemCapability.BarrierFree.Accessibility.Core
**参数:** **参数:**
...@@ -600,7 +608,7 @@ on(type: 'touchGuideStateChange', callback: Callback&lt;boolean&gt;): void ...@@ -600,7 +608,7 @@ on(type: 'touchGuideStateChange', callback: Callback&lt;boolean&gt;): void
监听触摸浏览功能启用状态变化事件,使用callback异步回调。 监听触摸浏览功能启用状态变化事件,使用callback异步回调。
**系统能力**以下各项对应的系统能力有所不同,详见下表。 **系统能力**SystemCapability.BarrierFree.Accessibility.Vision
**参数:** **参数:**
...@@ -627,13 +635,13 @@ off(type: 'accessibilityStateChange', callback?: Callback&lt;boolean&gt;): void ...@@ -627,13 +635,13 @@ off(type: 'accessibilityStateChange', callback?: Callback&lt;boolean&gt;): void
取消监听辅助应用启用状态变化事件,使用callback异步回调。 取消监听辅助应用启用状态变化事件,使用callback异步回调。
**系统能力**以下各项对应的系统能力有所不同,详见下表。 **系统能力**SystemCapability.BarrierFree.Accessibility.Core
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------- | ---- | ---------------------------------------- | | -------- | ----------------------- | ---- | ---------------------------------------- |
| type | string | | 取消监听的事件名,固定为‘accessibilityStateChange’,即辅助应用启用状态变化事件。 | | type | string | | 取消监听的事件名,固定为‘accessibilityStateChange’,即辅助应用启用状态变化事件。 |
| callback | Callback&lt;boolean&gt; | 否 | 回调函数,取消指定callback对象的事件响应。 | | callback | Callback&lt;boolean&gt; | 否 | 回调函数,取消指定callback对象的事件响应。 |
**示例:** **示例:**
...@@ -654,13 +662,13 @@ off(type: 'touchGuideStateChange', callback?: Callback&lt;boolean&gt;): void ...@@ -654,13 +662,13 @@ off(type: 'touchGuideStateChange', callback?: Callback&lt;boolean&gt;): void
取消监听触摸浏览启用状态变化事件,使用callback异步回调。 取消监听触摸浏览启用状态变化事件,使用callback异步回调。
**系统能力**以下各项对应的系统能力有所不同,详见下表。 **系统能力**SystemCapability.BarrierFree.Accessibility.Core
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------- | ---- | ---------------------------------------- | | -------- | ----------------------- | ---- | ---------------------------------------- |
| type | string | | 取消监听的事件名,固定为‘touchGuideStateChange’,即触摸浏览启用状态变化事件。 | | type | string | | 取消监听的事件名,固定为‘touchGuideStateChange’,即触摸浏览启用状态变化事件。 |
| callback | Callback&lt;boolean&gt; | 否 | 回调函数,取消指定callback对象的事件响应。 | | callback | Callback&lt;boolean&gt; | 否 | 回调函数,取消指定callback对象的事件响应。 |
**示例:** **示例:**
......
# @ohos.app.ability.DriverExtensionAbility (DriverExtensionAbility)
DriverExtensionAbility模块提供驱动相关扩展能力,提供驱动创建、销毁、连接、断开等生命周期回调。
> **说明:**
>
> 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> 本模块接口仅可在Stage模型下使用。
## 导入模块
```ts
import DriverExtension from '@ohos.app.ability.DriverExtensionAbility';
```
## 权限
## 属性
**系统能力**:SystemCapability.Driver.ExternalDevice
**系统API**: 此接口为系统接口,三方应用不支持调用。
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| context | [DriverExtensionContext](js-apis-inner-application-driverExtensionContext.md) | 是 | 否 | DriverExtension的上下文环境,继承自ExtensionContext。 |
## DriverExtensionAbility.onInit
onInit(want: Want): void;
Extension生命周期回调,在创建时回调,执行初始化业务逻辑操作。
**系统能力**:SystemCapability.Driver.ExternalDevice
**系统API**: 此接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-app-ability-want.md) | 是 | 当前Extension相关的Want类型信息,包括ability名称、bundle名称等。 |
**示例:**
```ts
class DriverExt extends DriverExtension {
onInit(want) {
console.log('onInit, want: ${want.abilityName}');
}
}
```
## DriverExtensionAbility.onRelease
onRelease(): void;
Extension生命周期回调,在销毁时回调,执行资源清理等操作。
**系统能力**:SystemCapability.Driver.ExternalDevice
**系统API**: 此接口为系统接口,三方应用不支持调用。
**示例:**
```ts
class DriverExt extends DriverExtension {
onRelease() {
console.log('onRelease');
}
}
```
## DriverExtensionAbility.onConnect
onConnect(want: Want): rpc.RemoteObject | Promise<rpc.RemoteObject>;
Extension生命周期回调,如果是connectAbility拉起的服务,会在onCreate之后回调。返回一个RemoteObject对象,用于客户端和服务端进行通信。
**系统能力**:SystemCapability.Driver.ExternalDevice
**系统API**: 此接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-app-ability-want.md)| 是 | 当前Extension相关的Want类型信息,包括ability名称、bundle名称等。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| rpc.RemoteObject | 一个RemoteObject对象,用于客户端和服务端进行通信。 |
**示例:**
```ts
import rpc from '@ohos.rpc';
class StubTest extends rpc.RemoteObject{
constructor(des) {
super(des);
}
onRemoteRequest(code, data, reply, option) {
}
}
class DriverExt extends DriverExtension {
onConnect(want) {
console.log('onConnect , want: ${want.abilityName}');
return new StubTest('test');
}
}
```
如果生成返回值RemoteObject依赖一个异步接口,可以使用异步生命周期:
```ts
import rpc from '@ohos.rpc';
class StubTest extends rpc.RemoteObject{
constructor(des) {
super(des);
}
onRemoteRequest(code, data, reply, option) {
}
}
async function getDescriptor() {
// 调用异步函数...
return "asyncTest"
}
class DriverExt extends DriverExtension {
async onConnect(want) {
console.log(`onConnect , want: ${want.abilityName}`);
let descriptor = await getDescriptor();
return new StubTest(descriptor);
}
}
```
## DriverExtensionAbility.onDisconnect
onDisconnect(want: Want): void | Promise\<void>;
Extension的生命周期回调,客户端执行断开连接服务时回调。
**系统能力**:SystemCapability.Driver.ExternalDevice
**系统API**: 此接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| want |[Want](js-apis-app-ability-want.md)| 是 | 当前Extension相关的Want类型信息,包括ability名称、bundle名称等。 |
**示例:**
```ts
class DriverExt extends DriverExtension {
onDisconnect(want) {
console.log('onDisconnect, want: ${want.abilityName}');
}
}
```
在执行完onDisconnect生命周期回调后,应用可能会退出,从而可能导致onDisconnect中的异步函数未能正确执行,比如异步写入数据库。可以使用异步生命周期,以确保异步onDisconnect完成后再继续后续的生命周期。
```ts
class DriverExt extends DriverExtension {
async onDisconnect(want) {
console.log('onDisconnect, want: ${want.abilityName}');
// 调用异步函数...
}
}
```
## DriverExtensionAbility.onDump
onDump(params: Array\<string>): Array\<string>;
转储客户端信息时调用。
**系统能力**:SystemCapability.Driver.ExternalDevice
**系统API**: 此接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| params | Array\<string> | 是 | 表示命令形式的参数。|
**示例:**
```ts
class DriverExt extends DriverExtension {
onDump(params) {
console.log('dump, params: ${JSON.stringify(params)}');
return ['params'];
}
}
```
...@@ -34,4 +34,5 @@ ...@@ -34,4 +34,5 @@
| metaData<sup>8+</sup> | Map\<string, Array\<[CustomizeData](js-apis-bundle-CustomizeData.md)>> | 是 | 否 | 应用程序的自定义元信息。<br />通过调用[bundle.getApplicationInfo](js-apis-Bundle.md#bundlegetapplicationinfodeprecated)接口时,传入GET_APPLICATION_INFO_WITH_METADATA获取。 | | metaData<sup>8+</sup> | Map\<string, Array\<[CustomizeData](js-apis-bundle-CustomizeData.md)>> | 是 | 否 | 应用程序的自定义元信息。<br />通过调用[bundle.getApplicationInfo](js-apis-Bundle.md#bundlegetapplicationinfodeprecated)接口时,传入GET_APPLICATION_INFO_WITH_METADATA获取。 |
| removable<sup>8+</sup> | boolean | 是 | 否 | 应用程序是否可以被移除。 | | removable<sup>8+</sup> | boolean | 是 | 否 | 应用程序是否可以被移除。 |
| accessTokenId<sup>8+</sup> | number | 是 | 否 | 应用程序的accessTokenId。 | | accessTokenId<sup>8+</sup> | number | 是 | 否 | 应用程序的accessTokenId。 |
| uid<sup>8+</sup> | number | 是 | 否 | 应用程序的uid。 | | uid<sup>8+</sup> | number | 是 | 否 | 应用程序的uid。 |
\ No newline at end of file | entityType | string | 是 | 否 | 应用程序的类别,例如游戏、社交、影视、新闻。 |
\ No newline at end of file
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
## ApplicationInfo ## ApplicationInfo
**系统能力**: 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core **系统能力**: 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| -------------------------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------------------------------------ | | -------------------------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------------------------------------ |
| name | string | 是 | 否 | 应用程序的名称。 | | name | string | 是 | 否 | 应用程序的名称。 |
......
...@@ -3592,13 +3592,15 @@ setAudioDevice\(device: AudioDevice, callback: AsyncCallback\<void\>\): void ...@@ -3592,13 +3592,15 @@ setAudioDevice\(device: AudioDevice, callback: AsyncCallback\<void\>\): void
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
**需要权限**:ohos.permission.SET_TELEPHONY_STATE
**系统能力**:SystemCapability.Telephony.CallManager **系统能力**:SystemCapability.Telephony.CallManager
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------- | ---- | ---------- | | -------- | ---------------------------- | ---- | ---------- |
| device | [AudioDevice](#audiodevice10) | 是 | 音频设备。 | | device | [AudioDevice](#audiodevice10)| 是 | 音频设备。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
**错误码:** **错误码:**
...@@ -3607,6 +3609,7 @@ setAudioDevice\(device: AudioDevice, callback: AsyncCallback\<void\>\): void ...@@ -3607,6 +3609,7 @@ setAudioDevice\(device: AudioDevice, callback: AsyncCallback\<void\>\): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 202 | Non-system applications use system APIs. | | 202 | Non-system applications use system APIs. |
| 401 | Parameter error. | | 401 | Parameter error. |
| 8300001 | Invalid parameter value. | | 8300001 | Invalid parameter value. |
...@@ -3641,103 +3644,13 @@ setAudioDevice\(device: AudioDevice): Promise\<void\> ...@@ -3641,103 +3644,13 @@ setAudioDevice\(device: AudioDevice): Promise\<void\>
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------- | ---- | ---------- | | -------- | ---------------------------- | ---- | ---------- |
| device | [AudioDevice](#audiodevice10) | 是 | 音频设备。 | | device | [AudioDevice](#audiodevice10)| 是 | 音频设备。 |
**错误码:**
以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 202 | Non-system applications use system APIs. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**示例:**
```js
let audioDevice={
deviceType: 1
}
call.setAudioDevice(audioDevice).then(() => {
console.log(`setAudioDevice success.`);
}).catch((err) => {
console.error(`setAudioDevice fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.setAudioDevice<sup>9+</sup>
setAudioDevice\(device: AudioDevice, options: AudioDeviceOptions, callback: AsyncCallback\<void\>\): void
设置通话音频设备。使用callback异步回调。
**系统接口:** 此接口为系统接口。
**系统能力**:SystemCapability.Telephony.CallManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------ | ---- | -------------- |
| device | [AudioDevice](#audiodevice10) | 是 | 音频设备。 |
| options | [AudioDeviceOptions](#audiodeviceoptions9) | 是 | 音频设备参数。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
**错误码:**
以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------------- |
| 202 | Non-system applications use system APIs. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**示例:**
```js
let audioDevice={
deviceType: 1
}
let audioDeviceOptions={
bluetoothAddress: "IEEE 802-2014"
}
call.setAudioDevice(audioDevice, audioDeviceOptions, (err) => {
console.log(`callback: err->${JSON.stringify(err)}`);
});
```
## call.setAudioDevice<sup>9+</sup>
setAudioDevice\(device: AudioDevice, options?: AudioDeviceOptions\): Promise\<void\>
设置通话音频设备。使用Promise异步回调。
**系统接口:** 此接口为系统接口。
**系统能力**:SystemCapability.Telephony.CallManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------------------------------ | ---- | ------------------ |
| device | [AudioDevice](#audiodevice10) | 是 | 音频设备。 |
| options | [AudioDeviceOptions](#audiodeviceoptions9) | 否 | 音频设备参数参数。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------------------- | ------------------------------- | | ------------------- | --------------------------- |
| Promise&lt;void&gt; | 以Promise形式异步返回设置结果。 | | Promise&lt;void&gt; | 以Promise形式异步返回结果。 |
**错误码:** **错误码:**
...@@ -3745,6 +3658,7 @@ setAudioDevice\(device: AudioDevice, options?: AudioDeviceOptions\): Promise\<vo ...@@ -3745,6 +3658,7 @@ setAudioDevice\(device: AudioDevice, options?: AudioDeviceOptions\): Promise\<vo
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 202 | Non-system applications use system APIs. | | 202 | Non-system applications use system APIs. |
| 401 | Parameter error. | | 401 | Parameter error. |
| 8300001 | Invalid parameter value. | | 8300001 | Invalid parameter value. |
...@@ -3758,10 +3672,7 @@ setAudioDevice\(device: AudioDevice, options?: AudioDeviceOptions\): Promise\<vo ...@@ -3758,10 +3672,7 @@ setAudioDevice\(device: AudioDevice, options?: AudioDeviceOptions\): Promise\<vo
let audioDevice={ let audioDevice={
deviceType: 1 deviceType: 1
} }
let audioDeviceOptions={ call.setAudioDevice(audioDevice).then(() => {
bluetoothAddress: "IEEE 802-2014"
}
call.setAudioDevice(audioDevice, audioDeviceOptions).then(() => {
console.log(`setAudioDevice success.`); console.log(`setAudioDevice success.`);
}).catch((err) => { }).catch((err) => {
console.error(`setAudioDevice fail, promise: err->${JSON.stringify(err)}`); console.error(`setAudioDevice fail, promise: err->${JSON.stringify(err)}`);
...@@ -4773,8 +4684,8 @@ IP多媒体系统调用模式。 ...@@ -4773,8 +4684,8 @@ IP多媒体系统调用模式。
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| --------------------------------- | ------------------------------------- | ---- | ---------------- | | --------------------------------- | ------------------------------------- | ---- | ---------------- |
| deviceType <sup>10+</sup> | [AudioDeviceType](#audiodevicetype10) | 是 | 音频设备类型。 | | deviceType <sup>10+</sup> | [AudioDeviceType](#audiodevicetype10) | 是 | 音频设备类型。 |
| address <sup>10+</sup> | string | 否 | 音频设备地址。 | | address <sup>10+</sup> | string | 否 | 音频设备地址。 |
## AudioDeviceType<sup>10+</sup> ## AudioDeviceType<sup>10+</sup>
...@@ -4802,7 +4713,7 @@ IP多媒体系统调用模式。 ...@@ -4802,7 +4713,7 @@ IP多媒体系统调用模式。
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| --------------------------------- | ------------------------------------- | ---- | ---------------- | | --------------------------------- | ------------------------------------- | ---- | ---------------- |
| audioDeviceList <sup>10+</sup> | [Array\<AudioDevice\>](#audiodevice10) | 是 | 音频设备列表。 | | audioDeviceList <sup>10+</sup> | [Array\<AudioDevice\>](#audiodevice10) | 是 | 音频设备列表。 |
| currentAudioDevice <sup>10+</sup> | [AudioDevice](#audiodevice10) | 是 | 音频设备类型。 | | currentAudioDevice <sup>10+</sup> | [AudioDevice](#audiodevice10) | 是 | 当前音频设备。 |
| isMuted <sup>10+</sup> | boolean | 是 | 是否静音。 | | isMuted <sup>10+</sup> | boolean | 是 | 是否静音。 |
......
...@@ -125,8 +125,8 @@ createDeviceManager(bundleName: string, callback: AsyncCallback&lt;DeviceManager ...@@ -125,8 +125,8 @@ createDeviceManager(bundleName: string, callback: AsyncCallback&lt;DeviceManager
| mode | [DiscoverMode ](#discovermode) | 是 | 发现模式。 | | mode | [DiscoverMode ](#discovermode) | 是 | 发现模式。 |
| medium | [ExchangeMedium](#exchangemedium) | 是 | 发现类型。 | | medium | [ExchangeMedium](#exchangemedium) | 是 | 发现类型。 |
| freq | [ExchangeFreq](#exchangefreq) | 是 | 发现频率。 | | freq | [ExchangeFreq](#exchangefreq) | 是 | 发现频率。 |
| isSameAccount | boolean | | 是否同帐号。 | | isSameAccount | boolean | | 是否同帐号。 |
| isWakeRemote | boolean | | 是否唤醒设备。 | | isWakeRemote | boolean | | 是否唤醒设备。 |
| capability | [SubscribeCap](#subscribecap) | 是 | 发现能力。 | | capability | [SubscribeCap](#subscribecap) | 是 | 发现能力。 |
......
...@@ -241,6 +241,14 @@ getFocusElement(isAccessibilityFocus: boolean, callback: AsyncCallback\<Accessib ...@@ -241,6 +241,14 @@ getFocusElement(isAccessibilityFocus: boolean, callback: AsyncCallback\<Accessib
| isAccessibilityFocus | boolean | 是 | 获取的是否是无障碍焦点元素。 | | isAccessibilityFocus | boolean | 是 | 获取的是否是无障碍焦点元素。 |
| callback | AsyncCallback&lt;AccessibilityElement&gt; | 是 | 回调函数,返回当前对应的焦点元素。 | | callback | AsyncCallback&lt;AccessibilityElement&gt; | 是 | 回调函数,返回当前对应的焦点元素。 |
**错误码:**
以下错误码的详细介绍请参见[无障碍子系统错误码](../errorcodes/errorcode-accessibility.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------- |
| 9300003 | Do not have accessibility right for this operation. |
**示例:** **示例:**
```ts ```ts
......
# DriverExtensionContext
DriverExtensionContext模块是DriverExtensionAbility的上下文环境,继承自ExtensionContext。
DriverExtensionContext模块提供DriverExtensionAbility实现中需要主动发起的操作。
> **说明:**
>
> - 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> - 本模块接口仅可在Stage模型下使用。
## 导入模块
```ts
import common from '@ohos.app.ability.common';
```
## 使用说明
在使用DriverExtensionContext的功能前,需要通过DriverExtensionAbility子类实例获取。
```ts
import DriverExtensionAbility from '@ohos.app.ability.DriverExtensionAbility';
let context;
class EntryAbility extends DriverExtensionAbility {
onInit() {
context = this.context; // 获取DriverExtensionContext
}
}
```
## DriverExtensionContext.updateDriverState
updateDriverState(): void;
驱动状态上报。预留接口,暂不提供具体功能。
**系统能力**:SystemCapability.Driver.ExternalDevice
**示例:**
```ts
this.context.updateDriverState() ;
```
...@@ -25,7 +25,7 @@ import sensor from '@system.sensor'; ...@@ -25,7 +25,7 @@ import sensor from '@system.sensor';
观察加速度数据变化。针对同一个应用,多次点击调用时,会覆盖前面的调用效果,即仅最后一次调用生效。 观察加速度数据变化。针对同一个应用,多次点击调用时,会覆盖前面的调用效果,即仅最后一次调用生效。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
**需要权限**:ohos.permission.ACCELEROMETER,该权限为系统权限 **需要权限**:ohos.permission.ACCELEROMETER,该权限为系统权限
...@@ -60,7 +60,7 @@ unsubscribeAccelerometer(): void ...@@ -60,7 +60,7 @@ unsubscribeAccelerometer(): void
取消订阅加速度数据。 取消订阅加速度数据。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
**需要权限**:ohos.permission.ACCELEROMETER,该权限为系统权限 **需要权限**:ohos.permission.ACCELEROMETER,该权限为系统权限
...@@ -76,7 +76,7 @@ sensor.unsubscribeAccelerometer(); ...@@ -76,7 +76,7 @@ sensor.unsubscribeAccelerometer();
订阅罗盘数据变化。针对同一个应用,多次点击调用时,会覆盖前面的调用效果,即仅最后一次调用生效。 订阅罗盘数据变化。针对同一个应用,多次点击调用时,会覆盖前面的调用效果,即仅最后一次调用生效。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
**参数:** **参数:**
...@@ -106,7 +106,7 @@ unsubscribeCompass(): void ...@@ -106,7 +106,7 @@ unsubscribeCompass(): void
取消订阅罗盘。 取消订阅罗盘。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
**示例:** **示例:**
...@@ -120,7 +120,7 @@ sensor.unsubscribeCompass(); ...@@ -120,7 +120,7 @@ sensor.unsubscribeCompass();
订阅距离感应数据变化。针对同一个应用,多次点击调用时,会覆盖前面的调用效果,即仅最后一次调用生效。 订阅距离感应数据变化。针对同一个应用,多次点击调用时,会覆盖前面的调用效果,即仅最后一次调用生效。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
**参数:** **参数:**
...@@ -150,7 +150,7 @@ unsubscribeProximity(): void ...@@ -150,7 +150,7 @@ unsubscribeProximity(): void
取消订阅距离感应。 取消订阅距离感应。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
**示例:** **示例:**
...@@ -164,7 +164,7 @@ sensor.unsubscribeProximity(); ...@@ -164,7 +164,7 @@ sensor.unsubscribeProximity();
订阅环境光线感应数据变化。再次调用时,会覆盖前一次调用效果,即仅最后一次调用生效。 订阅环境光线感应数据变化。再次调用时,会覆盖前一次调用效果,即仅最后一次调用生效。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
**参数:** **参数:**
...@@ -194,7 +194,7 @@ unsubscribeLight(): void ...@@ -194,7 +194,7 @@ unsubscribeLight(): void
取消订阅环境光线感应。 取消订阅环境光线感应。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
**示例:** **示例:**
...@@ -208,7 +208,7 @@ sensor.unsubscribeLight(); ...@@ -208,7 +208,7 @@ sensor.unsubscribeLight();
订阅计步传感器数据变化。针对同一个应用,多次点击调用时,会覆盖前面的调用效果,即仅最后一次调用生效。 订阅计步传感器数据变化。针对同一个应用,多次点击调用时,会覆盖前面的调用效果,即仅最后一次调用生效。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
**需要权限**:ohos.permission.ACTIVITY_MOTION **需要权限**:ohos.permission.ACTIVITY_MOTION
...@@ -240,7 +240,7 @@ unsubscribeStepCounter(): void ...@@ -240,7 +240,7 @@ unsubscribeStepCounter(): void
取消订阅计步传感器。 取消订阅计步传感器。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
**需要权限**:ohos.permission.ACTIVITY_MOTION **需要权限**:ohos.permission.ACTIVITY_MOTION
...@@ -257,7 +257,7 @@ subscribeBarometer(options: SubscribeBarometerOptions): void ...@@ -257,7 +257,7 @@ subscribeBarometer(options: SubscribeBarometerOptions): void
订阅气压计传感器数据变化。针对同一个应用,多次点击调用时,会覆盖前面的调用效果,即仅最后一次调用生效。 订阅气压计传感器数据变化。针对同一个应用,多次点击调用时,会覆盖前面的调用效果,即仅最后一次调用生效。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
**参数:** **参数:**
...@@ -288,7 +288,7 @@ unsubscribeBarometer(): void ...@@ -288,7 +288,7 @@ unsubscribeBarometer(): void
取消订阅气压计传感器。 取消订阅气压计传感器。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
**示例:** **示例:**
...@@ -303,7 +303,7 @@ sensor.unsubscribeBarometer(); ...@@ -303,7 +303,7 @@ sensor.unsubscribeBarometer();
订阅心率传感器数据变化。针对同一个应用,多次点击调用时,会覆盖前面的调用效果,即仅最后一次调用生效。 订阅心率传感器数据变化。针对同一个应用,多次点击调用时,会覆盖前面的调用效果,即仅最后一次调用生效。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
**需要权限**:ohos.permission.READ_HEALTH_DATA **需要权限**:ohos.permission.READ_HEALTH_DATA
...@@ -336,7 +336,7 @@ unsubscribeHeartRate(): void ...@@ -336,7 +336,7 @@ unsubscribeHeartRate(): void
取消订阅心率传感器。 取消订阅心率传感器。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
**需要权限**:ohos.permission.READ_HEALTH_DATA **需要权限**:ohos.permission.READ_HEALTH_DATA
...@@ -352,7 +352,7 @@ sensor.unsubscribeHeartRate(); ...@@ -352,7 +352,7 @@ sensor.unsubscribeHeartRate();
订阅设备佩戴状态。针对同一个应用,多次点击调用时,会覆盖前面的调用效果,即仅最后一次调用生效。 订阅设备佩戴状态。针对同一个应用,多次点击调用时,会覆盖前面的调用效果,即仅最后一次调用生效。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
**参数:** **参数:**
...@@ -382,7 +382,7 @@ unsubscribeOnBodyState(): void ...@@ -382,7 +382,7 @@ unsubscribeOnBodyState(): void
取消订阅设备佩戴状态。 取消订阅设备佩戴状态。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
**示例:** **示例:**
...@@ -396,7 +396,7 @@ sensor.unsubscribeOnBodyState(); ...@@ -396,7 +396,7 @@ sensor.unsubscribeOnBodyState();
获取设备佩戴状态。 获取设备佩戴状态。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
**参数:** **参数:**
...@@ -425,7 +425,7 @@ sensor.getOnBodyState({ ...@@ -425,7 +425,7 @@ sensor.getOnBodyState({
针对同一个应用,多次点击调用时,会覆盖前面的调用效果,即仅最后一次调用生效;针对同一个方法内,不支持多次调用。 针对同一个应用,多次点击调用时,会覆盖前面的调用效果,即仅最后一次调用生效;针对同一个方法内,不支持多次调用。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
**参数:** **参数:**
...@@ -458,7 +458,7 @@ unsubscribeDeviceOrientation(): void ...@@ -458,7 +458,7 @@ unsubscribeDeviceOrientation(): void
取消订阅设备方向传感器数据。 取消订阅设备方向传感器数据。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
**示例:** **示例:**
...@@ -474,7 +474,7 @@ sensor.unsubscribeDeviceOrientation(); ...@@ -474,7 +474,7 @@ sensor.unsubscribeDeviceOrientation();
针对同一个应用,多次点击调用时,会覆盖前面的调用效果,即仅最后一次调用生效;针对同一个方法内,不支持多次调用。 针对同一个应用,多次点击调用时,会覆盖前面的调用效果,即仅最后一次调用生效;针对同一个方法内,不支持多次调用。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
**需要权限**:ohos.permission.GYROSCOPE,该权限为系统权限 **需要权限**:ohos.permission.GYROSCOPE,该权限为系统权限
...@@ -509,7 +509,7 @@ unsubscribeGyroscope(): void ...@@ -509,7 +509,7 @@ unsubscribeGyroscope(): void
取消订阅陀螺仪传感器数据。 取消订阅陀螺仪传感器数据。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
**需要权限**:ohos.permission.GYROSCOPE,该权限为系统权限 **需要权限**:ohos.permission.GYROSCOPE,该权限为系统权限
...@@ -525,7 +525,7 @@ sensor.unsubscribeGyroscope(); ...@@ -525,7 +525,7 @@ sensor.unsubscribeGyroscope();
**需要权限**:ohos.permission.ACCELEROMETER **需要权限**:ohos.permission.ACCELEROMETER
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
...@@ -539,7 +539,7 @@ sensor.unsubscribeGyroscope(); ...@@ -539,7 +539,7 @@ sensor.unsubscribeGyroscope();
**需要权限**:ohos.permission.ACCELEROMETER **需要权限**:ohos.permission.ACCELEROMETER
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ------------- | | ---- | ------ | ---- | ------------- |
...@@ -551,7 +551,7 @@ sensor.unsubscribeGyroscope(); ...@@ -551,7 +551,7 @@ sensor.unsubscribeGyroscope();
当罗盘传感器数据发生变化时调用。 当罗盘传感器数据发生变化时调用。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| ------- | ----------------------------------- | ---- | ------------------------------ | | ------- | ----------------------------------- | ---- | ------------------------------ |
...@@ -562,7 +562,7 @@ sensor.unsubscribeGyroscope(); ...@@ -562,7 +562,7 @@ sensor.unsubscribeGyroscope();
罗盘数据改变后触发的回调函数。 罗盘数据改变后触发的回调函数。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| --------- | ------ | ---- | -------------------- | | --------- | ------ | ---- | -------------------- |
...@@ -572,7 +572,7 @@ sensor.unsubscribeGyroscope(); ...@@ -572,7 +572,7 @@ sensor.unsubscribeGyroscope();
当距离传感器数据发生变化时调用。 当距离传感器数据发生变化时调用。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| ------- | --------------------------------------- | ---- | ---------------------------------- | | ------- | --------------------------------------- | ---- | ---------------------------------- |
...@@ -583,7 +583,7 @@ sensor.unsubscribeGyroscope(); ...@@ -583,7 +583,7 @@ sensor.unsubscribeGyroscope();
距离感应数据改变后调用的回调函数。 距离感应数据改变后调用的回调函数。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------ | | -------- | ------ | ---- | ------------------------------------------ |
...@@ -593,7 +593,7 @@ sensor.unsubscribeGyroscope(); ...@@ -593,7 +593,7 @@ sensor.unsubscribeGyroscope();
当环境光传感器数据发生变化时调用。 当环境光传感器数据发生变化时调用。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| ------- | ------------------------------- | ---- | ------------------------------ | | ------- | ------------------------------- | ---- | ------------------------------ |
...@@ -604,7 +604,7 @@ sensor.unsubscribeGyroscope(); ...@@ -604,7 +604,7 @@ sensor.unsubscribeGyroscope();
光线感应数据改变后的回调函数。 光线感应数据改变后的回调函数。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| --------- | ------ | ---- | --------------------- | | --------- | ------ | ---- | --------------------- |
...@@ -616,7 +616,7 @@ sensor.unsubscribeGyroscope(); ...@@ -616,7 +616,7 @@ sensor.unsubscribeGyroscope();
**需要权限**:ohos.permission.ACTIVITY_MOTION **需要权限**:ohos.permission.ACTIVITY_MOTION
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| ------- | ------------------------------------------- | ---- | -------------------------------- | | ------- | ------------------------------------------- | ---- | -------------------------------- |
...@@ -629,7 +629,7 @@ sensor.unsubscribeGyroscope(); ...@@ -629,7 +629,7 @@ sensor.unsubscribeGyroscope();
**需要权限**:ohos.permission.ACTIVITY_MOTION **需要权限**:ohos.permission.ACTIVITY_MOTION
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| ----- | ------ | ---- | -------------------------------- | | ----- | ------ | ---- | -------------------------------- |
...@@ -639,7 +639,7 @@ sensor.unsubscribeGyroscope(); ...@@ -639,7 +639,7 @@ sensor.unsubscribeGyroscope();
当气压计传感器数据发生变化时调用。 当气压计传感器数据发生变化时调用。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| ------- | --------------------------------------- | ---- | -------------------------------- | | ------- | --------------------------------------- | ---- | -------------------------------- |
...@@ -650,7 +650,7 @@ sensor.unsubscribeGyroscope(); ...@@ -650,7 +650,7 @@ sensor.unsubscribeGyroscope();
气压计传感器数据改变后的回调函数。 气压计传感器数据改变后的回调函数。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ---------------------- | | -------- | ------ | ---- | ---------------------- |
...@@ -662,7 +662,7 @@ sensor.unsubscribeGyroscope(); ...@@ -662,7 +662,7 @@ sensor.unsubscribeGyroscope();
**需要权限**:ohos.permission.READ_HEALTH_DATA **需要权限**:ohos.permission.READ_HEALTH_DATA
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| ------- | --------------------------------------- | ---- | ----------------------------------------------- | | ------- | --------------------------------------- | ---- | ----------------------------------------------- |
...@@ -675,7 +675,7 @@ sensor.unsubscribeGyroscope(); ...@@ -675,7 +675,7 @@ sensor.unsubscribeGyroscope();
**需要权限**:ohos.permission.READ_HEALTH_DATA **需要权限**:ohos.permission.READ_HEALTH_DATA
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| --------- | ------ | ---- | -------- | | --------- | ------ | ---- | -------- |
...@@ -685,7 +685,7 @@ sensor.unsubscribeGyroscope(); ...@@ -685,7 +685,7 @@ sensor.unsubscribeGyroscope();
当穿着状态改变时调用。 当穿着状态改变时调用。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| ------- | ------------------------------------------- | ---- | -------------------------- | | ------- | ------------------------------------------- | ---- | -------------------------- |
...@@ -696,7 +696,7 @@ sensor.unsubscribeGyroscope(); ...@@ -696,7 +696,7 @@ sensor.unsubscribeGyroscope();
传感器是否磨损。 传感器是否磨损。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| ----- | ------- | ---- | ------------ | | ----- | ------- | ---- | ------------ |
...@@ -706,7 +706,7 @@ sensor.unsubscribeGyroscope(); ...@@ -706,7 +706,7 @@ sensor.unsubscribeGyroscope();
获取传感器磨损状态时调用。 获取传感器磨损状态时调用。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------- | ---- | ------------------------ | | -------- | ------------------------------------------- | ---- | ------------------------ |
...@@ -718,7 +718,7 @@ sensor.unsubscribeGyroscope(); ...@@ -718,7 +718,7 @@ sensor.unsubscribeGyroscope();
用于监听设备方向传感器数据的回调函数的执行频率。 用于监听设备方向传感器数据的回调函数的执行频率。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
...@@ -730,7 +730,7 @@ sensor.unsubscribeGyroscope(); ...@@ -730,7 +730,7 @@ sensor.unsubscribeGyroscope();
感应到设备方向传感器数据变化后的回调函数。 感应到设备方向传感器数据变化后的回调函数。
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| ----- | ------ | ---- | ------------------------------------------------------------ | | ----- | ------ | ---- | ------------------------------------------------------------ |
...@@ -744,7 +744,7 @@ sensor.unsubscribeGyroscope(); ...@@ -744,7 +744,7 @@ sensor.unsubscribeGyroscope();
**需要权限**:ohos.permission.GYROSCOPE **需要权限**:ohos.permission.GYROSCOPE
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
...@@ -758,7 +758,7 @@ sensor.unsubscribeGyroscope(); ...@@ -758,7 +758,7 @@ sensor.unsubscribeGyroscope();
**需要权限**:ohos.permission.GYROSCOPE **需要权限**:ohos.permission.GYROSCOPE
**系统能力**:SystemCapability.Sensors.Sensor **系统能力**:SystemCapability.Sensors.Sensor.Lite
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ----------------- | | ---- | ------ | ---- | ----------------- |
......
...@@ -20,7 +20,7 @@ get(options: GetStorageOptions): void ...@@ -20,7 +20,7 @@ get(options: GetStorageOptions): void
通过索引读取缓存中存储的值。 通过索引读取缓存中存储的值。
**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **系统能力:** SystemCapability.DistributedDataManager.Preferences.Core.Lite
**参数:** **参数:**
...@@ -55,7 +55,7 @@ set(options: SetStorageOptions): void ...@@ -55,7 +55,7 @@ set(options: SetStorageOptions): void
修改缓存中索引对应的值。 修改缓存中索引对应的值。
**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **系统能力:** SystemCapability.DistributedDataManager.Preferences.Core.Lite
**参数:** **参数:**
...@@ -88,7 +88,7 @@ clear(options?: ClearStorageOptions): void ...@@ -88,7 +88,7 @@ clear(options?: ClearStorageOptions): void
清空缓存中存储的键值对。 清空缓存中存储的键值对。
**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **系统能力:** SystemCapability.DistributedDataManager.Preferences.Core.Lite
**参数:** **参数:**
...@@ -119,7 +119,7 @@ delete(options: DeleteStorageOptions): void ...@@ -119,7 +119,7 @@ delete(options: DeleteStorageOptions): void
删除缓存中索引对应的键值对。 删除缓存中索引对应的键值对。
**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **系统能力:** SystemCapability.DistributedDataManager.Preferences.Core.Lite
**参数:** **参数:**
...@@ -147,7 +147,7 @@ export default { ...@@ -147,7 +147,7 @@ export default {
## GetStorageOptions ## GetStorageOptions
**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **系统能力:** SystemCapability.DistributedDataManager.Preferences.Core.Lite
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| -------- | ---------------- | ---- | ------------------- | | -------- | ---------------- | ---- | ------------------- |
...@@ -160,7 +160,7 @@ export default { ...@@ -160,7 +160,7 @@ export default {
## SetStorageOptions ## SetStorageOptions
**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **系统能力:** SystemCapability.DistributedDataManager.Preferences.Core.Lite
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| -------- | ------------------- | ---- | -------------------- | | -------- | ------------------- | ---- | -------------------- |
...@@ -173,7 +173,7 @@ export default { ...@@ -173,7 +173,7 @@ export default {
## ClearStorageOptions ## ClearStorageOptions
**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **系统能力:** SystemCapability.DistributedDataManager.Preferences.Core.Lite
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | -------------------- | | -------- | --------------------- | ---- | -------------------- |
...@@ -184,7 +184,7 @@ export default { ...@@ -184,7 +184,7 @@ export default {
## DeleteStorageOptions ## DeleteStorageOptions
**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **系统能力:** SystemCapability.DistributedDataManager.Preferences.Core.Lite
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ------------------ | | -------- | -------------------- | ---- | ------------------ |
......
...@@ -26,7 +26,7 @@ import vibrator from '@system.vibrator'; ...@@ -26,7 +26,7 @@ import vibrator from '@system.vibrator';
**需要权限**:ohos.permission.VIBRATE **需要权限**:ohos.permission.VIBRATE
**系统能力**:SystemCapability.Sensors.MiscDevice **系统能力**:SystemCapability.Sensors.MiscDevice.Lite
**参数:** **参数:**
...@@ -57,7 +57,7 @@ vibrator.vibrate({ ...@@ -57,7 +57,7 @@ vibrator.vibrate({
**需要权限**:ohos.permission.VIBRATE **需要权限**:ohos.permission.VIBRATE
**系统能力**:SystemCapability.Sensors.MiscDevice **系统能力**:SystemCapability.Sensors.MiscDevice.Lite
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| -------- | -------- | ---- | ------------------------------------------------------------ | | -------- | -------- | ---- | ------------------------------------------------------------ |
......
...@@ -39,7 +39,7 @@ AlphabetIndexer(value: {arrayValue: Array&lt;string&gt;, selected: number}) ...@@ -39,7 +39,7 @@ AlphabetIndexer(value: {arrayValue: Array&lt;string&gt;, selected: number})
| popupFont | [Font](ts-types.md#font) | 设置提示弹窗字体样式。<br/>默认值:<br/>{<br/>size:10,<br/> style:FontStyle.Normal,<br/> weight:FontWeight.Normal,<br/> family:'HarmonyOS Sans'<br/>} | | popupFont | [Font](ts-types.md#font) | 设置提示弹窗字体样式。<br/>默认值:<br/>{<br/>size:10,<br/> style:FontStyle.Normal,<br/> weight:FontWeight.Normal,<br/> family:'HarmonyOS Sans'<br/>} |
| font | [Font](ts-types.md#font) | 设置字母索引条默认字体样式。<br/>默认值:<br/>{<br/>size:10,<br/> style:FontStyle.Normal,<br/> weight:FontWeight.Normal,<br/> family:'HarmonyOS Sans'<br/>} | | font | [Font](ts-types.md#font) | 设置字母索引条默认字体样式。<br/>默认值:<br/>{<br/>size:10,<br/> style:FontStyle.Normal,<br/> weight:FontWeight.Normal,<br/> family:'HarmonyOS Sans'<br/>} |
| itemSize | string&nbsp;\|&nbsp;number | 设置字母索引条字母区域大小,字母区域为正方形,即正方形边长。不支持设置为百分比。<br/>默认值:24.0<br/>单位:vp | | itemSize | string&nbsp;\|&nbsp;number | 设置字母索引条字母区域大小,字母区域为正方形,即正方形边长。不支持设置为百分比。<br/>默认值:24.0<br/>单位:vp |
| alignStyle | value: [IndexerAlign](#indexeralign枚举说明),<br/>offset<sup>10+</sup>?: [Length](ts-types.md#length) | value:设置字母索引条弹框的对齐样式,支持弹窗显示在索引条右侧和左侧。<br/>默认值: IndexerAlign.Right。<br/>offset:设置提示弹窗与索引条之间间距,大于等于0为有效值,在不设置或设置为小于0的情况下间距与popupPosition.x相同。 | | alignStyle | value: [IndexerAlign](#indexeralign枚举说明),<br/>offset<sup>10+</sup>?: [Length](ts-types.md#length) | value:设置字母索引条弹框的对齐样式,支持弹窗显示在索引条右侧和左侧。<br/>默认值: IndexerAlign.Right。<br/>offset:设置提示弹窗与索引条之间间距,大于等于0为有效值,在不设置或设置为小于0的情况下间距与popupPosition.x相同。与popupPosition同时设置时,水平方向上offset生效,竖直方向上popupPosition.y生效。 |
| selected | number | 设置选中项索引值。<br/>默认值:0。<br />从API version 10开始,该参数支持[$$](../../quick-start/arkts-two-way-sync.md)双向绑定变量。 | | selected | number | 设置选中项索引值。<br/>默认值:0。<br />从API version 10开始,该参数支持[$$](../../quick-start/arkts-two-way-sync.md)双向绑定变量。 |
| popupPosition | [Position](ts-types.md#position8) | 设置弹出窗口相对于索引器条上边框中点的位置。<br/>默认值:{x:96.0, y:48.0}。 | | popupPosition | [Position](ts-types.md#position8) | 设置弹出窗口相对于索引器条上边框中点的位置。<br/>默认值:{x:96.0, y:48.0}。 |
| popupSelectedColor<sup>10+</sup> | [ResourceColor](ts-types.md#resourcecolor) | 设置提示弹窗非字母部分选中文字色。 <br/>默认值:#FF182431 | | popupSelectedColor<sup>10+</sup> | [ResourceColor](ts-types.md#resourcecolor) | 设置提示弹窗非字母部分选中文字色。 <br/>默认值:#FF182431 |
......
...@@ -60,6 +60,7 @@ Grid(scroller?: Scroller) ...@@ -60,6 +60,7 @@ Grid(scroller?: Scroller)
| multiSelectable<sup>8+</sup> | boolean | 是否开启鼠标框选。<br/>默认值:false<br/>-&nbsp;false:关闭框选。<br/>-&nbsp;true:开启框选。 | | multiSelectable<sup>8+</sup> | boolean | 是否开启鼠标框选。<br/>默认值:false<br/>-&nbsp;false:关闭框选。<br/>-&nbsp;true:开启框选。 |
| supportAnimation<sup>8+</sup> | boolean | 是否支持动画。当前支持GridItem拖拽动画。<br/>默认值:false | | supportAnimation<sup>8+</sup> | boolean | 是否支持动画。当前支持GridItem拖拽动画。<br/>默认值:false |
| edgeEffect<sup>10+</sup> | [EdgeEffect](ts-appendix-enums.md#edgeeffect) | 设置组件的滑动效果,支持弹簧效果和阴影效果。<br/>默认值:EdgeEffect.None<br/> | | edgeEffect<sup>10+</sup> | [EdgeEffect](ts-appendix-enums.md#edgeeffect) | 设置组件的滑动效果,支持弹簧效果和阴影效果。<br/>默认值:EdgeEffect.None<br/> |
| enableScrollInteraction<sup>10+</sup> | boolean | 设置是否支持滚动手势,当设置为false时,无法通过手指或者鼠标滚动,但不影响控制器的滚动接口。<br/>默认值:true |
Grid组件根据rowsTemplate、columnsTemplate属性的设置情况,可分为以下三种布局模式: Grid组件根据rowsTemplate、columnsTemplate属性的设置情况,可分为以下三种布局模式:
......
...@@ -63,6 +63,7 @@ List(value?:{space?: number&nbsp;|&nbsp;string, initialIndex?: number, scroller? ...@@ -63,6 +63,7 @@ List(value?:{space?: number&nbsp;|&nbsp;string, initialIndex?: number, scroller?
| lanes<sup>9+</sup> | number \| [LengthConstrain](ts-types.md#lengthconstrain) | 以列模式为例(listDirection为Axis.Vertical):<br/>lanes用于决定List组件在交叉轴方向按几列布局。<br/>默认值:1<br/>规则如下:<br/>-&nbsp;lanes为指定的数量时,根据指定的数量与List组件的交叉轴尺寸除以列数作为列的宽度。<br/>-&nbsp;lanes设置了{minLength,maxLength}时,根据List组件的宽度自适应决定lanes数量(即列数),保证缩放过程中lane的宽度符合{minLength,maxLength}的限制。其中,minLength条件会被优先满足,即优先保证符合ListItem的交叉轴尺寸符合最小限制。<br/>-&nbsp;lanes设置了{minLength,maxLength},如果父组件交叉轴方向尺寸约束为无穷大时,固定按一列排列,列宽度按显示区域内最大的ListItem计算<br/>-&nbsp;ListItemGroup在多列模式下也是独占一行,ListItemGroup中的ListItem按照List组件的lanes属性设置值来布局。<br/>-&nbsp;lanes设置了{minLength,maxLength}时,计算列数会按照ListItemGroup的交叉轴尺寸计算。当ListItemGroup交叉轴尺寸与List交叉轴尺寸不一致时ListItemGroup中的列数与List中的列数可能不一样。<br/>该接口支持在ArkTS卡片中使用。 | | lanes<sup>9+</sup> | number \| [LengthConstrain](ts-types.md#lengthconstrain) | 以列模式为例(listDirection为Axis.Vertical):<br/>lanes用于决定List组件在交叉轴方向按几列布局。<br/>默认值:1<br/>规则如下:<br/>-&nbsp;lanes为指定的数量时,根据指定的数量与List组件的交叉轴尺寸除以列数作为列的宽度。<br/>-&nbsp;lanes设置了{minLength,maxLength}时,根据List组件的宽度自适应决定lanes数量(即列数),保证缩放过程中lane的宽度符合{minLength,maxLength}的限制。其中,minLength条件会被优先满足,即优先保证符合ListItem的交叉轴尺寸符合最小限制。<br/>-&nbsp;lanes设置了{minLength,maxLength},如果父组件交叉轴方向尺寸约束为无穷大时,固定按一列排列,列宽度按显示区域内最大的ListItem计算<br/>-&nbsp;ListItemGroup在多列模式下也是独占一行,ListItemGroup中的ListItem按照List组件的lanes属性设置值来布局。<br/>-&nbsp;lanes设置了{minLength,maxLength}时,计算列数会按照ListItemGroup的交叉轴尺寸计算。当ListItemGroup交叉轴尺寸与List交叉轴尺寸不一致时ListItemGroup中的列数与List中的列数可能不一样。<br/>该接口支持在ArkTS卡片中使用。 |
| alignListItem<sup>9+</sup> | [ListItemAlign](#listitemalign9枚举说明) | List交叉轴方向宽度大于ListItem交叉轴宽度 * lanes时,ListItem在List交叉轴方向的布局方式,默认为首部对齐。<br/>默认值:ListItemAlign.Start<br/>该接口支持在ArkTS卡片中使用。 | | alignListItem<sup>9+</sup> | [ListItemAlign](#listitemalign9枚举说明) | List交叉轴方向宽度大于ListItem交叉轴宽度 * lanes时,ListItem在List交叉轴方向的布局方式,默认为首部对齐。<br/>默认值:ListItemAlign.Start<br/>该接口支持在ArkTS卡片中使用。 |
| sticky<sup>9+</sup> | [StickyStyle](#stickystyle9枚举说明) | 配合[ListItemGroup](ts-container-listitemgroup.md)组件使用,设置ListItemGroup中header和footer是否要吸顶或吸底。<br/>默认值:StickyStyle.None<br/>该接口支持在ArkTS卡片中使用。<br/>**说明:**<br/>sticky属性可以设置为 StickyStyle.Header \| StickyStyle.Footer 以同时支持header吸顶和footer吸底。 | | sticky<sup>9+</sup> | [StickyStyle](#stickystyle9枚举说明) | 配合[ListItemGroup](ts-container-listitemgroup.md)组件使用,设置ListItemGroup中header和footer是否要吸顶或吸底。<br/>默认值:StickyStyle.None<br/>该接口支持在ArkTS卡片中使用。<br/>**说明:**<br/>sticky属性可以设置为 StickyStyle.Header \| StickyStyle.Footer 以同时支持header吸顶和footer吸底。 |
| enableScrollInteraction<sup>10+</sup> | boolean | 设置是否支持滚动手势,当设置为false时,无法通过手指或者鼠标滚动,但不影响控制器的滚动接口。<br/>默认值:true |
## ListItemAlign<sup>9+</sup>枚举说明 ## ListItemAlign<sup>9+</sup>枚举说明
...@@ -303,4 +304,4 @@ struct ListExample{ ...@@ -303,4 +304,4 @@ struct ListExample{
} }
``` ```
![list](figures/list3.gif) ![list](figures/list3.gif)
\ No newline at end of file
...@@ -35,6 +35,7 @@ Scroll(scroller?: Scroller) ...@@ -35,6 +35,7 @@ Scroll(scroller?: Scroller)
| scrollBarColor | string&nbsp;\|&nbsp;number&nbsp;\|&nbsp;[Color](ts-appendix-enums.md#color) | 设置滚动条的颜色。 | | scrollBarColor | string&nbsp;\|&nbsp;number&nbsp;\|&nbsp;[Color](ts-appendix-enums.md#color) | 设置滚动条的颜色。 |
| scrollBarWidth | string&nbsp;\|&nbsp;number | 设置滚动条的宽度,不支持百分比设置。<br/>默认值:4<br/>单位:vp<br/>**说明:** <br/>如果滚动条的宽度超过其高度,则滚动条的宽度会变为默认值。 | | scrollBarWidth | string&nbsp;\|&nbsp;number | 设置滚动条的宽度,不支持百分比设置。<br/>默认值:4<br/>单位:vp<br/>**说明:** <br/>如果滚动条的宽度超过其高度,则滚动条的宽度会变为默认值。 |
| edgeEffect | [EdgeEffect](ts-appendix-enums.md#edgeeffect) | 设置滑动效果,目前支持的滑动效果参见EdgeEffect的枚举说明。<br/>默认值:EdgeEffect.None | | edgeEffect | [EdgeEffect](ts-appendix-enums.md#edgeeffect) | 设置滑动效果,目前支持的滑动效果参见EdgeEffect的枚举说明。<br/>默认值:EdgeEffect.None |
| enableScrollInteraction<sup>10+</sup> | boolean | 设置是否支持滚动手势,当设置为false时,无法通过手指或者鼠标滚动,但不影响控制器的滚动接口。<br/>默认值:true |
## ScrollDirection枚举说明 ## ScrollDirection枚举说明
| 名称 | 描述 | | 名称 | 描述 |
...@@ -310,4 +311,4 @@ struct NestedScroll { ...@@ -310,4 +311,4 @@ struct NestedScroll {
} }
``` ```
![NestedScroll](figures/NestedScroll.gif) ![NestedScroll](figures/NestedScroll.gif)
\ No newline at end of file
...@@ -44,6 +44,7 @@ WaterFlow(options?: {footer?: CustomBuilder, scroller?: Scroller}) ...@@ -44,6 +44,7 @@ WaterFlow(options?: {footer?: CustomBuilder, scroller?: Scroller})
| columnsGap | Length |设置列与列的间距。 <br>默认值:0| | columnsGap | Length |设置列与列的间距。 <br>默认值:0|
| rowsGap | Length |设置行与行的间距。<br> 默认值:0| | rowsGap | Length |设置行与行的间距。<br> 默认值:0|
| layoutDirection | [FlexDirection](ts-appendix-enums.md#flexdirection) |设置布局的主轴方向。<br/>默认值:FlexDirection.Column| | layoutDirection | [FlexDirection](ts-appendix-enums.md#flexdirection) |设置布局的主轴方向。<br/>默认值:FlexDirection.Column|
| enableScrollInteraction<sup>10+</sup> | boolean | 设置是否支持滚动手势,当设置为false时,无法通过手指或者鼠标滚动,但不影响控制器的滚动接口。<br/>默认值:true |
layoutDirection优先级高于rowsTemplate和columnsTemplate。根据layoutDirection设置情况,分为以下三种设置模式: layoutDirection优先级高于rowsTemplate和columnsTemplate。根据layoutDirection设置情况,分为以下三种设置模式:
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
| 名称 | 类型 | 默认值 | 必填 | 描述 | | 名称 | 类型 | 默认值 | 必填 | 描述 |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| src | string | - | 否 | 图片的路径。<br/>-&nbsp;支持本地路径,图片格式包括png,&nbsp;jpg,&nbsp;bmp,&nbsp;svg和gif。<br/>-&nbsp;支持内存图片读取,scheme格式为memory://。 | | src | string | - | 否 | 图片的路径。<br/>-&nbsp;支持本地路径,图片格式包括png,&nbsp;jpg,&nbsp;bmp,&nbsp;svg和gif。<br/>-&nbsp;支持内存图片读取,scheme格式为memory://。<br/>**说明:**<br/>如需显示网络图片,应自行下载后使用内存图片方式刷新,禁止使用网络URL地址。|
| alt | string | - | 否 | 占位图,当指定图片在加载中时显示。 | | alt | string | - | 否 | 占位图,当指定图片在加载中时显示。 |
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
| border-[top\|bottom]-[left\|right]-radius | &lt;length&gt; | - | 分别设置左上,右上,右下和左下四个角的圆角半径。 | | border-[top\|bottom]-[left\|right]-radius | &lt;length&gt; | - | 分别设置左上,右上,右下和左下四个角的圆角半径。 |
| background | &lt;linear-gradient&gt; | - | 仅支持设置[渐变样式](js-service-widget-common-gradient.md),与background-color、background-image不兼容。 | | background | &lt;linear-gradient&gt; | - | 仅支持设置[渐变样式](js-service-widget-common-gradient.md),与background-color、background-image不兼容。 |
| background-color | &lt;color&gt; | - | 设置背景颜色。 | | background-color | &lt;color&gt; | - | 设置背景颜色。 |
| background-image | string | - | 设置背景图片。与background-color、background不兼容,支持本地图片资源地址。<br/>示例:<br/>-&nbsp;background-image:&nbsp;url("/common/background.png")<br/>不支持svg格式图片。 | | background-image | string | - | 设置背景图片。与background-color、background不兼容,支持本地图片资源地址。<br/>示例:<br/>-&nbsp;background-image:&nbsp;url("/common/background.png")<br/>不支持svg格式图片。<br/>如需显示网络图片,应自行下载后使用内存图片方式刷新,禁用网络URL地址。 |
| background-size | -&nbsp;string<br/>-&nbsp;&lt;length&gt;&nbsp;&lt;length&gt;<br/>-&nbsp;&lt;percentage&gt;&nbsp;&lt;percentage&gt; | auto | 设置背景图片的大小。<br/>-&nbsp;string可选值:<br/>&nbsp;&nbsp;-&nbsp;contain:把图片扩展至最大尺寸,以使其高度和宽度完全适用内容区域。<br/>&nbsp;&nbsp;-&nbsp;cover:把背景图片扩展至足够大,以使背景图片完全覆盖背景区域;背景图片的某些部分也许无法显示在背景定位区域中。<br/>&nbsp;&nbsp;-&nbsp;auto:保持原图的比例不变。<br/>-&nbsp;length值参数方式:<br/>&nbsp;&nbsp;设置背景图片的高度和宽度。第一个值设置宽度,第二个值设置高度。如果只设置一个值,则第二个值会被设置为&nbsp;"auto"。<br/>-&nbsp;百分比参数方式:<br/>&nbsp;&nbsp;以父元素的百分比来设置背景图片的宽度和高度。第一个值设置宽度,第二个值设置高度。如果只设置一个值,则第二个值会被设置为&nbsp;"auto"。 | | background-size | -&nbsp;string<br/>-&nbsp;&lt;length&gt;&nbsp;&lt;length&gt;<br/>-&nbsp;&lt;percentage&gt;&nbsp;&lt;percentage&gt; | auto | 设置背景图片的大小。<br/>-&nbsp;string可选值:<br/>&nbsp;&nbsp;-&nbsp;contain:把图片扩展至最大尺寸,以使其高度和宽度完全适用内容区域。<br/>&nbsp;&nbsp;-&nbsp;cover:把背景图片扩展至足够大,以使背景图片完全覆盖背景区域;背景图片的某些部分也许无法显示在背景定位区域中。<br/>&nbsp;&nbsp;-&nbsp;auto:保持原图的比例不变。<br/>-&nbsp;length值参数方式:<br/>&nbsp;&nbsp;设置背景图片的高度和宽度。第一个值设置宽度,第二个值设置高度。如果只设置一个值,则第二个值会被设置为&nbsp;"auto"。<br/>-&nbsp;百分比参数方式:<br/>&nbsp;&nbsp;以父元素的百分比来设置背景图片的宽度和高度。第一个值设置宽度,第二个值设置高度。如果只设置一个值,则第二个值会被设置为&nbsp;"auto"。 |
| background-repeat | string | repeat | 针对重复背景图片样式进行设置,背景图片默认在水平和垂直方向上重复。<br/>-&nbsp;repeat:在水平轴和竖直轴上同时重复绘制图片。<br/>-&nbsp;repeat-x:只在水平轴上重复绘制图片。<br/>-&nbsp;repeat-y:只在竖直轴上重复绘制图片。<br/>-&nbsp;no-repeat:不会重复绘制图片。 | | background-repeat | string | repeat | 针对重复背景图片样式进行设置,背景图片默认在水平和垂直方向上重复。<br/>-&nbsp;repeat:在水平轴和竖直轴上同时重复绘制图片。<br/>-&nbsp;repeat-x:只在水平轴上重复绘制图片。<br/>-&nbsp;repeat-y:只在竖直轴上重复绘制图片。<br/>-&nbsp;no-repeat:不会重复绘制图片。 |
| background-position | -&nbsp;string&nbsp;string<br/>-&nbsp;&lt;length&gt;&nbsp;&lt;length&gt;<br/>-&nbsp;&lt;percentage&gt;&nbsp;&lt;percentage&gt; | 0px&nbsp;0px | -&nbsp;关键词方式:如果仅规定了一个关键词,那么第二个值为"center"。两个值分别定义水平方向位置和竖直方向位置。<br/>&nbsp;&nbsp;-&nbsp;left:水平方向上最左侧。<br/>&nbsp;&nbsp;-&nbsp;right:水平方向上最右侧。<br/>&nbsp;&nbsp;-&nbsp;top:竖直方向上最顶部。<br/>&nbsp;&nbsp;-&nbsp;bottom:竖直方向上最底部。<br/>&nbsp;&nbsp;-&nbsp;center:水平方向或竖直方向上中间位置。<br/>-&nbsp;length值参数方式:第一个值是水平位置,第二个值是垂直位置。&nbsp;左上角是&nbsp;0&nbsp;0。单位是像素&nbsp;(0px&nbsp;0px)&nbsp;&nbsp;。如果仅规定了一个值,另外一个值将是50%。<br/>-&nbsp;百分比参数方式:第一个值是水平位置,第二个值是垂直位置。左上角是&nbsp;0%&nbsp;0%。右下角是&nbsp;100%&nbsp;100%。如果仅规定了一个值,另外一个值为50%。<br/>-&nbsp;可以混合使用&lt;percentage&gt;&lt;length&gt;。 | | background-position | -&nbsp;string&nbsp;string<br/>-&nbsp;&lt;length&gt;&nbsp;&lt;length&gt;<br/>-&nbsp;&lt;percentage&gt;&nbsp;&lt;percentage&gt; | 0px&nbsp;0px | -&nbsp;关键词方式:如果仅规定了一个关键词,那么第二个值为"center"。两个值分别定义水平方向位置和竖直方向位置。<br/>&nbsp;&nbsp;-&nbsp;left:水平方向上最左侧。<br/>&nbsp;&nbsp;-&nbsp;right:水平方向上最右侧。<br/>&nbsp;&nbsp;-&nbsp;top:竖直方向上最顶部。<br/>&nbsp;&nbsp;-&nbsp;bottom:竖直方向上最底部。<br/>&nbsp;&nbsp;-&nbsp;center:水平方向或竖直方向上中间位置。<br/>-&nbsp;length值参数方式:第一个值是水平位置,第二个值是垂直位置。&nbsp;左上角是&nbsp;0&nbsp;0。单位是像素&nbsp;(0px&nbsp;0px)&nbsp;&nbsp;。如果仅规定了一个值,另外一个值将是50%。<br/>-&nbsp;百分比参数方式:第一个值是水平位置,第二个值是垂直位置。左上角是&nbsp;0%&nbsp;0%。右下角是&nbsp;100%&nbsp;100%。如果仅规定了一个值,另外一个值为50%。<br/>-&nbsp;可以混合使用&lt;percentage&gt;&lt;length&gt;。 |
......
...@@ -1143,6 +1143,14 @@ usb服务 ...@@ -1143,6 +1143,14 @@ usb服务
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| 是 | 否 | 是 | 是 | 否 | 否 | 否 | 否 | | 是 | 否 | 是 | 是 | 否 | 否 | 否 | 否 |
## SystemCapability.Sensors.Sensor.Lite
传感器服务订阅
| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| 是 | 是 | 是 | 是 | 否 | 否 | 否 | 否 |
## SystemCapability.Sensors.MiscDevice ## SystemCapability.Sensors.MiscDevice
小器件-振感 小器件-振感
...@@ -1151,6 +1159,14 @@ usb服务 ...@@ -1151,6 +1159,14 @@ usb服务
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| 是 | 否 | 是 | 是 | 否 | 否 | 否 | 否 | | 是 | 否 | 是 | 是 | 否 | 否 | 否 | 否 |
## SystemCapability.Sensors.MiscDevice.Lite
小器件-振感
| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| 是 | 是 | 是 | 是 | 否 | 否 | 否 | 否 |
## SystemCapability.Startup.SystemInfo ## SystemCapability.Startup.SystemInfo
系统基本信息 系统基本信息
......
...@@ -419,6 +419,7 @@ ...@@ -419,6 +419,7 @@
- [使用AudioRenderer开发音频播放功能](media/using-audiorenderer-for-playback.md) - [使用AudioRenderer开发音频播放功能](media/using-audiorenderer-for-playback.md)
- [使用OpenSL ES开发音频播放功能](media/using-opensl-es-for-playback.md) - [使用OpenSL ES开发音频播放功能](media/using-opensl-es-for-playback.md)
- [使用TonePlayer开发音频播放功能(仅对系统应用开放)](media/using-toneplayer-for-playback.md) - [使用TonePlayer开发音频播放功能(仅对系统应用开放)](media/using-toneplayer-for-playback.md)
- [使用OHAudio开发音频播放功能](media/using-ohaudio-for-playback.md)
- [多音频播放的并发策略](media/audio-playback-concurrency.md) - [多音频播放的并发策略](media/audio-playback-concurrency.md)
- [播放音量管理](media/volume-management.md) - [播放音量管理](media/volume-management.md)
- [音效管理](media/audio-effect-management.md) - [音效管理](media/audio-effect-management.md)
...@@ -430,6 +431,7 @@ ...@@ -430,6 +431,7 @@
- [使用AVRecorder开发音频录制功能](media/using-avrecorder-for-recording.md) - [使用AVRecorder开发音频录制功能](media/using-avrecorder-for-recording.md)
- [使用AudioCapturer开发音频录制功能](media/using-audiocapturer-for-recording.md) - [使用AudioCapturer开发音频录制功能](media/using-audiocapturer-for-recording.md)
- [使用OpenSL ES开发音频录制功能](media/using-opensl-es-for-recording.md) - [使用OpenSL ES开发音频录制功能](media/using-opensl-es-for-recording.md)
- [使用OHAudio开发音频录制功能](media/using-ohaudio-for-recording.md)
- [管理麦克风](media/mic-management.md) - [管理麦克风](media/mic-management.md)
- [音频录制流管理](media/audio-recording-stream-management.md) - [音频录制流管理](media/audio-recording-stream-management.md)
- [音频输入设备管理](media/audio-input-device-management.md) - [音频输入设备管理](media/audio-input-device-management.md)
...@@ -1018,6 +1020,7 @@ ...@@ -1018,6 +1020,7 @@
- [@ohos.accessibility.GesturePath (手势路径)](reference/apis/js-apis-accessibility-GesturePath.md) - [@ohos.accessibility.GesturePath (手势路径)](reference/apis/js-apis-accessibility-GesturePath.md)
- [@ohos.accessibility.GesturePoint (手势触摸点)](reference/apis/js-apis-accessibility-GesturePoint.md) - [@ohos.accessibility.GesturePoint (手势触摸点)](reference/apis/js-apis-accessibility-GesturePoint.md)
- [@ohos.application.AccessibilityExtensionAbility (辅助功能扩展能力)](reference/apis/js-apis-application-accessibilityExtensionAbility.md) - [@ohos.application.AccessibilityExtensionAbility (辅助功能扩展能力)](reference/apis/js-apis-application-accessibilityExtensionAbility.md)
- [@ohos.base (公共回调信息)](reference/apis/js-apis-base.md)
- [@ohos.faultLogger (故障日志获取)](reference/apis/js-apis-faultLogger.md) - [@ohos.faultLogger (故障日志获取)](reference/apis/js-apis-faultLogger.md)
- [@ohos.hichecker (检测模式)](reference/apis/js-apis-hichecker.md) - [@ohos.hichecker (检测模式)](reference/apis/js-apis-hichecker.md)
- [@ohos.hidebug (Debug调试)](reference/apis/js-apis-hidebug.md) - [@ohos.hidebug (Debug调试)](reference/apis/js-apis-hidebug.md)
...@@ -1068,7 +1071,6 @@ ...@@ -1068,7 +1071,6 @@
- [@ohos.multimodalInput.shortKey(快捷键)](reference/apis/js-apis-shortKey.md) - [@ohos.multimodalInput.shortKey(快捷键)](reference/apis/js-apis-shortKey.md)
- [@ohos.power (系统电源管理)](reference/apis/js-apis-power.md) - [@ohos.power (系统电源管理)](reference/apis/js-apis-power.md)
- [@ohos.runningLock (Runninglock锁)](reference/apis/js-apis-runninglock.md) - [@ohos.runningLock (Runninglock锁)](reference/apis/js-apis-runninglock.md)
- [@ohos.resourceschedule.deviceStandby(设备待机模块)](reference/apis/js-apis-resourceschedule-deviceStandby.md)
- [@ohos.sensor (传感器)](reference/apis/js-apis-sensor.md) - [@ohos.sensor (传感器)](reference/apis/js-apis-sensor.md)
- [@ohos.settings (设置数据项名称)](reference/apis/js-apis-settings.md) - [@ohos.settings (设置数据项名称)](reference/apis/js-apis-settings.md)
- [@ohos.stationary (设备状态感知框架)](reference/apis/js-apis-stationary.md) - [@ohos.stationary (设备状态感知框架)](reference/apis/js-apis-stationary.md)
...@@ -1231,7 +1233,6 @@ ...@@ -1231,7 +1233,6 @@
- [半模态转场](reference/arkui-ts/ts-universal-attributes-sheet-transition.md) - [半模态转场](reference/arkui-ts/ts-universal-attributes-sheet-transition.md)
- [隐私遮罩](reference/arkui-ts/ts-universal-attributes-obscured.md) - [隐私遮罩](reference/arkui-ts/ts-universal-attributes-obscured.md)
- [文本通用](reference/arkui-ts/ts-universal-attributes-text-style.md) - [文本通用](reference/arkui-ts/ts-universal-attributes-text-style.md)
- [安全控件通用](reference/arkui-ts/ts-universal-attributes-securitycomponent.md)
- 手势处理 - 手势处理
- [绑定手势方法](reference/arkui-ts/ts-gesture-settings.md) - [绑定手势方法](reference/arkui-ts/ts-gesture-settings.md)
- 基础手势 - 基础手势
...@@ -1274,9 +1275,6 @@ ...@@ -1274,9 +1275,6 @@
- [RichText](reference/arkui-ts/ts-basic-components-richtext.md) - [RichText](reference/arkui-ts/ts-basic-components-richtext.md)
- [ScrollBar](reference/arkui-ts/ts-basic-components-scrollbar.md) - [ScrollBar](reference/arkui-ts/ts-basic-components-scrollbar.md)
- [Search](reference/arkui-ts/ts-basic-components-search.md) - [Search](reference/arkui-ts/ts-basic-components-search.md)
- [SecLocationButton](reference/arkui-ts/ts-basic-components-seclocationbutton.md)
- [SecPasteButton](reference/arkui-ts/ts-basic-components-secpastebutton.md)
- [SecSaveButton](reference/arkui-ts/ts-basic-components-secsavebutton.md)
- [Select](reference/arkui-ts/ts-basic-components-select.md) - [Select](reference/arkui-ts/ts-basic-components-select.md)
- [Slider](reference/arkui-ts/ts-basic-components-slider.md) - [Slider](reference/arkui-ts/ts-basic-components-slider.md)
- [Span](reference/arkui-ts/ts-basic-components-span.md) - [Span](reference/arkui-ts/ts-basic-components-span.md)
...@@ -1666,6 +1664,7 @@ ...@@ -1666,6 +1664,7 @@
- [VideoEncoder](reference/native-apis/_video_encoder.md) - [VideoEncoder](reference/native-apis/_video_encoder.md)
- [AVDemuxer](reference/native-apis/_a_v_demuxer.md) - [AVDemuxer](reference/native-apis/_a_v_demuxer.md)
- [AVSource](reference/native-apis/_a_v_source.md) - [AVSource](reference/native-apis/_a_v_source.md)
- [OHAudio](reference/native-apis/_o_h_audio.md)
- [HuksKeyApi](reference/native-apis/_huks_key_api.md) - [HuksKeyApi](reference/native-apis/_huks_key_api.md)
- [HuksParamSetApi](reference/native-apis/_huks_param_set_api.md) - [HuksParamSetApi](reference/native-apis/_huks_param_set_api.md)
- [HuksTypeApi](reference/native-apis/_huks_type_api.md) - [HuksTypeApi](reference/native-apis/_huks_type_api.md)
...@@ -1716,6 +1715,10 @@ ...@@ -1716,6 +1715,10 @@
- [native_avmemory.h](reference/native-apis/native__avmemory_8h.md) - [native_avmemory.h](reference/native-apis/native__avmemory_8h.md)
- [native_avmuxer.h](reference/native-apis/native__avmuxer_8h.md) - [native_avmuxer.h](reference/native-apis/native__avmuxer_8h.md)
- [native_avsource.h](reference/native-apis/native__avsource_8h.md) - [native_avsource.h](reference/native-apis/native__avsource_8h.md)
- [native_audiocapturer.h](reference/native-apis/native__audiocapturer_8h.md)
- [native_audiorenderer.h](reference/native-apis/native__audiorenderer_8h.md)
- [native_audiostream_base.h](reference/native-apis/native__audiostream__base_8h.md)
- [native_audiostreambuilder.h](reference/native-apis/native__audiostreambuilder_8h.md)
- [native_huks_api.h](reference/native-apis/native__huks__api_8h.md) - [native_huks_api.h](reference/native-apis/native__huks__api_8h.md)
- [native_huks_param.h](reference/native-apis/native__huks__param_8h.md) - [native_huks_param.h](reference/native-apis/native__huks__param_8h.md)
- [native_huks_type.h](reference/native-apis/native__huks__type_8h.md) - [native_huks_type.h](reference/native-apis/native__huks__type_8h.md)
...@@ -1755,6 +1758,8 @@ ...@@ -1755,6 +1758,8 @@
- [OH_AVCodecAsyncCallback](reference/native-apis/_o_h___a_v_codec_async_callback.md) - [OH_AVCodecAsyncCallback](reference/native-apis/_o_h___a_v_codec_async_callback.md)
- [OH_AVCodecBufferAttr](reference/native-apis/_o_h___a_v_codec_buffer_attr.md) - [OH_AVCodecBufferAttr](reference/native-apis/_o_h___a_v_codec_buffer_attr.md)
- [OH_AVRange](reference/native-apis/_o_h___a_v_range.md) - [OH_AVRange](reference/native-apis/_o_h___a_v_range.md)
- [OH_AudioCapturer_Callbacks_Struct](reference/native-apis/_o_h___audio_capturer___callbacks___struct.md)
- [OH_AudioRenderer_Callbacks_Struct](reference/native-apis/_o_h___audio_renderer___callbacks___struct.md)
- [OH_Huks_Blob](reference/native-apis/_o_h___huks___blob.md) - [OH_Huks_Blob](reference/native-apis/_o_h___huks___blob.md)
- [OH_Huks_CertChain](reference/native-apis/_o_h___huks___cert_chain.md) - [OH_Huks_CertChain](reference/native-apis/_o_h___huks___cert_chain.md)
- [OH_Huks_KeyInfo](reference/native-apis/_o_h___huks___key_info.md) - [OH_Huks_KeyInfo](reference/native-apis/_o_h___huks___key_info.md)
......
...@@ -91,7 +91,7 @@ GPIO模块适配包含以下四个步骤: ...@@ -91,7 +91,7 @@ GPIO模块适配包含以下四个步骤:
### 开发实例 ### 开发实例
下方将基于Hi3516DV300开发板以//device_soc_hisilicon/common/platform/gpio/gpio_hi35xx.c驱动为示例,展示需要驱动适配者提供哪些内容来完整实现设备功能。 下方将基于Hi3516DV300开发板以//device/soc/hisilicon/common/platform/gpio/gpio_hi35xx.c驱动为示例,展示需要驱动适配者提供哪些内容来完整实现设备功能。
1. 实例化驱动入口 1. 实例化驱动入口
......
...@@ -133,7 +133,7 @@ MIPI CSI模块适配包含以下四个步骤: ...@@ -133,7 +133,7 @@ MIPI CSI模块适配包含以下四个步骤:
### 开发实例 ### 开发实例
下方将基于Hi3516DV300开发板以//device_soc_hisilicon/common/platform/mipi_csi/mipi_csi_hi35xx.c驱动为示例,展示需要厂商提供哪些内容来完整实现设备功能。 下方将基于Hi3516DV300开发板以//device/soc/hisilicon/common/platform/mipi_csi/mipi_csi_hi35xx.c驱动为示例,展示需要厂商提供哪些内容来完整实现设备功能。
1. 实例化驱动入口 1. 实例化驱动入口
......
...@@ -117,7 +117,7 @@ MIPI DSI模块适配包含以下四个步骤: ...@@ -117,7 +117,7 @@ MIPI DSI模块适配包含以下四个步骤:
### 开发实例 ### 开发实例
下方将基于Hi3516DV300开发板以//device_soc_hisilicon/common/platform/mipi_dsi/mipi_tx_hi35xx.c驱动为示例,展示需要厂商提供哪些内容来完整实现设备功能。 下方将基于Hi3516DV300开发板以//device/soc/hisilicon/common/platform/mipi_dsi/mipi_tx_hi35xx.c驱动为示例,展示需要厂商提供哪些内容来完整实现设备功能。
1. 实例化驱动入口 1. 实例化驱动入口
......
...@@ -108,7 +108,7 @@ MMC模块适配包含以下四个步骤: ...@@ -108,7 +108,7 @@ MMC模块适配包含以下四个步骤:
### 开发实例 ### 开发实例
下方将基于Hi3516DV300开发板以//device_soc_hisilicon/common/platform/mmc/himci_v200/himci.c驱动为示例,展示需要驱动适配者提供哪些内容来完整实现设备功能。 下方将基于Hi3516DV300开发板以//device/soc/hisilicon/common/platform/mmc/himci_v200/himci.c驱动为示例,展示需要驱动适配者提供哪些内容来完整实现设备功能。
1. 实例化驱动入口 1. 实例化驱动入口
......
...@@ -88,7 +88,7 @@ PIN模块适配HDF框架包含以下四个步骤: ...@@ -88,7 +88,7 @@ PIN模块适配HDF框架包含以下四个步骤:
### 开发实例 ### 开发实例
下方将基于Hi3516DV300开发板以//device_soc_hisilicon/common/platform/pin/pin_hi35xx.c驱动为示例,展示需要驱动适配者提供哪些内容来完整实现设备功能。 下方将基于Hi3516DV300开发板以//device/soc/hisilicon/common/platform/pin/pin_hi35xx.c驱动为示例,展示需要驱动适配者提供哪些内容来完整实现设备功能。
1. 实例化驱动入口 1. 实例化驱动入口
......
...@@ -74,7 +74,7 @@ PWM模块适配包含以下四个步骤: ...@@ -74,7 +74,7 @@ PWM模块适配包含以下四个步骤:
### 开发实例 ### 开发实例
下方将基于Hi3516DV300开发板以//device_soc_hisilicon/common/platform/pwm/pwm_hi35xx.c驱动为示例,展示需要驱动适配者提供哪些内容来完整实现设备功能。 下方将基于Hi3516DV300开发板以//device/soc/hisilicon/common/platform/pwm/pwm_hi35xx.c驱动为示例,展示需要驱动适配者提供哪些内容来完整实现设备功能。
1. 驱实例化驱动入口 1. 驱实例化驱动入口
......
...@@ -114,7 +114,7 @@ UART模块适配HDF框架包含以下四个步骤: ...@@ -114,7 +114,7 @@ UART模块适配HDF框架包含以下四个步骤:
### 开发实例 ### 开发实例
下方将基于Hi3516DV300开发板以//device_soc_hisilicon/common/platform/uart/uart_hi35xx.c驱动为示例,展示需要驱动适配者提供哪些内容来完整实现设备功能。 下方将基于Hi3516DV300开发板以//device/soc/hisilicon/common/platform/uart/uart_hi35xx.c驱动为示例,展示需要驱动适配者提供哪些内容来完整实现设备功能。
1. 实例化驱动入口 1. 实例化驱动入口
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
### 功能简介 ### 功能简介
看门狗(Watchdog),又称看门狗计时器(Watchdog timer),是一种硬件计时设备。一般有一个输入,叫做喂狗,一个输出到系统的复位端。当系统主程序发生错误导致未及时清除看门狗计时器的计时值时,看门狗计时器就会对系统发出复位信号,使系统从悬停状态恢复到正常运作状态。 看门狗(Watchdog),又称看门狗计时器(Watchdog timer),是一种硬件计时设备。一般有一个输入、一个输出,输入叫做喂狗,输出连接到系统的复位端。当系统主程序发生错误导致未及时清除看门狗计时器的计时值时,看门狗计时器就会对系统发出复位信号,使系统从悬停状态恢复到正常运作状态。
Watchdog接口定义了看门狗操作的通用方法集合,包括: Watchdog接口定义了看门狗操作的通用方法集合,包括:
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
### 功能简介 ### 功能简介
看门狗(Watchdog),又称看门狗计时器(Watchdog timer),是一种硬件计时设备。一般有一个输入,叫做喂狗,一个输出到系统的复位端。当系统主程序发生错误导致未及时清除看门狗计时器的计时值时,看门狗计时器就会对系统发出复位信号,使系统从悬停状态恢复到正常运作状态。 看门狗(Watchdog),又称看门狗计时器(Watchdog timer),是一种硬件计时设备。一般有一个输入、一个输出,输入叫做喂狗,输出连接到系统的复位端。当系统主程序发生错误导致未及时清除看门狗计时器的计时值时,看门狗计时器就会对系统发出复位信号,使系统从悬停状态恢复到正常运作状态。
### 基本概念 ### 基本概念
...@@ -84,7 +84,7 @@ Watchdog模块适配包含以下四个步骤: ...@@ -84,7 +84,7 @@ Watchdog模块适配包含以下四个步骤:
### 开发实例 ### 开发实例
下方将基于Hi3516DV300开发板以//device_soc_hisilicon/common/platform/watchdog/watchdog_hi35xx.c驱动为示例,展示需要驱动适配者提供哪些内容来完整实现设备功能。 下方将基于Hi3516DV300开发板以//device/soc/hisilicon/common/platform/watchdog/watchdog_hi35xx.c驱动为示例,展示需要驱动适配者提供哪些内容来完整实现设备功能。
1. 实例化驱动入口 1. 实例化驱动入口
......
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
| 版本源码 | **版本信息** | **下载站点** | **SHA256校验码** | | 版本源码 | **版本信息** | **下载站点** | **SHA256校验码** |
| ------------------------------------- | ------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | | ------------------------------------- | ------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| 全量代码(标准、轻量和小型系统) | 3.2.2 Release | [站点](https://mirrors.huaweicloud.com/openharmony/os/3.2.2/code-v3.2.2-Release.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/openharmony/os/3.2.2/code-v3.2.2-Release.tar.gz.sha256) | | 全量代码(标准、轻量和小型系统) | 3.2.2 Release | [站点](https://mirrors.huaweicloud.com/openharmony/os/3.2.2/code-v3.2.2-Release_20230628.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/openharmony/os/3.2.2/code-v3.2.2-Release.tar.gz_20230628.sha256) |
| Hi3861解决方案(二进制) | 3.2.2 Release | [站点](https://mirrors.huaweicloud.com/openharmony/os/3.2.2/hispark_pegasus.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/openharmony/os/3.2.2/hispark_pegasus.tar.gz.sha256) | | Hi3861解决方案(二进制) | 3.2.2 Release | [站点](https://mirrors.huaweicloud.com/openharmony/os/3.2.2/hispark_pegasus.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/openharmony/os/3.2.2/hispark_pegasus.tar.gz.sha256) |
| Hi3516解决方案-LiteOS(二进制) | 3.2.2 Release | [站点](https://mirrors.huaweicloud.com/openharmony/os/3.2.2/hispark_taurus_LiteOS.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/openharmony/os/3.2.2/hispark_taurus_LiteOS.tar.gz.sha256) | | Hi3516解决方案-LiteOS(二进制) | 3.2.2 Release | [站点](https://mirrors.huaweicloud.com/openharmony/os/3.2.2/hispark_taurus_LiteOS.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/openharmony/os/3.2.2/hispark_taurus_LiteOS.tar.gz.sha256) |
| Hi3516解决方案-Linux(二进制) | 3.2.2 Release | [站点](https://mirrors.huaweicloud.com/openharmony/os/3.2.2/hispark_taurus_Linux.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/openharmony/os/3.2.2/hispark_taurus_Linux.tar.gz.sha256) | | Hi3516解决方案-Linux(二进制) | 3.2.2 Release | [站点](https://mirrors.huaweicloud.com/openharmony/os/3.2.2/hispark_taurus_Linux.tar.gz) | [SHA256校验码](https://mirrors.huaweicloud.com/openharmony/os/3.2.2/hispark_taurus_Linux.tar.gz.sha256) |
......
# arkui子系统ChangeLog
## cl.arkui.1 通用事件参数支持undefined
通用事件(点击事件、触摸事件、挂载卸载事件、按键事件、焦点事件、鼠标事件、组件区域变化事件)参数支持undefined。
**示例:**
```ts
// xxx.ets
@Entry
@Component
struct Example {
build() {
Button("test")
.onClick(()=>{
console.log("click");
})
.onClick(undefined)
}
}
```
**变更影响**
如果事件回调参数为undefined,那么将不再响应已经设置的事件回调。
**关键的接口/组件变更**
不涉及。
**适配指导**
当事件参数设置为undefined,将会禁用该事件,依据实际应用开发场景进行参数设置即可。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册