This is an archive of the discontinued LLVM Phabricator instance.

[mlir][math] Initial support for fastmath flag attributes for Math dialect.
ClosedPublic

Authored by vzakhari on Oct 19 2022, 7:31 PM.

Details

Summary

Added arith::FastMathAttr and ArithFastMathInterface support for Math dialect
floating point operations.

This change-set creates ArithCommon conversion utils that currently
provide classes and methods to aid with arith::FastMathAttr conversion
into LLVM::FastmathFlags. These utils are used in ArithToLLVM and
MathToLLVM convertors, but may eventually be used by other converters
that need to convert fast math attributes.

Since Math dialect operations use arith::FastMathAttr, MathOps.td now
has to include enum and attributes definitions from Arith dialect.
To minimize the amount of TD code included from Arith dialect,
I moved FastMathAttr definition into ArithBase.td.

Depends on D136225

Diff Detail

Event Timeline

vzakhari created this revision.Oct 19 2022, 7:31 PM
vzakhari requested review of this revision.Oct 19 2022, 7:31 PM
vzakhari updated this revision to Diff 470227.Oct 24 2022, 11:22 AM
vzakhari retitled this revision from [RFC][mlir][math] Initial support for fastmath flag attributes for Math dialect. to [mlir][math] Initial support for fastmath flag attributes for Math dialect..
vzakhari edited the summary of this revision. (Show Details)

Rebase on top of the latest D126305.

vzakhari planned changes to this revision.Oct 28 2022, 8:34 AM
vzakhari updated this revision to Diff 472400.Nov 1 2022, 2:22 PM
vzakhari edited the summary of this revision. (Show Details)
vzakhari added a reviewer: rkayaith.

LGTM. Please wait a day before you submit in case there are comments from other reviewers.

mlir/lib/Conversion/ArithCommon/CMakeLists.txt
1 ↗(On Diff #472400)

Nit: Would it be better to retain AttrToLLVM in the name of the pass like MLIRArithAttrToLLVMConversion? Or do you anticipate other conversions to be present here?

This revision is now accepted and ready to land.Nov 2 2022, 10:13 AM
vzakhari added inline comments.Nov 2 2022, 7:36 PM
mlir/lib/Conversion/ArithCommon/CMakeLists.txt
1 ↗(On Diff #472400)

Yes, I created ArithCommon directory with the intention that it would hold some common conversion utils from Arith dialect entities (like FastMathFlagsAttr) to other dialects. For example, there are ArithToSPIRV and MathToSPIRV convertors, which may also have some common utils hosted here. I am not sure though if these SPIRV utils will necessarily be put into the same CMake component (e.g. the SPIRV convertors may not need a dependency on LLVM dialect), so I guess renaming it to MLIRArithAttrToLLVMConversion should be appropriate right now.

vzakhari updated this revision to Diff 472984.Nov 3 2022, 10:50 AM
vzakhari marked an inline comment as done.