Fix ifelse crash and gpu support

- [x] fix ifelse crash
- [ ] gpu/cpu support
pep8 tell to add an empty line at the end of a file.