Term |
Description |
|---|---|
Synchronous/Asynchronous |
Indicates whether an API call returns immediately when the request is delivered.
|
Process/Thread |
Unless otherwise specified, the processes and threads mentioned in this document refer to those on the host. |
Host |
A host refers to the x86 or Arm server connected to the device. The host utilizes the NN compute capability provided by the device to implement services. |
Device |
A device refers to an Ascend AI Processor-powered hardware device that connects to the host over the PCIe interface, providing the host with the NN computing capability. Memory sharing between devices is not supported. |
Context |
A context is a container that manages the lifetime of its objects (including streams, events, and device memory). Each unique context has isolated streams and events, and they cannot be synchronized with one another. Contexts come in two types:
|
Stream |
Streams preserve the order of a stack of asynchronous operations being executed on the device. Stream-based kernel execution and data transfer can implement parallel computing on both the host and the device, as well as data transfer between the host and the device. Streams come in two types:
|
Event |
Events are used to synchronize tasks between streams by using AscendCL API calls, including tasks between the host and the device, and tasks on the same device. For example, to execute a task from stream 2 after executing a task from stream 1, create an event and append it to stream 1. |
AIPP |
The Artificial Intelligence Pre-Processing (AIPP) module is introduced for AI Core–based image preprocessing including Color Space Conversion (CSC), image normalization (by subtracting the mean value or multiplying a factor), image cropping (by specifying the crop start and cropping the image to the size required by the NN), and much more.
AIPP supports static and dynamic modes. However, these two modes are mutually exclusive.
|
Dynamic batch/image size |
The batch size or image size is not fixed in certain scenarios. For example, as the number of detected objects is subject to change in the object detection+target recognition cascade scenario, the batch size of the target recognition input is dynamic.
|
Dynamic dimensions (ND format only) |
Dynamic dimensions for the ND format are useful in scenarios where input dimensions are unknown (such as the Transformer network). ND indicates any format with up to four dimensions. |
Channel |
An RGB image has three channels: red, green, and blue. HSV stands for hue, saturation, and value (brightness) and is an alternative representation of the RGB color model. |
Standard form |
The device functions as an endpoint (EP) and cooperates with the host (namely, an x86 or Arm server) over the PCIe interface. In this case, CPU resources on the device are available only to the host, and inference apps run on the host. The device only provides the NN compute capability for the server. |
EP mode/RC mode |
The following uses the Ascend AI Processor as an example. If the PCIe works as the master and supports peripherals, this mode is referred to as the RC mode (or Ascend RC in the following). If the PCIe serves as a slave, this mode is referred to as the EP mode (or Ascend EP in the following). |
... aclrtCreateContext(&ctx1,0); aclrtCreateStream(&s1); aclopExecuteV2(op1,...,s1); aclrtCreateContext(&ctx2,1); /* After ctx2 is created, the context used in the current thread changes to ctx2, and the subsequent tasks are computed on device 1. This sample executes op2 on device 1. */ aclrtCreateStream(&s2); aclopExecuteV2(op2,...,s2); aclrtSetCurrentContext(ctx1); /* Switch between devices by switching between contexts in the current thread so that the subsequent tasks can be computed on device 0.*/ aclopExecuteV2(op3,...,s1); ...
To pass the default stream to any API call, pass NULL directly.
The following code snippet shows key steps only, and is not ready to be built or run.
... aclInit(...); aclrtSetDevice(0); /* In the default context, a default stream is created, and the stream is available in the current thread. */ ... aclopExecuteV2(op1,...,NULL); //NULL indicates that op1 is executed in the default stream. aclopExecuteV2(op2,...,NULL); //NULL indicates that op2 is executed in the default stream. aclrtSynchronizeStream(NULL); /* Output the result as required when all computing tasks (op1 and op2 execution tasks) are complete. */ ... aclrtResetDevice(0); //Reset device 0. The lifetime of the corresponding default context and default stream end.