Function TVMFFIErrorSetRaisedFromCStrParts#
Defined in File c_api.h
Function Documentation#
-
void TVMFFIErrorSetRaisedFromCStrParts(const char *kind, const char **message_parts, int32_t num_parts)#
Set a raised error in TLS, which can be fetched by TVMFFIErrorMoveFromRaised.
Rationale: This function can be used by compilers to create error messages by concatenating multiple parts of the error message, which can reduce the storage size for common parts such as function signatures.
For example, the following are possible error messages from a kernel DSL
Argument 1 mismatch in
matmul(x: Tensor, y: Tensor, z: Tensor)
, dtype mismatchArgument 2 mismatch in
matmul(x: Tensor, y: Tensor, z: Tensor)
, shape[0] mismatchArgument 2 mismatch in
matmul(x: Tensor, y: Tensor, z: Tensor)
, shape[1] mismatch
Storing each part of the error message as a separate global string can cause quite a bit of duplication, especially considering the kinds of error reports we may have. Instead, compilers can store error messages in parts, where items like
matmul(x: Tensor, y: Tensor, z: Tensor)
can be reused across multiple error messages. This API simplifies error reporting for such cases.- Parameters:
kind – The kind of the error.
message_parts – The error message parts, each part can be NULL and will be skipped.
num_parts – The number of error message parts.