ti.kernel的报错?

为什么这段代码无法正确运行呢

import taichi as ti

ti.init(arch=ti.cpu)

dim = 2
vec = lambda: ti.Vector.field(dim, dtype=ti.f32)

pos = vec()
ti.root.dense(ti.ij, (5, 5)).place(pos)


@ti.kernel
def visualize():
    for i in range(5):
        for j in range(5):
            print(pos_np[i, j])


pos_np = pos.to_numpy()
while 1:
    visualize()

会得到报错信息

IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices   

而当我把visualize的修饰 @ti.kernel 注释掉后就可以正常运行了. 这是为什么呢?