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/12/01 18:12:01 UTC

[GitHub] [tvm] vinx13 commented on a change in pull request #9620: [TVMScript] Add for loop syntax sugar

vinx13 commented on a change in pull request #9620:
URL: https://github.com/apache/tvm/pull/9620#discussion_r760452389



##########
File path: python/tvm/script/parser.py
##########
@@ -272,6 +272,13 @@ def parse_arg_list(self, func, node_call):
                 f"but it is {type(func).__name__}",
                 node_call.span,
             )
+
+        # for loop syntax sugar, check if starting 0 is omitted
+        # param_list[0] is the list of positional args which could include kw_args
+        # therefore the sum of len(args) and len(kw_args) is used here
+        if isinstance(func, ForScopeHandler) and len(args) + len(kw_args) < len(param_list[0]):
+            if args[0] != 0:
+                args.insert(0, 0)

Review comment:
       if possible I'd prefer implementing such logic in `ForScopeHandler` (or its subclasses like `Parallel`, `Vectorized`, etc.) to separate the details of these statements from the parser. see the example here https://github.com/apache/tvm/blob/main/python/tvm/script/tir/scope_handler.py#L591-L593




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