Skip to content

Commit

Permalink
[Refactor] move vm.py under runtime and adt to runtime.container.py (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiics authored and alexwong committed Feb 28, 2020
1 parent ae79ce8 commit 0771b02
Show file tree
Hide file tree
Showing 23 changed files with 481 additions and 440 deletions.
55 changes: 1 addition & 54 deletions python/tvm/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"""Container data structures used in TVM DSL."""
import tvm._ffi

from tvm.runtime import Object, ObjectTypes
from tvm.runtime import Object
from tvm.runtime.container import getitem_helper
from tvm.runtime import _ffi_node_api
from . import _api_internal
Expand Down Expand Up @@ -104,56 +104,3 @@ class LoweredFunc(Object):
MixedFunc = 0
HostFunc = 1
DeviceFunc = 2


@tvm._ffi.register_object("vm.ADT")
class ADT(Object):
"""Algebatic data type(ADT) object.
Parameters
----------
tag : int
The tag of ADT.
fields : list[Object] or tuple[Object]
The source tuple.
"""
def __init__(self, tag, fields):
for f in fields:
assert isinstance(f, ObjectTypes), "Expect object or " \
"tvm NDArray type, but received : {0}".format(type(f))
self.__init_handle_by_constructor__(_ADT, tag, *fields)

@property
def tag(self):
return _GetADTTag(self)

def __getitem__(self, idx):
return getitem_helper(
self, _GetADTFields, len(self), idx)

def __len__(self):
return _GetADTSize(self)


def tuple_object(fields=None):
"""Create a ADT object from source tuple.
Parameters
----------
fields : list[Object] or tuple[Object]
The source tuple.
Returns
-------
ret : ADT
The created object.
"""
fields = fields if fields else []
for f in fields:
assert isinstance(f, ObjectTypes), "Expect object or tvm " \
"NDArray type, but received : {0}".format(type(f))
return _Tuple(*fields)


tvm._ffi._init_api("tvm.container")
1 change: 0 additions & 1 deletion python/tvm/relay/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
from . import param_dict
from . import feature
from .backend import vm
from .backend import profiler_vm

# Root operators
from .op import Op
Expand Down
2 changes: 1 addition & 1 deletion python/tvm/relay/backend/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import numpy as np

from tvm import container
from tvm.runtime import container
from . import _backend
from .. import _make, analysis, transform
from .. import module
Expand Down
Loading

0 comments on commit 0771b02

Please sign in to comment.