[lang] Make dynamic indexing compatible with grouped loop indices of struct fors #3218
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related issue = #2590, #2637
One of the remaining issues in #2637 is that grouped loop indices of struct fors are exposed to users as
ti.Vector
however they are (naturally) implemented as individual variables, therefore dynamic indexing cannot work here. My solution is different from the idea in #2637: instead of making members ofti.Vector
loopable, I prefer to keep the individual variables and assign them to ati.Vector
so that the user API is not affected and we don't have to re-design the looping mechanism. Furthermore, after we implement complete optimization passes of tensor types in the future, theti.Vector
allocation and assignments here can be eliminated, which leads to the same performance as before.