junrushao1994 commented on a change in pull request #6315:
URL: https://github.com/apache/incubator-tvm/pull/6315#discussion_r474217829



##########
File path: python/tvm/target/target.py
##########
@@ -364,9 +394,11 @@ def create(target_str):
     ----
     See the note on :py:mod:`tvm.target` on target string format.
     """
-    if isinstance(target_str, Target):
+    if isinstance(target, Target):
         return target_str
-    if not isinstance(target_str, str):
-        raise ValueError("target_str has to be string type")
+    if isinstance(target, dict):
+        return _ffi_api.TargetFromConfig(target)
+    if isinstance(target, str):
+        return _ffi_api.TargetFromString(target)

Review comment:
       Shall we also do some guessing work as well for strings? If it is a 
string but seems like a JSON, we can use `json.loads` instead.
   
   ```suggestion
       if isinstance(target, str):
           if target.startswith("{"):
             return _ffi_api.TargetFromConfig(json.loads(target))
           else:
             return _ffi_api.TargetFromString(target)
   ```




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