Open chenzhekl opened 11 months ago
Ok the problem is that the Taichi compiler does not reject use of "struct-for" in an inner loop -- the line of for j in y
in the code.
Write something like:
@ti.kernel
def foo(x: ti.types.ndarray(), y: ti.types.ndarray()):
for i in x:
for j in range(y.shape[0]):
x[i] += y[j]
Meanwhile, we should add a guard to emit an error message when struct-for
is used inside the loop
Describe the bug A clear and concise description of what the bug is, ideally within 20 words.
The same algorithm of different forms produces different gradients.
To Reproduce Please post a minimal sample code to reproduce the bug. The developer team will put a higher priority on bugs that can be reproduced within 20 lines of code. If you want a prompt reply, please keep the sample code short and representative.
The above code outputs
while the commented-out code, which does the same thing, outputs:
Log/Screenshots Please post the full log of the program (instead of just a few lines around the error message, unless the log is > 1000 lines). This will help us diagnose what's happening. For example:
Additional comments If possible, please also consider attaching the output of command
ti diagnose
. This produces the detailed environment information and hopefully helps us diagnose faster.If you have local commits (e.g. compile fixes before you reproduce the bug), please make sure you first make a PR to fix the build errors and then report the bug.