def test(): a = 0 for i in range(4): val[i] = i * 10 ti.print(val[i]) if i % 2 == 0: a += i ti.print(a)
def p2g(f: ti.i32): for p in range(n_particles): base = x[f, p] * inv_dx ti.print(f) ti.print(p) new_F = (F[f, p]) @ F[f, p] F[f + 1, p] = new_F
def test(): for i in range(n): ti.print(i) s = 0 for j in range(10): s += j a = ti.Vector([0.4, 0.3]) val[i] = s + ti.cast(a.norm() * 100, ti.i32) + i
def update(): for i in ti.static(range(number_coeffs)): ti.print(i) ti.print(coeffs[i][None]) ti.print(coeffs[i].grad[None]) coeffs[i][None] -= learning_rate * coeffs[i].grad[None] coeffs[i].grad[None] = 0
def func(): while True: a = 0 ti.print(a)
def func(): for i in range(10): a = i ti.print(a)
def func(): if True: a = 0 else: a = 1 ti.print(a)
def func(): if 1 > 0: val = 1 ti.print(val)
def test_numpy(arr: np.ndarray): for i in range(4): ti.print(arr[i]) arr[i] = i * i
def kernel2(x: ti.i32, y: ti.f32): ti.print(x + y)
def kernel(x: ti.i32): ti.print(x)
def torch_kernel_2(t_grad: ti.ext_arr(), t: ti.ext_arr(), o_grad: ti.ext_arr()): for i in range(n): ti.print(o_grad[i]) t_grad[i] = 2 * t[i] * o_grad[i]
def test_struct(): for i in y: y[i] = i + 1 ti.print(i)
def test1(): for i in range(4): val[i] = i * 20 ti.print(val[i])
def torch_kernel_2(t_grad: np.ndarray, t: np.ndarray, o_grad: np.ndarray): for i in range(n): ti.print(o_grad[i]) t_grad[i] = 2 * t[i] * o_grad[i]