Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing expansion patterns for math.powf #14614

Merged
merged 7 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class PolynomialApproximationPass
RewritePatternSet mathPatterns(&getContext());
populateExpandTanPattern(mathPatterns);
populateExpandExp2FPattern(mathPatterns);
populateExpandPowFPattern(mathPatterns);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear to me what qualifies the expansions to be here or in the if-else statement below... but this should be similar to Exp2

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, it should be inside if-then-else if you are worried the approximation is not precise enough. As far as I know, if exp2 is precise enough then this shouldn't cause a huge issue.


if (clNativeMathPrecision) {
mathPatterns.add<math::ErfPolynomialApproximation>(&getContext());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
// RUN: iree-opt --iree-codegen-polynomial-approximation %s | FileCheck %s
// RUN: iree-opt --iree-codegen-polynomial-approximation --split-input-file %s | FileCheck %s

// CHECK-LABEL: @polynomial_tan
func.func @polynomial_tan(%arg0: f32) -> f32 {
// CHECK-NOT: math.tan
%0 = math.tan %arg0 : f32
%0 = math.tan %arg0 : f32
return %0 : f32
}

// -----

// CHECK-LABEL: @expanded_pow
func.func @expanded_pow(%arg0: f32, %arg1: f32) -> f32 {
// CHECK-NOT: math.pow
%0 = math.powf %arg0, %arg1 : f32
return %0 : f32
}
Loading