如何遍历某个snode下的所有的值

我把空间分为了(4096,4096,4096)个网格,然后在每个网格中用bitmaskd存储对应 的数据。我想遍历具体某个网格底下所有的值,比如 for k in block2[16,16,16]: ,这时候出现了 AttributeError: ‘SNode’ object has no attribute ‘getitem’。 请问该如何解决?我也尝试了dynamic snode,但是因为dynamic snode没法进行pop,所有后续的很多操作无法完成。如果再进行遍历leaf节点并检查是否active,耗时又很久。实在是没办法解决了。

import taichi as ti
ti.init(arch=ti.cuda, default_fp=ti.f32)
indices = ti.ijk
grid_size = 4096
offset = tuple(-grid_size // 8 for _ in range(3))
pid = ti.field(ti.i32)
dim = 3
grid_block_size = 128
grid = ti.root.pointer(ti.ijk, 32)
block = grid.pointer(ti.ijk, 32)
block2 = block.pointer(ti.ijk, 4)
MAX_G = 64
leaf = block2.bitmasked(ti.axes(3), MAX_G)
leaf.place(pid)
print('grid', grid.shape)
print('block', block.shape)
print('block2', block2.shape)
print('leaf', leaf.shape)
print('pid', pid.shape)
# grid (32, 32, 32)
# block (1024, 1024, 1024)
# block2 (4096, 4096, 4096)
# leaf (4096, 4096, 4096, 64)
# (4096, 4096, 4096, 64)
@ti.kernel
def init_pid():
    for k in range(3):
        pid[16, 16, 16, k] = 1
        pid[32, 32, 32, k] = 1
        # .....

    n = 0
    for I in ti.grouped(block2):
        print(I) # ok
        n+=1
    print('block2 active',n)

init_pid()


@ti.kernel
def get_pid():
    # for k in block2[16,16,16]:
    #     print(k) # wrong
    for k in range(64):
        if ti.is_active(leaf, [16,16,16,k]):
            print(k, pid[16,16,16,k])  # slow

get_pid()