前辈们好,向请教关于ti.static在for loop中运用的问题。代码如下:
> @ti.kernel
> def streaming(self):
> for I in ti.grouped(self.is_solid):
> for s in ti.static(range(Q)):
> neighbor_pos = self.periodic_index(I + self.e[s])
> if (self.is_solid[neighbor_pos] == 0):
> self.f[neighbor_pos][s] = self.F[I][s]
> else:
> self.f[I][self.REVERSED_E[s]] = self.F[I][s]
其中self.REVERSED_E是一个constant scalar field. 运行时会报错:
The 0-th index of a Matrix/Vector must be a compile-time constant integer, got <class ‘taichi.lang.expr.Expr’>.\nThis is because matrix operations will be unrolled at compile-time for performance reason
除了设置dynamic_index=True之外还有什么办法么?这个class其他member function不需要dynamic_index =True, 会变慢。
非常感谢!!