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

Conversation

dcaballe
Copy link
Contributor

@dcaballe dcaballe commented Aug 9, 2023

Following the same approach as for other math ops. This will prevent the powf operation to be scalarized on CPU.

Fixes #13547

Following the same approach as for other math ops.
This will prevent the powf operation to be scalaried on CPU.
@@ -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.

@MaheshRavishankar
Copy link
Contributor

Looks good, but waiting for benchmark runs

@dcaballe dcaballe requested a review from bviyer August 11, 2023 05:35
Copy link
Contributor

@bviyer bviyer left a comment

Choose a reason for hiding this comment

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

LGTM.

@@ -30,6 +30,7 @@ class PolynomialApproximationPass
RewritePatternSet mathPatterns(&getContext());
populateExpandTanPattern(mathPatterns);
populateExpandExp2FPattern(mathPatterns);
populateExpandPowFPattern(mathPatterns);
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.

@dcaballe dcaballe merged commit c2f69fd into iree-org:main Sep 6, 2023
54 checks passed
@dcaballe dcaballe deleted the powf branch September 6, 2023 22:34
jinchen62 pushed a commit to jinchen62/iree that referenced this pull request Sep 18, 2023
Following the same approach as for other math ops. This will prevent the powf operation to be scalarized on CPU.

Fixes iree-org#13547
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CPU] Vector powf is not vectorized
3 participants