| 7 | namespace jit { |
| 8 | |
| 9 | mlir::Value polynomial( |
| 10 | ValueBuilderHelper& helper, mlir::Value x, std::vector<mlir::Value>& coeff) { |
| 11 | size_t n = coeff.size(); |
| 12 | if (n == 0) { |
| 13 | return helper.const_f32(0); |
| 14 | } |
| 15 | |
| 16 | mlir::Value r = coeff[0]; |
| 17 | for (size_t i = 1; i < n; i++) { |
| 18 | r = helper.add(helper.mul(r, x), coeff[i]); |
| 19 | } |
| 20 | return r; |
| 21 | } |
| 22 | |
| 23 | // polynomial approximation of arctangent |
| 24 | // atan(t) = t + c3 * t^3 + c5 * t^5 + ... + c17 * t^17 |
no test coverage detected