_ffi.base#

Base library for TVM FFI.

exception tvm._ffi.base.TVMError[源代码]#

Default error thrown by TVM functions.

TVMError will be raised if you do not give any error type specification,

tvm._ffi.base._find_error_type(line)[源代码]#

Find the error name given the first line of the error message.

linestr

The first line of error message.

name : str The error name

tvm._ffi.base._load_lib()[源代码]#

Load libary by searching possible path.

tvm._ffi.base._valid_error_name(name)[源代码]#

Check whether name is a valid error name.

tvm._ffi.base.c2pyerror(err_msg)[源代码]#

Translate C API error message to python style.

err_msgstr

The error message.

new_msgstr

Translated message.

err_typestr

Detected error type.

tvm._ffi.base.c_array(ctype, values)[源代码]#

Create ctypes array from a python array

ctypectypes data type

data type of the array we want to convert to

valuestuple or list

data content

outctypes array

Created ctypes array

tvm._ffi.base.c_str(string)[源代码]#

Create ctypes char * from a python string Parameters ———- string : string type

python string

strc_char_p

A char pointer that can be passed to C API

tvm._ffi.base.check_call(ret)[源代码]#

Check the return value of C API call

This function will raise exception when error occurs. Wrap every API call with this function

retint

return value from API calls

tvm._ffi.base.decorate(func, fwrapped)[源代码]#

A wrapper call of decorator package, differs to call time

funcfunction

The original function

fwrappedfunction

The wrapped function

tvm._ffi.base.get_last_ffi_error()[源代码]#

Create error object given result of TVMGetLastError.

errobject

The error object based on the err_msg

tvm._ffi.base.py2cerror(err_msg)[源代码]#

Translate python style error message to C style.

err_msgstr

The error message.

new_msgstr

Translated message.

tvm._ffi.base.register_error(func_name=None, cls=None)[源代码]#

Register an error class so it can be recognized by the ffi error handler.

func_namestr or function or class

The name of the error function.

clsfunction

The function to create the class

fregisterfunction

Register function if f is not specified.

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

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