google / google/heir

reduce one multiplication in tosa to arith sigmoid

Open
#982 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
MLIR
Stars
906
Forks
171
Avg merge
4d 12h
Merged PRs (30d)
32

Description

In recent implementation of **lib/Conversion/TosaToSecretArith/TosaToSecretArith.cpp** we lower Tosa::sigmoid() to degree-3 polynomial approximation as $-0.004x^3 + 0.197 * x + 0.5$. It could have used Horner's rule instead of direct computation.

Further, while current implementation computes the polynomial directly a better way would be to compute it as,
$x *(0.197 - 0.004 x^2) + 0.5 $ where the number of arith::mulop is fewer by 1.

If we had easy ability to compute complex numbers we can further break down the compute as 2 products from applying the fundamental theorem of algebra.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.