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 错误处理程序识别。

参数:
  • func_name (strfunctionclass) – 错误函数的名称。

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

返回:

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

返回类型:

函数

示例

@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 期间报告了错误诊断。

有关详细的错误信息,请参阅配置的诊断渲染器。