-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ti.ndrange
does not check for number of parameters
#6351
Comments
In fact the use of the ndrange-for in Python scope is a use of grouped ndrange-for... I've come up with an idea that we treat the use of ndrange-for with only one loop variable but has many dimensions automatically as a grouped ndrange-for (maybe we can do the same thing on the struct for too). In this way the syntax of Python and Taichi can be united, and the |
For ndrange deprecating For struct-fors, if we deprecate If we only deprecate it for |
What about a subclass of |
TBH, that would be a little tricky to understand by users, given it's neither a scalar nor a vector... |
It is actually a scalar and a vector (with one element). |
Given this only happens when there is only one loop variable and the field has only one dimension, I think it is not that hard to understand...... |
While it may be understandable by some of the users, it does break the uniformity. If we use |
I agree that we should not mix scalar and vector together. |
…not match the dimension of the ndrange (taichi-dev#6360) Issue: taichi-dev#6351 ### Brief Summary Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
…mension of the ndrange (taichi-dev#6422) Issue: fixes taichi-dev#6351 Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Describe the bug
ti.ndrange
does not report an error or warning even when the number of parameters does not match.To Reproduce
As shown in the code example above, a user who is unfamiliar with
ti.ndrange
's syntax might expect the printing result ofiter()
to be1, 2, 3, 4, 5, 6, 7
; however, sinceti.ndrange
requires a parentheses for each index and the users forgot to include one, the results might be unexpected. It's probably better to give a warning or error message when the number of index does not match the parameters inti.ndrange
.It's also confusing that the same syntax yields different results for Taichi scope and Python scope. If this kind of mismatch is allowed (with a warning but not an error), then the current behavior in Python scope seems to be more reasonable than the results in Taichi scope.
The text was updated successfully, but these errors were encountered: