Skip to content

Commit

Permalink
Improve code style, python wrapper and test cases (apache#11)
Browse files Browse the repository at this point in the history
* Update c++ code style and unit test

* Update python State wrapper and test cases
  • Loading branch information
merrymercy committed Jun 20, 2020
1 parent e52135f commit 1fe6638
Show file tree
Hide file tree
Showing 43 changed files with 2,461 additions and 2,595 deletions.
8 changes: 8 additions & 0 deletions python/tvm/ansor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
# pylint: disable=unused-import, redefined-builtin
"""Namespace for Ansor autoSchedule"""

from . import compute_dag
from . import measure
from . import serialization
from . import loop_state
from . import task
from . import utils

# Shortcut
from .compute_dag import ComputeDAG
from .task import SearchTask, MetaTileRewritePolicy, TuneOption
from .task import auto_schedule
Expand Down
3 changes: 2 additions & 1 deletion python/tvm/ansor/_ffi_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
"""FFI APIs for tvm.ansor"""

"""Register FFI APIs from C++ for the namespace tvm.ansor"""
import tvm._ffi


Expand Down
18 changes: 8 additions & 10 deletions python/tvm/ansor/compute_dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=unused-import
""" ... """

""" Computational graph and its analysis tools """

import tvm._ffi
from tvm.runtime import Object

from .state import State

from .loop_state import State
from . import _ffi_api


Expand Down Expand Up @@ -50,13 +48,13 @@ def get_init_state(self):
-------
state : State
"""
return _ffi_api.ComputeDAGGetInitState(self)
return State(_ffi_api.ComputeDAGGetInitState(self))

def apply_steps_from_state(self, state, layout_rewrite_level=None):
"""
Parameters
----------
state : State
state : StateObject
layout_rewrite_level : LayoutRewriteLevel(***)
Returns
Expand All @@ -71,7 +69,7 @@ def print_python_code_from_state(self, state):
"""
Parameters
----------
state : State
state : StateObject
Returns
-------
Expand All @@ -83,10 +81,10 @@ def infer_bound_from_state(self, state):
"""
Parameters
----------
state : State
state : StateObject
Returns
-------
state : State
state : StateObject
"""
return _ffi_api.ComputeDAGInferBoundFromState(self, state)
2 changes: 1 addition & 1 deletion python/tvm/ansor/cost_model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
# specific language governing permissions and limitations
# under the License.
# pylint: disable=unused-import, redefined-builtin
""" ... """
""" Cost model that estimates the performance of programs """

from .cost_model import RandomModel
8 changes: 2 additions & 6 deletions python/tvm/ansor/cost_model/cost_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=unused-import
""" ... """

""" Cost model that estimates the performance of programs """
import ctypes
import numpy as np

import tvm._ffi
from tvm.runtime import Object

from .. import _ffi_api


Expand All @@ -32,9 +31,6 @@ class CostModel(Object):

@tvm._ffi.register_object("ansor.RandomModel")
class RandomModel(Object):
"""
"""

def __init__(self):
self.__init_handle_by_constructor__(_ffi_api.RandomModel)

Expand Down
Loading

0 comments on commit 1fe6638

Please sign in to comment.