This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Math] Add constant folder for ExpM1Op.
ClosedPublic

Authored by jacquesguan on Jul 26 2022, 6:58 AM.

Details

Summary

This patch adds constant folder for ExpM1Op which only supports single and double precision floating-point.

Diff Detail

Event Timeline

jacquesguan created this revision.Jul 26 2022, 6:58 AM
jacquesguan requested review of this revision.Jul 26 2022, 6:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 26 2022, 6:58 AM

Windows build error seems relevant. I suspect some underlying implementation differs across platforms.

Windows build error seems relevant. I suspect some underlying implementation differs across platforms.

I found that the result of expm1(4.0) is 53.5981483 on Windows but 53.5981522 on Linux. Any good advice? Or just change to a nother number case?

I'd just drop it. I am generally skeptical about the utility of tests with hardcoded numbers that cannot be easily verifiable with pen an paper. The only thing that we need to verify here is that applies to a the vector elementwise, which should be visible from a denes<[1.0, 0.0, 1.0]> just fine.

Refactor test.

I'd just drop it. I am generally skeptical about the utility of tests with hardcoded numbers that cannot be easily verifiable with pen an paper. The only thing that we need to verify here is that applies to a the vector elementwise, which should be visible from a denes<[1.0, 0.0, 1.0]> just fine.

Done, thank you.

Mogball accepted this revision.Jul 30 2022, 4:30 PM
Mogball added inline comments.
mlir/test/Dialect/Math/canonicalize.mlir
278

you could use a regex to match fewer decimal places if it varies too much across platforms (adding a float matching feature to FileCheck is also highly-requested)

This revision is now accepted and ready to land.Jul 30 2022, 4:30 PM
This revision was automatically updated to reflect the committed changes.