When writing library code, never hard-terminate or silently ignore failures. Always (1) validate inputs/shape compatibility correctly (including pack/elempack and dynamic dims), (2) signal errors with consistent return codes, and (3) propagate error statuses from lower-level operations to the caller.
Apply these rules:
assert(0)/process termination with a returned error code so the caller can decide how to recover.-1 for invalid parameter, existing -100 for allocation failure, etc.).Example: propagate and handle submit errors
// Bad: ignoring status
cmd.submit_and_wait();
return 0;
// Good: propagate to caller
return cmd.submit_and_wait();
Example: avoid assert(0) in library code
switch (impl_type) {
case 1: /* ... */ break;
case 2: /* ... */ break;
// ...
default:
return -1; // invalid impl_type
}
Enter the URL of a public GitHub repository