Skip to content

Commit

Permalink
[PYTHON] Rename the namespace (dmlc#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
tqchen authored Apr 26, 2017
1 parent e4c7466 commit 7e03245
Show file tree
Hide file tree
Showing 22 changed files with 40 additions and 41 deletions.
2 changes: 1 addition & 1 deletion python/tvm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
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__
Expand Down
File renamed without changes.
20 changes: 10 additions & 10 deletions python/tvm/_ctypes/_function.py → python/tvm/_ffi/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

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
Expand Down Expand Up @@ -57,7 +57,7 @@ def cfun(args, type_codes, num_args, ret, _):

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):
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

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."""
Expand Down
4 changes: 2 additions & 2 deletions python/tvm/_ctypes/_node.py → python/tvm/_ffi/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
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
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions python/tvm/addon/verilog.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

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
Expand Down
11 changes: 5 additions & 6 deletions python/tvm/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@

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
Expand Down
4 changes: 2 additions & 2 deletions python/tvm/arith.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""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):
Expand Down
2 changes: 1 addition & 1 deletion python/tvm/codegen.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""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.
Expand Down
2 changes: 1 addition & 1 deletion python/tvm/collections.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""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
Expand Down
2 changes: 1 addition & 1 deletion python/tvm/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"""
# 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):
Expand Down
2 changes: 1 addition & 1 deletion python/tvm/intrin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

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):
Expand Down
2 changes: 1 addition & 1 deletion python/tvm/ir_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
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"""
Expand Down
2 changes: 1 addition & 1 deletion python/tvm/ir_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
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")
2 changes: 1 addition & 1 deletion python/tvm/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
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")
4 changes: 2 additions & 2 deletions python/tvm/module.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""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):
Expand Down
6 changes: 3 additions & 3 deletions python/tvm/ndarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
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

Expand Down
2 changes: 1 addition & 1 deletion python/tvm/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"""
# 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
4 changes: 2 additions & 2 deletions python/tvm/schedule.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""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
Expand Down
2 changes: 1 addition & 1 deletion python/tvm/stmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion python/tvm/tensor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""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
Expand Down

0 comments on commit 7e03245

Please sign in to comment.