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/02/16 12:15:21 UTC

[GitHub] [tvm] manupa-arm commented on a change in pull request #7304: [TVMC] Add composite target passes for compilation and tuning

manupa-arm commented on a change in pull request #7304:
URL: https://github.com/apache/tvm/pull/7304#discussion_r576778307



##########
File path: python/tvm/driver/tvmc/common.py
##########
@@ -91,18 +272,37 @@ def target_from_cli(target):
     -------
     tvm.target.Target
         an instance of target device information
+    codegens : list of dict
+        This list preserves the order in which codegens were
+        provided via command line. Each Dict contains three keys:
+        'kind', containing the name of the codegen; 'opts' containing
+        a key-value for all options passed via CLI; 'raw',
+        containing the plain string for this codegen
     """
+    extra_codegens = []
 
     if os.path.exists(target):
         with open(target) as target_file:
-            logger.info("using target input from file: %s", target)
+            logger.info("target input is a path: %s", target)
             target = "".join(target_file.readlines())
+    elif is_inline_json(target):
+        logger.info("target input is inline JSON: %s", target)
+    else:
+        logger.info("target input is plain text: %s", target)
+        try:
+            parsed_targets = parse_target(target)
+        except ValueError as ex:
+            raise TVMCException(f"Error parsing target string '{target}'.\nThe error was: {ex}")
+
+        validate_targets(parsed_targets)
+        target = parsed_targets[-1]["raw"]
+        extra_codegens = parsed_targets[:-1] if len(parsed_targets) > 1 else []
 
     # TODO(@leandron) We don't have an API to collect a list of supported
     #       targets yet
     logger.debug("creating target from input: %s", target)
 
-    return tvm.target.Target(target)
+    return tvm.target.Target(target), extra_codegens

Review comment:
       Im kind of inclined to agree with @leandron.
   
   For me, apart from the syntax, JSON provides a hierarchical target structure that is valuable for internal tvm components. I think we need to think hard whether this hierarchical structure provides a real degree of freedome to the user -- For e.g., should the user be concerned about target_host and kind ? if so what would that enable the user from doing something different from the command line.
   
   I guess my concern is given a set of target kinds and a host, is there a true degree of freedom in which the composite target could be assembled (differently) that means a different thing for tvm. If not my humble opinion is that there is no value exposing this interface to the user. WDYT ?
   
   If you have something in mind, please do share an example where this logic fails -- happy to discuss.




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

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