RunCpuKernelAsyncV2
Description
Asynchronously executes the Compute function of the AI CPU operator kernel (V2 version).
V2 execution is searched only in creatorMapV2 and is not fallen back to V1.
Prototype
uint32_t RunCpuKernelAsyncV2(CpuKernelContext &ctx, const uint8_t wait_type, const uint32_t wait_id, std::function<uint32_t()> cb)
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
ctx |
Input |
Context of CpuKernel. CpuKernelContext type. |
wait_type |
Input |
Event waiting type. The value can be 0 or 1. 0: disables the event waiting function. 1: enables the event waiting function. Note: In the asynchronous scenario, this parameter must be set to 1. |
wait_id |
Input |
Event ID, which is the event waiting ID. |
cb |
Input |
Post-Compute processing callback function. |
Returns
uint32_t for the RunCpuKernelAsyncV2 execution result.
- 0: success
- Other values: failure
Restrictions
Kernel execution is searched only in the V2 registry and is not fallen back to V1. If the operator is not registered in V2, a failure is returned.
Example
CpuKernelContext ctx;
uint8_t wait_type = 1;
uint32_t wait_id = 0;
uint32_t UpdateFWKOutputShape(const CpuKernelContext &ctx) const {
// Update the specific output shape information.
// ...
}
uint32_t ret = CpuKernelRegister::Instance().RunCpuKernelAsyncV2(ctx, wait_type, wait_id,
[&, ctx]() { return UpdateFWKOutputShape(ctx); });