This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Add polynomial approximation for math::ExpM1
ClosedPublic

Authored by cota on May 4 2021, 1:17 PM.

Details

Summary

This approximation matches the one in Eigen.

name                      old cpu/op  new cpu/op  delta
BM_mlir_Expm1_f32/10      90.9ns ± 4%  52.2ns ± 4%  -42.60%    (p=0.000 n=74+87)
BM_mlir_Expm1_f32/100      837ns ± 3%   231ns ± 4%  -72.43%    (p=0.000 n=79+69)
BM_mlir_Expm1_f32/1k      8.43µs ± 3%  1.58µs ± 5%  -81.30%    (p=0.000 n=77+83)
BM_mlir_Expm1_f32/10k     83.8µs ± 3%  15.4µs ± 5%  -81.65%    (p=0.000 n=83+69)
BM_eigen_s_Expm1_f32/10   68.8ns ±17%  72.5ns ±14%   +5.40%  (p=0.000 n=118+115)
BM_eigen_s_Expm1_f32/100   694ns ±11%   717ns ± 2%   +3.34%   (p=0.000 n=120+75)
BM_eigen_s_Expm1_f32/1k   7.69µs ± 2%  7.97µs ±11%   +3.56%   (p=0.000 n=95+117)
BM_eigen_s_Expm1_f32/10k  88.0µs ± 1%  89.3µs ± 6%   +1.45%   (p=0.000 n=74+106)
BM_eigen_v_Expm1_f32/10   44.3ns ± 6%  45.0ns ± 8%   +1.45%   (p=0.018 n=81+111)
BM_eigen_v_Expm1_f32/100   351ns ± 1%   360ns ± 9%   +2.58%    (p=0.000 n=73+99)
BM_eigen_v_Expm1_f32/1k   3.31µs ± 1%  3.42µs ± 9%   +3.37%   (p=0.000 n=71+100)
BM_eigen_v_Expm1_f32/10k  33.7µs ± 8%  34.1µs ± 9%   +1.04%    (p=0.007 n=99+98)

Diff Detail

Event Timeline

cota created this revision.May 4 2021, 1:17 PM
cota requested review of this revision.May 4 2021, 1:17 PM
cota edited the summary of this revision. (Show Details)May 4 2021, 1:18 PM
ftynse added a subscriber: ftynse.May 5 2021, 12:49 AM
ftynse added inline comments.
mlir/test/Dialect/Math/polynomial-approximation.mlir
14–17

Could we check the emitted IR at least once, not just the fact that it is emitted?

ezhulenev added inline comments.May 5 2021, 5:35 AM
mlir/test/Dialect/Math/polynomial-approximation.mlir
14–17

I originally skipped verifying emitted IR because it's huge and completely unreadable. Is it a value in checking that sequence of emitted operation is correct without verifying every ssa result and operand? Or it's better to bite the bullet and write proper tests for expansions?

ftynse added inline comments.May 5 2021, 5:47 AM
mlir/test/Dialect/Math/polynomial-approximation.mlir
14–17

We have a tool to generate the boilerplate part of the test https://github.com/llvm/llvm-project/blob/main/mlir/utils/generate-test-checks.py, usually one just needs to remove irrelevant parts.

cota marked 3 inline comments as done.May 5 2021, 1:17 PM
cota added inline comments.
mlir/test/Dialect/Math/polynomial-approximation.mlir
14–17

Just sent a patch to do this for the entire file: https://reviews.llvm.org/D101940

ezhulenev accepted this revision.May 5 2021, 2:27 PM
This revision is now accepted and ready to land.May 5 2021, 2:27 PM
This revision was landed with ongoing or failed builds.May 5 2021, 2:31 PM
This revision was automatically updated to reflect the committed changes.