Concisely describe the proposed feature
I found it's hard to locate where the first NAN was calculated when I use Taichi to write MPM simulation code, once a NAN exist, the calculation iterations will spread it to everywhere. It seems Taichi hasn't included NAN judge function and because of parallelism and numbers of particles, locate the problem is still challenging for me.
Describe the solution you'd like (if any)
Add library functions like insan(), isinf().
Throw reasonable exception information in debug mode when encountered NAN.
Additional comments
My Macbook system version is OS X 10.11.6, for some reasons it can't update but have enough calculation resources, could Taichi support OS X 10.11.6 next time? :P
For the isnan and isinf, consider install taichi_glsl, an extension library:
pip install taichi_glsl
or simply define one yourself:
@ti.func
def isnan(x):
return not (x >= 0 or x <= 0)
For the throw exception when NAN detected on debug mode, use the assert statement with ts.isnan:
import taichi as ti
import taichi_glsl as ts
ti.init(debug=True) # `assert` only works in debug mode
@ti.kernel
def substep():
...
assert not ts.isnan(x), "some message" # insert this statement to some critical points
...
For the OS X 10.11.6, sorry about the trouble, @yuanming-hu would you mind help to support taichi on 10.11.6?
It works. Thanks! : )
Glad that this issue has been resolved.
For the
OS X 10.11.6, sorry about the trouble, @yuanming-hu would you mind help to supporttaichion 10.11.6?
Sorry, but we have to prioritize on supporting OS X 10.14+...
Most helpful comment
For the
isnanandisinf, consider installtaichi_glsl, an extension library:or simply define one yourself:
For the
throw exception when NAN detected on debug mode, use theassertstatement withts.isnan:For the
OS X 10.11.6, sorry about the trouble, @yuanming-hu would you mind help to supporttaichion 10.11.6?