|
26 | 26 |
|
27 | 27 | #include <tvm/tir/builtin.h> |
28 | 28 | #include <tvm/tir/expr.h> |
| 29 | +#include <tvm/tir/op.h> |
29 | 30 | #include <tvm/topi/tags.h> |
30 | 31 |
|
31 | 32 | #include <algorithm> |
@@ -455,54 +456,6 @@ inline Tensor fast_exp(const Tensor& x, std::string name = "T_fast_exp", |
455 | 456 | } |
456 | 457 | } |
457 | 458 |
|
458 | | -/*! |
459 | | - * \brief Fast_erf_float expression from Eigen |
460 | | - * https://github.com/eigenteam/eigen-git-mirror/blob/master/unsupported/Eigen/src/SpecialFunctions/SpecialFunctionsImpl.h#L290 |
461 | | - * \param arg The input expression. |
462 | | - * \param bits The number of bits in the type. |
463 | | - */ |
464 | | -inline PrimExpr fast_erf_float_expr(PrimExpr arg, int bits) { |
465 | | - auto plus_4 = make_const(DataType::Float(bits), 4.f); |
466 | | - auto minus_4 = make_const(DataType::Float(bits), -4.f); |
467 | | - |
468 | | - // The monomial coefficients of the numerator polynomial (odd). |
469 | | - auto alpha_1 = make_const(DataType::Float(bits), -1.60960333262415e-02f); |
470 | | - auto alpha_3 = make_const(DataType::Float(bits), -2.95459980854025e-03f); |
471 | | - auto alpha_5 = make_const(DataType::Float(bits), -7.34990630326855e-04f); |
472 | | - auto alpha_7 = make_const(DataType::Float(bits), -5.69250639462346e-05f); |
473 | | - auto alpha_9 = make_const(DataType::Float(bits), -2.10102402082508e-06f); |
474 | | - auto alpha_11 = make_const(DataType::Float(bits), 2.77068142495902e-08f); |
475 | | - auto alpha_13 = make_const(DataType::Float(bits), -2.72614225801306e-10f); |
476 | | - |
477 | | - // The monomial coefficients of the denominator polynomial (even). |
478 | | - auto beta_0 = make_const(DataType::Float(bits), -1.42647390514189e-02f); |
479 | | - auto beta_2 = make_const(DataType::Float(bits), -7.37332916720468e-03f); |
480 | | - auto beta_4 = make_const(DataType::Float(bits), -1.68282697438203e-03f); |
481 | | - auto beta_6 = make_const(DataType::Float(bits), -2.13374055278905e-04f); |
482 | | - auto beta_8 = make_const(DataType::Float(bits), -1.45660718464996e-05f); |
483 | | - |
484 | | - // clamp x |
485 | | - auto x = tvm::max(tvm::min(arg, plus_4), minus_4); |
486 | | - auto x2 = x * x; |
487 | | - |
488 | | - // Evaluate the numerator polynomial p. |
489 | | - auto p = x2 * alpha_13 + alpha_11; |
490 | | - p = x2 * p + alpha_9; |
491 | | - p = x2 * p + alpha_7; |
492 | | - p = x2 * p + alpha_5; |
493 | | - p = x2 * p + alpha_3; |
494 | | - p = x2 * p + alpha_1; |
495 | | - p = x * p; |
496 | | - |
497 | | - // Evaluate the denominator polynomial p. |
498 | | - auto q = x2 * beta_8 + beta_6; |
499 | | - q = x2 * q + beta_4; |
500 | | - q = x2 * q + beta_2; |
501 | | - q = x2 * q + beta_0; |
502 | | - |
503 | | - return p / q; |
504 | | -} |
505 | | - |
506 | 459 | /*! |
507 | 460 | * \brief Fast_erf_float expression from Eigen |
508 | 461 | */ |
|
0 commit comments