Fix ifelse crash and gpu support

- [x] fix ifelse crash
- [ ] gpu/cpu support
you should use out.type