hughperkins / DeepCL

OpenCL library to train deep convolutional neural networks
Mozilla Public License 2.0
866 stars 200 forks source link

Added a substitute tanh function #60

Closed wbernoudy closed 8 years ago

wbernoudy commented 8 years ago

This is to avoid the tanh function which the Clover driver for OpenCL 1.1 doesn't seem to provide.

battlesnake commented 8 years ago

Does that macro calculate four exponentials? If we don't care about non-GCC compilers, we can use expression macros to avoid that, something like:

({ float _a = exp(x), _b = exp(-x); ((_a - _b) / (_a + _b)) })
wbernoudy commented 8 years ago

Yup, that makes a lot of sense. It's quite inefficient for a simple function being called so much. I'm a C noob, I didn't know you could use macros like that.

I couldn't actually get it to work within the macro. However, I just declared a new function in cl/activation.cl and used that in the other macros which seems to work fine.

I just realized I accidentally made this PR for the master branch when it should be for clover-compatibility. Is there a way to change it? Or should I make a new PR? Thanks!

hughperkins commented 8 years ago

Apparently you cant create a PR to a non-existent branch, so I've pushed your branch directly to a new branch at https://github.com/hughperkins/DeepCL/tree/clover-compatibility

hughperkins commented 8 years ago

(I've also removed static from the cl files in 92bb336

hughperkins commented 8 years ago

(By the way, William, you might want to check that your email address in your ~/.gitconfig matches with your github email address, that way your account shows up as a contributor and so on)