矩阵规模过大,导致编译时间过长

UserWarning: Taichi matrices/vectors with 4x27 > 32 entries are not suggested. Matrices/vectors will be automatically unrolled at compile-time for performance. So the compilation time could be extremely long if the matrix size is too big. You may use a field to store a large matrix like this, e.g.:
x = ti.field(ti.f32, (4, 27)).

在mls-mpm的实现中,需要用到一个27*4的M矩阵

d_vecs = ti.Vector([0,]*27).cast(float)
diag = ti.Matrix.identity(float, 27)
temp = ti.Vector([0,0,0,0]).cast(float)
Q = ti.Matrix.rows([temp,]*27) 

image

以及后续还要对矩阵进行转置和求逆操作。如果按照提示转换成field,那又要如何对field进行矩阵乘法及求逆等操作呢?
或者说还有其他的解决方法缩短编译时间。

目前Taichi主要支持小矩阵,转换成field后,矩阵的操作需要自己手写;也可以用Taichi的sparse matrix solver来做,可以参考文档:Sparse Matrix | Taichi Docs

减少编译时长的话,可以尝试避免在kernel中定义d_vecs = ti.Vector([0,]*27).cast(float) (编译时会展开),而把这些变量定义成kernel外的field

2 个赞

请问能否隐藏这些warnings呢?