tvm.error

TVM中的结构化错误类。

每个错误类以错误消息作为输入。 请参阅示例部分了解建议的消息格式规范。 为了提高代码可读性,我们建议开发者 复制这些示例并使用相同的消息规范来抛出错误。

注意

请同时参考错误处理指南

异常情况:

TVMError

TVM函数抛出的默认错误。

InternalError(msg)

系统内部错误。

RPCError

由处理RPC调用的远程服务器抛出的错误。

RPCSessionTimeoutError

当RPC会话过期时,远程服务器抛出的错误。

OpError

前端中所有操作符错误的基类。

OpNotImplemented

操作符未实现。

OpAttributeRequired

未找到必需属性。

OpAttributeInvalid

当前端操作符传入时属性值无效。

OpAttributeUnImplemented

该属性在某个前端中不受支持。

DiagnosticError

在执行某个pass过程中报告了错误诊断信息。

功能:

register_error([func_name, cls])

注册一个错误类,以便ffi错误处理程序能够识别它。

exception tvm.error.TVMError

TVM函数抛出的默认错误。

如果不指定任何错误类型,将会引发TVMError,

tvm.error.register_error(func_name=None, cls=None)

注册一个错误类,使其能够被ffi错误处理器识别。

Parameters:
  • func_name (strfunctionclass) - 错误函数的名称。

  • cls (function) – 用于创建类的函数

Returns:

fregister - 如果未指定f参数,则注册函数。

Return type:

函数

示例

@tvm.error.register_error
class MyError(RuntimeError):
    pass

err_inst = tvm.error.create_ffi_error("MyError: xyz")
assert isinstance(err_inst, MyError)
exception tvm.error.InternalError(msg)

系统内部错误。

示例

// Example code C++
LOG(FATAL) << "InternalError: internal error detail.";
# Example code in python
raise InternalError("internal error detail")
exception tvm.error.RPCError

由处理RPC调用的远程服务器抛出的错误。

exception tvm.error.RPCSessionTimeoutError

当RPC会话过期时,远程服务器抛出的错误。

exception tvm.error.OpError

前端中所有操作符错误的基类。

exception tvm.error.OpNotImplemented

操作符未实现。

示例

raise OpNotImplemented(
    "Operator {} is not supported in {} frontend".format(
        missing_op, frontend_name))
exception tvm.error.OpAttributeRequired

未找到必需属性。

示例

raise OpAttributeRequired(
    "Required attribute {} not found in operator {}".format(
        attr_name, op_name))
exception tvm.error.OpAttributeInvalid

当前端操作符传入时属性值无效。

示例

raise OpAttributeInvalid(
    "Value {} in attribute {} of operator {} is not valid".format(
        value, attr_name, op_name))
exception tvm.error.OpAttributeUnImplemented

该属性在某个前端中不受支持。

示例

raise OpAttributeUnImplemented(
    "Attribute {} is not supported in operator {}".format(
        attr_name, op_name))
exception tvm.error.DiagnosticError

在执行某个pass过程中报告了错误诊断信息。

查看配置的诊断渲染器以获取详细的错误信息。