andersbll / cudarray

CUDA-based NumPy
MIT License
233 stars 61 forks source link

fp16 #47

Open filmo opened 8 years ago

filmo commented 8 years ago

Is it possible to set up arrays using FP16 rather than FP32 ?? (I didn't see anything obvious. Looks like the code using fp32 right now. I seem to recall seeing it being set to 32 somewhere in the code.)

If fp16 is possible, is it possible to convert fp32 arrays to fp16 directly as it is doing type conversion in numpy?

andersbll commented 8 years ago

Good question! FP16 is not supported at the moment. I expect it would be fairly straightforward (but tedious) to add FP16 to all the CUDA kernels. Maybe it's easier to simply replace all occurrences of FP32 with FP16 as a hack.

filmo commented 8 years ago

I've only dabbled with CUDA and C++. I see many of the kernels taking 'float' as their data type. Would each kernel need to be duplicated to take half floats? or is it possible with templating to abstract this so that any particular type of float or int can be handled through redirection?

andersbll commented 8 years ago

I think all kernels have types as template parameters. Thus, you can add float16 support by instantiating template functions with float16. Alternatively you can try to change all occurences of float32 to float16.