Skip to content

Commit

Permalink
Update decorator code to fully use new MiniPython based frontend. (ap…
Browse files Browse the repository at this point in the history
…ache#20)

* Remove old decorator and port to new one.

* Repair tests

* Add module docstring

* Trigger another build

* Test to see if only this test
  • Loading branch information
jroesch committed Aug 16, 2018
1 parent af8600a commit 1440d3c
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 741 deletions.
2 changes: 1 addition & 1 deletion relay/python/relay/frontend/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#pylint: disable-all
"Frontends for Relay."
from relay.frontend.relay_decorator import *
from .mini_python import relay, get_env
3 changes: 3 additions & 0 deletions relay/python/relay/frontend/mini_python/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""The Python frontend for Relay."""
from .py_to_mini_py import compile_func, get_env
from .relay_decorator import relay
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import relay.ir as ir
import relay.make as relay_mk
import relay.visitor as relay_visit
import relay.frontend.mini_python.ir as mp
from . import ir as mp

class MiniPythonToRelay(ast.NodeVisitor):
bindings: List[Dict[ir.LocalId, Tuple[ir.Type, ir.Expr]]]
Expand Down
2 changes: 1 addition & 1 deletion relay/python/relay/frontend/mini_python/py_to_mini_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import relay.make as relay_mk
# pylint: disable=unused-import
from relay.operators import initialize_operators, __relay_tvm_context__
import relay.frontend.mini_python.ir as mp
from . import ir as mp

# Contains a global environment of all items.
__relay_environment__ = relay_mk.Environment({})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from relay.make import *
from relay.ir import BOp, UOp, Value
from relay.operators import __relay_tvm_context__
from .py_to_mini_py import compile_func
from .py_to_mini_py import compile_func, get_env
from .mini_py_to_relay import compile_global_defn

def relay_compile(f):
Expand All @@ -39,7 +39,6 @@ def marshal_argument(arg, _) -> ir.Value:
else:
raise Exception(f"unsupported argument type {type(arg)}")

# TODO(@weberlo): Replace current decorator usage with this one.
def relay(func):
"""The Relay decorator.
Expand All @@ -49,7 +48,7 @@ def relay(func):
"""
env = get_env()
try:
defn = compile_func(func)
defn = relay_compile(func)
env.add(defn)
except FrontendError as e:
get_env().display_errors()
Expand Down
Loading

0 comments on commit 1440d3c

Please sign in to comment.