Dump Log APIs
Description
Records logs generated during the execution of AI CPU operators to facilitate function debugging. Currently, log APIs of the DEBUG, INFO, WARNING, and ERROR levels are provided.
Prototype
CUST_KERNEL_LOG_DEBUG(ctx, fmt, ...)
CUST_KERNEL_LOG_INFO(ctx, fmt, ...)
CUST_KERNEL_LOG_WARNING(ctx, fmt, ...)
CUST_KERNEL_LOG_ERROR(ctx, fmt, ...)
Note: The following API is called by the preceding macro definition, rather than directly called by developers.
static void CustLogDebug(aicpu::CpuKernelContext &ctx, const char *fmt, ...);
static void CustLogWarning(aicpu::CpuKernelContext &ctx, const char *fmt, ...);
static void CustLogInfo(aicpu::CpuKernelContext &ctx, const char *fmt, ...);
static void CustLogError(aicpu::CpuKernelContext &ctx, const char *fmt, ...);
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
ctx |
Input |
CPU kernel context, CpuKernelContext object, and input parameter of the Compute function of the operator. |
fmt |
Input |
Format control string. |
... |
Input |
Additional parameters. Depending on the fmt string, the function may require a series of additional parameters. Each parameter contains a value to be inserted and replaces each % tag specified in the fmt parameter. |
Returns
None
Restrictions
None
Example
uint32_t UniqueCpuKernel::Compute(CpuKernelContext &ctx) {
Tensor *param_tensor = ctx.Input(0);
if (param_tensor == nullptr) {
return 1;
}
auto param_shape = param_tensor->GetTensorShape();
if (param_shape == nullptr) {
return 1;
}
int64_t p_size = 1;
for (int i = 0; i < param_shape->GetDims(); ++i) {
p_size *= param_shape->GetDimSize(i);
}
CUST_KERNEL_LOG_DEBUG(ctx, "Cust UniqueCpuKernel Compute, p_size is %ld.", p_size);
...
}