taichi: If condition must be int32 error
To reproduce:
import taichi as ti
ti.init(default_ip=ti.i64)
@ti.kernel
def test():
for i in range(100):
if i % 2 == 0:
print(i)
test()
The above code reports error
taichi.lang.exception.TaichiTypeError:
`if` conditions must be of type int32; found i64. Consider using `if x != 0` instead of `if x` for float values.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 16 (6 by maintainers)
After I applied this modification,I can use four int64 to simulate float256 and draw this in 10^-55 precision 😃 Re:-0.6717536270481832370389902348813046305959745988723619134343491834092885898911496280 Im:0.4609205425545165168733304746281937721035176497122051662619296867035239619125442493 zoom:2.28E54
Thanks again for your efficient bug fix.
Here are the basic code: https://github.com/SuperWildFireFox/MandelbrotZoom/blob/main/FLOAT/FLOAT256.py
Maybe one or two days later, I will release my code.It is just an experimental program, but the efficiency is satisfactory to me.
I also tried this:
still output:
whileconditions must be of type int32; found i64. Consider usingwhile x != 0instead ofwhile xfor float values.and thank you for your quick reply.
output:
whileconditions must be of type int32; found i64. Consider usingwhile x != 0instead ofwhile xfor float values.it will still happened in while loop
Currently we use
i32to represent boolean and it is self-contained. The bug in this issue is due to wrong implementation, and can be easily fixed by #5487.i1is only a nice-to-have for now, and we may plan it in some future version like v1.3 or so.