This is an archive of the discontinued LLVM Phabricator instance.

[mlir][math] Improved math.atan approximation
ClosedPublic

Authored by rsuderman on Jun 23 2023, 11:44 AM.

Details

Summary

Used the cephes numerical approximation for math.atan. This is a
significant accuracy improvement over the previous taylor series
approximation.

Diff Detail

Event Timeline

rsuderman created this revision.Jun 23 2023, 11:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 23 2023, 11:44 AM
rsuderman requested review of this revision.Jun 23 2023, 11:44 AM

Fixed windows build

rsuderman updated this revision to Diff 534063.Jun 23 2023, 1:46 PM

More windows compilation failures.

rsuderman updated this revision to Diff 534069.Jun 23 2023, 2:02 PM

Expand f32Cst to take double

rsuderman updated this revision to Diff 534118.Jun 23 2023, 4:30 PM

Formatting changes and float -> double correction.

jpienaar accepted this revision.Jun 23 2023, 4:36 PM
jpienaar added a subscriber: jpienaar.
jpienaar added inline comments.
mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp
447

We almost need polyeval :-)

This revision is now accepted and ready to land.Jun 23 2023, 4:36 PM
This revision was landed with ongoing or failed builds.Jun 23 2023, 5:32 PM
This revision was automatically updated to reflect the committed changes.

Seems this patch caused build failure on x64 windows.

[6792/9410] Building CXX object tools\mlir\lib\Dialect\Math\Transforms\CMakeFiles\obj.MLIRMathTransforms.dir\PolynomialApproximation.cpp.obj
FAILED: tools/mlir/lib/Dialect/Math/Transforms/CMakeFiles/obj.MLIRMathTransforms.dir/PolynomialApproximation.cpp.obj
sccache C:\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe  /nologo /TP -DBUILD_EXAMPLES -DGTEST_HAS_RTTI=0 -DMLIR_CUDA_CONVERSIONS_ENABLED=1 -DMLIR_ROCM_CONVERSIONS_ENABLED=1 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_ASSERTIONS -D_HAS_EXCEPTIONS=0 -D_LIBCPP_ENABLE_ASSERTIONS -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools\mlir\lib\Dialect\Math\Transforms -IC:\ws\w3\llvm-project\premerge-checks\mlir\lib\Dialect\Math\Transforms -Iinclude -IC:\ws\w3\llvm-project\premerge-checks\llvm\include -IC:\ws\w3\llvm-project\premerge-checks\mlir\include -Itools\mlir\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -w14062 -we4238 /Gw /MD /O2 /Ob2  /EHs-c- /GR- -UNDEBUG -std:c++17 /showIncludes /Fotools\mlir\lib\Dialect\Math\Transforms\CMakeFiles\obj.MLIRMathTransforms.dir\PolynomialApproximation.cpp.obj /Fdtools\mlir\lib\Dialect\Math\Transforms\CMakeFiles\obj.MLIRMathTransforms.dir\ /FS -c C:\ws\w3\llvm-project\premerge-checks\mlir\lib\Dialect\Math\Transforms\PolynomialApproximation.cpp
C:\ws\w3\llvm-project\premerge-checks\mlir\lib\Dialect\Math\Transforms\PolynomialApproximation.cpp(444): error C2065: 'M_PI_4': undeclared identifier
C:\ws\w3\llvm-project\premerge-checks\mlir\lib\Dialect\Math\Transforms\PolynomialApproximation.cpp(448): error C2065: 'M_PI_2': undeclared identifier

I'm not sure can we add these constant in llvm/Support/MathExtras.h ?