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 2022/04/11 17:56:50 UTC

[GitHub] [tvm] areusch commented on a diff in pull request #10941: TVMC: Add new text/relay frontend

areusch commented on code in PR #10941:
URL: https://github.com/apache/tvm/pull/10941#discussion_r847595319


##########
python/tvm/driver/tvmc/frontends.py:
##########
@@ -284,13 +285,48 @@ def load(self, path, shape_dict=None, **kwargs):
         return relay.frontend.from_paddle(prog, shape_dict=shape_dict, **kwargs)
 
 
+class RelayFrontend(Frontend):
+    """Relay frontend for TVMC"""
+
+    @staticmethod
+    def name():
+        return "relay"
+
+    @staticmethod
+    def suffixes():
+        return ["relay"]
+
+    def load(self, path, shape_dict=None, **kwargs):
+        with open(path, "r", encoding="utf-8") as relay_text:
+            text = relay_text.read()
+        if shape_dict is not None:
+            logger.warning("Supplied shape_dict argument ignored for text frontend")
+        ir_mod = parser.fromtext(text)
+
+        def _gen_params(ir_mod):
+            """Populate the all the params in the mode with ones."""
+            main_func = ir_mod["main"]
+            shape_dict = {p.name_hint: p.checked_type.concrete_shape for p in main_func.params}
+            type_dict = {p.name_hint: p.checked_type.dtype for p in main_func.params}
+            params = {}
+            for name, shape in shape_dict.items():
+                data = np.ones(shape).astype(type_dict[name])

Review Comment:
   any thoughts on supplying data in e.g. `.npz`?



-- 
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