leandron commented on a change in pull request #7304:
URL: https://github.com/apache/tvm/pull/7304#discussion_r572098966



##########
File path: python/tvm/driver/tvmc/common.py
##########
@@ -76,6 +98,165 @@ def convert_graph_layout(mod, desired_layout):
             )
 
 
+def validate_targets(parse_targets):
+    """
+    Apply a series of validations in the targets provided via CLI.
+    """
+    targets = [t["kind"] for t in parse_targets]
+
+    if len(targets) > len(set(targets)):
+        raise TVMCException("Duplicate target definitions are not allowed")
+
+    if targets[-1] not in TVM_TARGETS:
+        raise TVMCException(f"The last target needs to be a TVM target. 
Choices: {TVM_TARGETS}")
+
+    tvm_targets = [t for t in targets if t in TVM_TARGETS]
+    tvm_targets_count = len(tvm_targets)
+    if tvm_targets_count > 1:
+        verbose_tvm_targets = ", ".join(tvm_targets)
+        raise TVMCException(
+            f"Only one of the following targets can be used at a time. "
+            "Found {tvm_targets_count}: {verbose_tvm_targets}."
+        )
+
+
+def tokenize_target(target):

Review comment:
       Despite being  short, I think it still worth being a standalone 
function, in order to simplify testing.




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


Reply via email to