[mlir][math] Expand math.round to truncate, compare and increment.
authorBalaji V. Iyer <bviyer@gmail.com>
Thu, 13 Apr 2023 17:58:14 +0000 (17:58 +0000)
committerRobert Suderman <suderman@google.com>
Thu, 13 Apr 2023 18:02:10 +0000 (18:02 +0000)
commitbe9115788c7f223dfc6d369455ce84c0e443743b
tree2b0464ae8e8df45e12f60aa24357b39e1559eeba
parent43c42d6d7ab7f80c79e5b1bfd329b9e84eac06ba
[mlir][math] Expand math.round to truncate, compare and increment.

Round functions are pushed directly to libm. This is problematic for
situations where libm is not available. This patch will decompose the
roundf function by adding 0.5 to positive number to input
(subtracting for negative) following by a truncate.

Reviewed By: rsuderman

Differential Revision: https://reviews.llvm.org/D148026
mlir/include/mlir/Dialect/Math/Transforms/Passes.h
mlir/lib/Dialect/Math/Transforms/ExpandPatterns.cpp
mlir/test/Dialect/Math/expand-math.mlir
mlir/test/lib/Dialect/Math/TestExpandMath.cpp
mlir/test/mlir-cpu-runner/test-expand-math-approx.mlir