taichi-dev / difftaichi

10 differentiable physical simulators built with Taichi differentiable programming (DiffTaichi, ICLR 2020)
2.47k stars 260 forks source link

How to detach variable from gradient computation in tachi-scope #39

Open wangsd01 opened 3 years ago

wangsd01 commented 3 years ago

I was thinking to detach a variable from gradient computation in ti.kernel.

E.g y = copy(x).detach() f(x) = 5x + 6y I hope df/dx = 5, not 11.

How can I do the above process in py-taichi? Thank you!