[REFACTOR][PY][API-CHANGE] establish tvm.ir, migrate corresponding files (#4862)
* [REFACTOR][PY][API-CHANGE] establish tvm.ir, migrate corresponding relay files.
This PR establishes tvm.ir and migrates the corresponding relay
files into the new folder.
API Change:
- relay.Module -> tvm.IRModule
* Update with ADT
* Migrate transform
* address comments
* Migrate module
* Migrate json_compact
* Migrate attrs
* Move LoweredFunc to stmt temporarily
* temp migrate container
* Finish migrate container
diff --git a/python/vta/build_module.py b/python/vta/build_module.py
index cec217c..df67faa 100644
--- a/python/vta/build_module.py
+++ b/python/vta/build_module.py
@@ -33,7 +33,7 @@
"""Try to do storage rewrite in early pass."""
try:
return tvm.ir_pass.StorageRewrite(stmt)
- except tvm.TVMError:
+ except tvm.error.TVMError:
return stmt
diff --git a/python/vta/top/graphpack.py b/python/vta/top/graphpack.py
index b14f937..76b3dc5 100644
--- a/python/vta/top/graphpack.py
+++ b/python/vta/top/graphpack.py
@@ -17,6 +17,7 @@
# pylint: disable=unused-argument
"""A Relay implementation of graph packing."""
+import tvm
from tvm import relay
from tvm.relay import op, transform
from tvm.relay import ExprMutator
@@ -24,7 +25,7 @@
def run_opt_pass(expr, opt_pass):
"""Exectue a relay pass."""
assert isinstance(opt_pass, transform.Pass)
- mod = relay.Module.from_expr(expr)
+ mod = tvm.IRModule.from_expr(expr)
mod = opt_pass(mod)
entry = mod["main"]
return entry if isinstance(expr, relay.Function) else entry.body
diff --git a/tutorials/autotvm/tune_relay_vta.py b/tutorials/autotvm/tune_relay_vta.py
index 4cf08e9..3221c3b 100644
--- a/tutorials/autotvm/tune_relay_vta.py
+++ b/tutorials/autotvm/tune_relay_vta.py
@@ -353,7 +353,7 @@
# Perform task extraction on Relay program
print("Extract tasks...")
relay_prog, params = compile_network(env, target, network, start_pack, stop_pack)
- mod = relay.Module.from_expr(relay_prog)
+ mod = tvm.IRModule.from_expr(relay_prog)
tasks = autotvm.task.extract_from_program(mod,
params=params,
ops=(tvm.relay.op.nn.conv2d, ),