Fix ifelse crash and gpu support

- [ ] fix ifelse crash
- [ ] gpu/cpu support