facebookresearch / gtn

Automatic differentiation with weighted finite-state transducers.
MIT License
453 stars 40 forks source link

LogAdd and -Ofast #33

Closed danpovey closed 3 years ago

danpovey commented 3 years ago

https://github.com/facebookresearch/gtn/blob/08443f8d5ccf71f26fd5098791cbfde4d19a811f/gtn/functions/shortest.cpp#L24

Just a warning for the future (you guys probably know this already, but just in case), that any comparisons with infinities will fail if you ever try to compile with -Ofast. I seem to remember situations where -Ofast is implicit- possibly at high optimization levels like -O3, but I'm not sure.

We encountered this in Kaldi, and it's very hard to work around because the compiler is very clever at detecting implicit checks for infinity and optimizing them out. Will close the issue after creating it because it's an FYI more than an issue.

awni commented 3 years ago

Thanks for the tip @danpovey!