Open liamxu1 opened 1 year ago
Hi @liamxu1 , thanks for reporting this. The main issue you mentioned here is confirmed as a bug. The fix is submitted in PR #7778 .
The for...continue
and while
statement are not supported currently in Taichi autodiff.
Though the control flows can be handled, the pure nested loops as your modification are more friendly to the autodiff system.
Thanks for the fast reply. I will give it a try.
Excuse me @erizmr, is there a way I can experience the fixed version? I tried to clone the code in your branch and follow https://docs.taichi-lang.org/docs/dev_install to compile the code, but it failed with a DLL loading error.
Hi @liamxu1 , could you please share more error info e.g., screenshots ?
I am trying to differentiate a complicated calculation with diff-Taichi, which includes nested range-for statements where the inside loop range depends on the outside loop index. Besides, there can be lots of condition statements.
I tried to reproduce the error with simple codes and below is what I got.
In both cuda and x64 backend, the code fails with information
However, if I change the code to
the code just works fine.
I am wondering what is the suggested way to write such loops. Am I violating the rule "Kernel body must only consist of either multiple for-loops or non-for statements" or is it something else? In addition, I noticed that the code may also fail if I use "for ... continue ...", are there any more rules I should know about when dealing with for statements and if statements by Taichi autodiff?
e.g. The below code will fail
Looking forward to your reply. Many thanks.