The approximation relays on range reduced version y \in [0, pi/2]. An input x will have
the property that sin(x) = sin(y), -sin(y), cos(y), -cos(y) depends on which quadrable x
is in, where sin(y) and cos(y) are approximated with 5th degree polynomial (of x^2).
As a result a single pattern can be used to compute approximation for both sine and cosine.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
There are bunch of variable name warning, I'd say it's ok to keep CC/KR/etc upper case but cast_f32_to_i32 and such are better to keep consistent
mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp | ||
---|---|---|
639 | private: static constexpr bool isSine = std::is_same<OpTy, math::SinOp>::value; + static_assert that OpTy is Sin or Cos |
+ static_assert that OpTy is Sin or Cos