You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2021/10/17 00:49:24 UTC

[GitHub] [tvm] electriclilies commented on a change in pull request #9282: [CORE][Relay] Swap and remove compile_engine with te_compiler followup of #8775

electriclilies commented on a change in pull request #9282:
URL: https://github.com/apache/tvm/pull/9282#discussion_r730058969



##########
File path: python/tvm/relay/backend/te_compiler.py
##########
@@ -275,6 +256,46 @@ def select_implementation(op, attrs, inputs, out_type, target, use_autotvm=True)
     return best_plevel_impl, outputs[best_plevel_impl]
 
 
+@tvm._ffi.register_object("relay.TECompiler")
+class TECompiler(Object):
+    """TECompiler to get lowered code."""
+
+    def __init__(self):
+        raise RuntimeError("Cannot construct a TECompiler")
+
+    def lower(self, source_func, target=None, mod_name="default"):
+        """Lower a source_func to a CachedFunc.
+
+        Parameters
+        ----------
+        source_func : Union[tvm.relay.Function, CCacheKey]
+            The source relay function.
+
+        target : tvm.Target
+            The target platform.
+
+        Returns
+        -------
+        cached_func: CachedFunc
+            The result of lowering.
+        """
+        # pylint: disable=broad-except, import-outside-toplevel
+        try:
+            mod_name = mangle_module_name(mod_name)
+            key = _get_cache_key(source_func, target)
+            print(key)

Review comment:
       A stray print!

##########
File path: python/tvm/relay/backend/te_compiler.py
##########
@@ -79,24 +78,6 @@ def _get_cache_key(source_func, target):
     return source_func
 
 
-def get_shape(shape):
-    """Convert the shape to correct dtype and vars."""
-    ret = []
-    for dim in shape:
-        if isinstance(dim, tvm.tir.IntImm):
-            if libinfo()["INDEX_DEFAULT_I64"] == "ON":
-                ret.append(dim)
-            else:
-                val = int(dim)
-                assert val <= np.iinfo(np.int32).max
-                ret.append(tvm.tir.IntImm("int32", val))
-        elif isinstance(dim, tvm.tir.Any):
-            ret.append(te.var("any_dim", "int32"))
-        else:
-            ret.append(dim)
-    return ret
-
-

Review comment:
       What is this replaced with?

##########
File path: tests/python/contrib/test_vitis_ai/infrastructure.py
##########
@@ -18,24 +18,23 @@
 
 """Expose Vitis-AI test functions to the Python frontend"""
 
+from tvm.contrib import utils
+from tvm.contrib import graph_executor
+from tvm.contrib.target import vitis_ai
+from tvm.relay.build_module import bind_params_by_name
+from tvm.relay.op.contrib.vitis_ai import partition_for_vitis_ai
+from tvm.relay import transform
+from tvm import runtime
+from tvm import relay
+import tvm
+import pyxir.contrib.target.DPUCZDX8G
+import pyxir.contrib.target.DPUCADX8G
 import sys

Review comment:
       Did you mean to reorder this? looks like now you are importing pyxir before the pytest.importorskip("pyxir") line.

##########
File path: python/tvm/relay/backend/te_compiler.py
##########
@@ -275,6 +256,46 @@ def select_implementation(op, attrs, inputs, out_type, target, use_autotvm=True)
     return best_plevel_impl, outputs[best_plevel_impl]
 
 
+@tvm._ffi.register_object("relay.TECompiler")
+class TECompiler(Object):
+    """TECompiler to get lowered code."""
+
+    def __init__(self):
+        raise RuntimeError("Cannot construct a TECompiler")
+
+    def lower(self, source_func, target=None, mod_name="default"):
+        """Lower a source_func to a CachedFunc.
+
+        Parameters
+        ----------
+        source_func : Union[tvm.relay.Function, CCacheKey]
+            The source relay function.
+
+        target : tvm.Target
+            The target platform.
+
+        Returns
+        -------
+        cached_func: CachedFunc
+            The result of lowering.
+        """
+        # pylint: disable=broad-except, import-outside-toplevel
+        try:
+            mod_name = mangle_module_name(mod_name)

Review comment:
       Why do name mangling here instead of in TECompilerLower?

##########
File path: python/tvm/relay/backend/te_compiler.py
##########
@@ -79,24 +78,6 @@ def _get_cache_key(source_func, target):
     return source_func
 
 
-def get_shape(shape):
-    """Convert the shape to correct dtype and vars."""
-    ret = []
-    for dim in shape:
-        if isinstance(dim, tvm.tir.IntImm):
-            if libinfo()["INDEX_DEFAULT_I64"] == "ON":
-                ret.append(dim)
-            else:
-                val = int(dim)
-                assert val <= np.iinfo(np.int32).max
-                ret.append(tvm.tir.IntImm("int32", val))
-        elif isinstance(dim, tvm.tir.Any):
-            ret.append(te.var("any_dim", "int32"))
-        else:
-            ret.append(dim)
-    return ret
-
-

Review comment:
       Oops, now I see this was just moved. Nevermind




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org