[all-commits] [llvm/llvm-project] f99ccf: [mlir] Add math polynomial approximation pass
Eugene Zhulenev via All-commits
all-commits at lists.llvm.org
Fri Feb 19 12:43:55 PST 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: f99ccf6516bdd5def4d3bc311330aec92f5cb99d
https://github.com/llvm/llvm-project/commit/f99ccf6516bdd5def4d3bc311330aec92f5cb99d
Author: Eugene Zhulenev <ezhulenev at google.com>
Date: 2021-02-19 (Fri, 19 Feb 2021)
Changed paths:
M mlir/include/mlir/Dialect/Math/Transforms/Passes.h
M mlir/lib/Dialect/Math/Transforms/CMakeLists.txt
A mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp
A mlir/test/Dialect/Math/polynomial-approximation.mlir
M mlir/test/lib/Transforms/CMakeLists.txt
A mlir/test/lib/Transforms/TestPolynomialApproximation.cpp
A mlir/test/mlir-cpu-runner/math_polynomial_approx.mlir
M mlir/tools/mlir-opt/mlir-opt.cpp
Log Message:
-----------
[mlir] Add math polynomial approximation pass
This gives ~30x speedup compared to expanding Tanh into exp operations:
```
name old cpu/op new cpu/op delta
BM_mlir_Tanh_f32/10 253ns ± 3% 55ns ± 7% -78.35% (p=0.000 n=44+41)
BM_mlir_Tanh_f32/100 2.21µs ± 4% 0.14µs ± 8% -93.85% (p=0.000 n=48+49)
BM_mlir_Tanh_f32/1k 22.6µs ± 4% 0.7µs ± 5% -96.68% (p=0.000 n=32+42)
BM_mlir_Tanh_f32/10k 225µs ± 5% 7µs ± 6% -96.88% (p=0.000 n=49+55)
name old time/op new time/op delta
BM_mlir_Tanh_f32/10 259ns ± 1% 56ns ± 2% -78.31% (p=0.000 n=41+39)
BM_mlir_Tanh_f32/100 2.27µs ± 1% 0.14µs ± 5% -93.89% (p=0.000 n=46+49)
BM_mlir_Tanh_f32/1k 22.9µs ± 1% 0.8µs ± 4% -96.67% (p=0.000 n=30+42)
BM_mlir_Tanh_f32/10k 230µs ± 0% 7µs ± 3% -96.88% (p=0.000 n=37+55)
```
This approximations is based on Eigen::generic_fast_tanh function
Reviewed By: mehdi_amini
Differential Revision: https://reviews.llvm.org/D96739
More information about the All-commits
mailing list