cornell-zhang / heterocl

HeteroCL: A Multi-Paradigm Programming Infrastructure for Software-Defined Heterogeneous Computing
https://cornell-zhang.github.io/heterocl/
Apache License 2.0
326 stars 92 forks source link

How can I calculate atan2 with HeteroCL? #396

Open MariusWiggert opened 3 years ago

MariusWiggert commented 3 years ago

This is probably a really dumb question but unfortunately I couldn't find an answer in the last hours. Is there an easy way to calculate the atan with heterocl? I found the python API for sin, cos, tanh, but not atan.

Help is highly appreciated!

Marius

seanlatias commented 3 years ago

We don't have such API unfortunately. You will need to write your own function to calculate the (approximate) value of arctangent.

seanlatias commented 3 years ago

One way is to use Taylor series expansion. You may find this article useful.

MariusWiggert commented 3 years ago

Thanks for clarifying @seanlatias ! The article seems actually quite helpful. I found C implementations of arctan but they looked a lot more complicated with look up tables etc.

Is there a way to plug in a C++ or C implementation of arctan into heterocl?

seanlatias commented 3 years ago

Currently we don't have such a feature. We are also thinking about importing some existing C/C++ implementations into HCL, especially those more hardware-friendly ones.

MariusWiggert commented 3 years ago

Thanks! That helps, then I'll implement the arctan approximation on my own for now =)