RunCpuKernelAsync
Description
Asynchronously executes the Compute function of the AI CPU operator kernel.
Prototype
uint32_t RunCpuKernelAsync(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.
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 RunCpuKernelAsync execution result.
- 0: success
- Other values: failure
Restrictions
None
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().RunCpuKernelAsync(ctx, wait_type, wait_id, [&, ctx]() { return UpdateFWKOutputShape(ctx); });
Parent topic: Class CpuKernelRegister