manupa-arm commented on a change in pull request #7304:
URL: https://github.com/apache/tvm/pull/7304#discussion_r577034960
##########
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:
Well, agreed. Here I did not mean to discuss the agreed composite
target. (I think it could be quite useful to have it accessible in the
PassContext :) )
So the matter of constructing of hierarchical target should be an internal
choice of tvm -- whether the TargetRegistry offers a constructor or TVMC does
the translation. However, what we should decide is what we are going to provide
the user with ? and that should be intuitive and complexities should be
justified for the different usecase it opens up for the user.
So, once we decide on that, I think it may sound this conversion should be
handled by TargetRegistry as it is aware of the details a flat target(and
kinds) and how it should be translated to the hierarchical target that is
eventually stored in PassContext, I suppose. Therefore, if there is a unique
1:1 mapping to a hierarchical target from a flat target, I think flat target
might be preferred from TVMC.
But then again, I might be wrong if there is 1:many mapping to a
hierarchical target from a flat target where use wants to pick one (this what I
meant by a useful degree of freedom). Do you have something in mind to that
regard ?
----------------------------------------------------------------
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:
[email protected]