denizyuret / Knet.jl

Koç University deep learning framework.
https://denizyuret.github.io/Knet.jl/latest
Other
1.43k stars 230 forks source link

Bessel functions #265

Open salbert83 opened 6 years ago

salbert83 commented 6 years ago

CUDA j0, j1, y0, and y1 correspond to besselj0, besselj1, bessely0, and bessely1 from the package SpecialFunctions.jl. Would you recommend adding these by modifying unary.jl? Note the Bessel functions are not as simple as the functions which you currently supply. Please offer a suggestion. Thanks!

CarloLucibello commented 6 years ago

I'd say the more we get from CUDA the better it is! Why you say it is more complicated?

salbert83 commented 6 years ago

I noticed in unary.jl, the functions where the Julia SpecialFunctions.jl name differs from the CUDA name are entered as triplets such as ("abs2", "abs2", "(xi*xi)") Are you suggesting to just add the code for the Bessel function as a string in the triplet?

denizyuret commented 6 years ago

Yes, your guess is right.

If you add a triple ("cuda_name", "julia_name", "kernel_code") to the list it should make this new function available. The last two components are optional: julia_name is assumed to be the same as cuda_name if missing, and kernel_code is assumed to be just the cuda function call if missing. If there is a single component of the triple, parantheses are also optional.

When I first wrote this I wasn't sure what the different cuda bessel functions corresponded to (if anything) in the Julia standard library, so I left them out. You are welcome to add them in.

Another complication is if you want to train models, you need to add the gradients to AutoGrad.jl

deniz

On Wed, Feb 14, 2018 at 5:10 AM salbert83 notifications@github.com wrote:

I noticed in unary.jl, the functions where the Julia SpecialFunctions.jl name differs from the CUDA name are entered as triplets such as ("abs2", "abs2", "(xi*xi)") Are you suggesting to just add the code for the Bessel function as a string in the triplet?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/denizyuret/Knet.jl/issues/265#issuecomment-365472557, or mute the thread https://github.com/notifications/unsubscribe-auth/ABvNppja-UWPU8DzHWlPtQVHYdnYL_zRks5tUkB_gaJpZM4R2ntV .