You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
import taichi as ti
import torch
ti.init(arch=ti.cuda)
@ti.kernel
def foo(x: ti.types.ndarray(), y: ti.types.ndarray()):
for i in x:
# a = 0.0
# for j in y:
# a += y[j]
# x[i] += a
for j in y:
x[i] += y[j]
x = torch.tensor(
[0, 0, 0, 0, 0], dtype=torch.float32, device="cuda", requires_grad=True
)
y = torch.tensor([1, 2, 3], dtype=torch.float32, device="cuda", requires_grad=True)
foo(x, y)
x.grad = torch.ones_like(x)
foo.grad(x, y)
print(x.grad, y.grad)
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.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: