예제 #1
0
 def func():
     # Two loops, one with stop grad on without
     for i in range(n):
         ti.stop_grad(x)
         loss[None] += x[i]**2
     for i in range(n):
         loss[None] += x[i]**2
예제 #2
0
 def func():
     # Two loops, one with stop grad on without
     for i in range(n):
         ti.stop_grad(x)
         ti.atomic_add(loss, x[i]**2)
     for i in range(n):
         ti.atomic_add(loss, x[i]**2)
예제 #3
0
 def func():
     for i in range(n):
         ti.stop_grad(x)
         loss[None] += x[i]**2