Commit 7e032457 by Tianqi Chen Committed by GitHub

[PYTHON] Rename the namespace (#105)

parent e4c74668
......@@ -18,7 +18,7 @@ from . import ir_builder
from . import ndarray as nd
from .ndarray import cpu, gpu, opencl, cl, vpi
from ._ctypes._function import Function
from ._ffi.function import Function
from ._base import TVMError
from ._base import __version__
......
......@@ -10,11 +10,11 @@ from numbers import Number, Integral
from .._base import _LIB, check_call
from .._base import c_str, py_str, string_types
from ._types import TVMValue, TypeCode, TVMType, TVMByteArray
from ._types import TVMPackedCFunc, TVMCFuncFinalizer
from ._types import RETURN_SWITCH, C_TO_PY_ARG_SWITCH, _wrap_arg_func
from ._node import NodeBase, NodeGeneric, convert_to_node
from ._ndarray import NDArrayBase
from .types import TVMValue, TypeCode, TVMType, TVMByteArray
from .types import TVMPackedCFunc, TVMCFuncFinalizer
from .types import RETURN_SWITCH, C_TO_PY_ARG_SWITCH, _wrap_arg_func
from .node import NodeBase, NodeGeneric, convert_to_node
from .ndarray import NDArrayBase
FunctionHandle = ctypes.c_void_p
ModuleHandle = ctypes.c_void_p
......@@ -57,7 +57,7 @@ def convert_to_tvm_func(pyfunc):
if rv is not None:
if isinstance(rv, tuple):
raise ValueError("PackedFunction can only support one reurn value")
raise ValueError("PackedFunction can only support one return value")
temp_args = []
values, tcodes, _ = _make_tvm_args((rv,), temp_args)
if not isinstance(ret, TVMRetValueHandle):
......@@ -84,15 +84,15 @@ def _make_tvm_args(args, temp_args):
values = (TVMValue * num_args)()
type_codes = (ctypes.c_int * num_args)()
for i, arg in enumerate(args):
if arg is None:
if isinstance(arg, NodeBase):
values[i].v_handle = arg.handle
type_codes[i] = TypeCode.NODE_HANDLE
elif arg is None:
values[i].v_handle = None
type_codes[i] = TypeCode.NULL
elif isinstance(arg, NDArrayBase):
values[i].v_handle = ctypes.cast(arg.handle, ctypes.c_void_p)
type_codes[i] = TypeCode.ARRAY_HANDLE
elif isinstance(arg, NodeBase):
values[i].v_handle = arg.handle
type_codes[i] = TypeCode.NODE_HANDLE
elif isinstance(arg, Integral):
values[i].v_int64 = arg
type_codes[i] = TypeCode.INT
......
......@@ -8,7 +8,7 @@ import numpy as np
from .._base import _LIB, check_call
from .._base import c_array
from ._types import TVMType, tvm_shape_index_t
from .types import TVMType, tvm_shape_index_t
class TVMContext(ctypes.Structure):
"""TVM context strucure."""
......
......@@ -10,8 +10,8 @@ from numbers import Number, Integral
from .._base import _LIB, check_call
from .._base import c_str, py_str, string_types
from .. import _api_internal
from ._types import TVMValue, TypeCode
from ._types import RETURN_SWITCH, C_TO_PY_ARG_SWITCH, _wrap_arg_func
from .types import TVMValue, TypeCode
from .types import RETURN_SWITCH, C_TO_PY_ARG_SWITCH, _wrap_arg_func
NodeHandle = ctypes.c_void_p
......
......@@ -8,8 +8,8 @@ import ctypes
from .. import _api_internal
from .._base import string_types
from .._ctypes._node import NodeBase, register_node
from .._ctypes._function import register_func
from .._ffi.node import NodeBase, register_node
from .._ffi.function import register_func
from . import testing
@register_node
......
......@@ -4,12 +4,11 @@ from __future__ import absolute_import as _abs
from numbers import Integral as _Integral
from ._ctypes._types import TVMType
from ._ctypes._node import register_node, NodeBase
from ._ctypes._node import convert_to_node as _convert_to_node
from ._ctypes._function import Function
from ._ctypes._function import _init_api, register_func, get_global_func
from ._ctypes._function import convert_to_tvm_func as _convert_tvm_func
from ._ffi.node import register_node, NodeBase
from ._ffi.node import convert_to_node as _convert_to_node
from ._ffi.function import Function
from ._ffi.function import _init_api, register_func, get_global_func
from ._ffi.function import convert_to_tvm_func as _convert_tvm_func
from . import _api_internal
from . import _base
from . import make as _make
......
"""Arithmetic data structure and utility"""
from __future__ import absolute_import as _abs
from ._ctypes._node import NodeBase, register_node
from ._ctypes._function import _init_api
from ._ffi.node import NodeBase, register_node
from ._ffi.function import _init_api
from . import _api_internal
class IntSet(NodeBase):
......
"""Code generation related functions."""
from ._ctypes._function import _init_api
from ._ffi.function import _init_api
def build_module(lowered_func, target):
"""Build lowered_func into Module.
......
"""Collections contains data structures used in TVM DSL."""
from __future__ import absolute_import as _abs
from ._ctypes._node import NodeBase, register_node
from ._ffi.node import NodeBase, register_node
from . import _api_internal
@register_node
......
......@@ -16,7 +16,7 @@ For example, you can use addexp.a to get the left operand of an Add node.
"""
# pylint: disable=missing-docstring
from __future__ import absolute_import as _abs
from ._ctypes._node import NodeBase, register_node
from ._ffi.node import NodeBase, register_node
from . import make as _make
class ExprOp(object):
......
......@@ -3,7 +3,7 @@ from __future__ import absolute_import as _abs
from .expr import Call as _Call
from . import make as _make
from ._ctypes._function import register_func as _register_func
from ._ffi.function import register_func as _register_func
from .api import convert
def call_packed(*args):
......
......@@ -8,7 +8,7 @@ from . import make as _make
from . import ir_pass as _pass
from . import collections as _collections
from ._base import string_types
from ._ctypes._node import NodeGeneric
from ._ffi.node import NodeGeneric
class WithScope(object):
"""Auxiliary scope with"""
......
......@@ -6,6 +6,6 @@ The functions are automatically exported from C++ side via PackedFunc.
Each api is a PackedFunc that can be called in a positional argument manner.
You can read "include/tvm/pass.h" for the function signature of these functions.
"""
from ._ctypes._function import _init_api
from ._ffi.function import _init_api
_init_api("tvm.ir_pass")
......@@ -6,6 +6,6 @@ The functions are automatically exported from C++ side via PackedFunc.
Each api is a PackedFunc that can be called in a positional argument manner.
You can use make function to build the IR node.
"""
from ._ctypes._function import _init_api
from ._ffi.function import _init_api
_init_api("tvm.make")
"""Container of compiled functions of TVM."""
from __future__ import absolute_import as _abs
from ._ctypes._function import ModuleBase, _init_module_module
from ._ctypes._function import _init_api
from ._ffi.function import ModuleBase, _init_module_module
from ._ffi.function import _init_api
class Module(ModuleBase):
......
......@@ -7,9 +7,9 @@ the correctness of the program.
from __future__ import absolute_import as _abs
import numpy as _np
from ._ctypes._ndarray import TVMContext, TVMType, NDArrayBase
from ._ctypes._ndarray import cpu, gpu, opencl, vpi, empty, sync
from ._ctypes._ndarray import _init_ndarray_module
from ._ffi.ndarray import TVMContext, TVMType, NDArrayBase
from ._ffi.ndarray import cpu, gpu, opencl, vpi, empty, sync
from ._ffi.ndarray import _init_ndarray_module
cl = opencl
......
......@@ -4,6 +4,6 @@ Normally user do not need to touch this api.
"""
# pylint: disable=unused-import
from __future__ import absolute_import as _abs
from ._ctypes._node import NodeBase, register_node
from ._ffi.node import NodeBase, register_node
Node = NodeBase
"""The computation schedule api of TVM."""
from __future__ import absolute_import as _abs
from ._ctypes._node import NodeBase, register_node
from ._ffi.node import NodeBase, register_node
from . import _api_internal
from . import tensor as _tensor
from . import expr as _expr
from . import collections as _collections
from ._ctypes._function import _init_api
from ._ffi.function import _init_api
@register_node
......
......@@ -14,7 +14,7 @@ Each statement node have subfields that can be visited from python side.
assert(st.buffer_var == a)
"""
from __future__ import absolute_import as _abs
from ._ctypes._node import NodeBase, register_node
from ._ffi.node import NodeBase, register_node
class Stmt(NodeBase):
pass
......
"""Tensor and Operation class for computation declaration."""
# pylint: disable=invalid-name
from __future__ import absolute_import as _abs
from ._ctypes._node import NodeBase, NodeGeneric, register_node, convert_to_node
from ._ffi.node import NodeBase, NodeGeneric, register_node, convert_to_node
from . import _api_internal
from . import make as _make
from . import expr as _expr
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment