Skip to content

Commit

Permalink
Add missing expansion patterns for math.powf (iree-org#14614)
Browse files Browse the repository at this point in the history
Following the same approach as for other math ops. This will prevent the powf operation to be scalarized on CPU.

Fixes iree-org#13547
  • Loading branch information
dcaballe authored and jinchen62 committed Sep 18, 2023
1 parent 2996856 commit 55de72a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
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);

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
}

0 comments on commit 55de72a

Please sign in to comment.