glow icon indicating copy to clipboard operation
glow copied to clipboard

torch op support

Open ezimmer9 opened this issue 6 years ago • 5 comments

Hi,

are you support on sin(x) or cos(x) , cumsum(x) ?

Thanks

ezimmer9 avatar Dec 30 '19 13:12 ezimmer9

Hi @ezimmer9, we currently do not support these ops. However they should be relatively easy to implement, depending on what precision you're talking about (we'd probably want to create IntLookupTables for sin/cos but still should be somewhat painless to implement).

jfix71 avatar Dec 30 '19 15:12 jfix71

I am looking for supporting the trigonometric operators (sin, cos, tan, asin, acos, atan). A related question is that the ONNX definition of the operators doesn't clearly specify what the input values signify, do they map to degrees (in floating scale) or radians. If it is radians, then the the lookup tables can be made considering an input range of [0, 2*pi] => [0, 6.28] For this, we can quantize the input range into INT8 and have LUT accordingly.

If the input is in degrees, [0, 360] in floating scale, it might be tricky to quantize and have a lookup table.

What is your take on this? On similar lines, what was the thought behind implementation of LOG operator? How was the input range ascertained? (I see LUT for LOG also defined in INT8 whereas the input can be floats)

anujgupt-github avatar Jul 02 '20 10:07 anujgupt-github

Actually, I see that Interpreter and CPU backends for sin/cos are already brought in via support for TFLite "https://github.com/pytorch/glow/pull/4584/files/e526460dc3799ea9ff9dd13d8f32f1c3da399754#diff-432c9c901879d6257b101f981c5bd878R535"

Then it seems we are not doing the Lookup table approach!

anujgupt-github avatar Jul 02 '20 12:07 anujgupt-github

Hi @anujgupt-github -- Thanks for updating this issue. As far as I recall, we are only using the LUT when the inputs and outputs are both quantized. This is where we get the range from, as the op's inputs are already quantized with a specific range. LMK if you are seeing something different.

jfix71 avatar Jul 07 '20 08:07 jfix71

Hi @jfix71 , thanks for responding back! I was actually referring to " https://github.com/pytorch/glow/pull/4584" where sin/cos are now implemented without LUTs. I plan to take a similar route to wrap up other trigonometric Ops.

anujgupt-github avatar Jul 07 '20 17:07 anujgupt-github