Skip to content

Commit

Permalink
[CPU] Remove casting math.powf from fp16 to fp32 (#19844)
Browse files Browse the repository at this point in the history
  • Loading branch information
ita9naiwa authored Feb 4, 2025
1 parent 2733115 commit d7c6c7b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ struct ExpandF16OpToF32Pass
MLIRContext *context = &getContext();
RewritePatternSet patterns(&getContext());
patterns.insert<ExpandF16OpToF32Pattern<arith::MaximumFOp>>(context);
// TODO(#15661): Remove the expansion for math.powf op after fixing
// approximation issue.
patterns.insert<ExpandF16OpToF32Pattern<math::PowFOp>>(context);
if (failed(applyPatternsGreedily(getOperation(), std::move(patterns)))) {
return signalPassFailure();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,3 @@ func.func @maximumf(%arg0: tensor<4xf16>, %arg1: tensor<4xf16>, %arg2: tensor<4x
// CHECK: %[[TRUNC:.*]] = arith.truncf %[[MAX]] : f32 to f16
// CHECK: linalg.yield %[[TRUNC:.*]] : f16
// CHECK: return %[[GEN:.*]] : tensor<4xf16>

// -----

func.func @powf(%arg0: tensor<4xf16>, %arg1: tensor<4xf16>, %arg2: tensor<4xf16>) -> tensor<4xf16>{
%1 = linalg.generic {
indexing_maps = [affine_map<(d0) -> (d0)>,
affine_map<(d0) -> (d0)>,
affine_map<(d0) -> (d0)>],
iterator_types = ["parallel"]}
ins(%arg0, %arg1: tensor<4xf16>, tensor<4xf16>)
outs(%arg2: tensor<4xf16>) {
^bb0(%in: f16, %in_0: f16, %out: f16):
%2 = math.powf %in, %in_0 : f16
linalg.yield %2: f16
} -> tensor<4xf16>
return %1 : tensor<4xf16>
}
// CHECK-LABEL: func.func @powf
// CHECK: %[[GEN:.*]] = linalg.generic
// CHECK: %[[LHS:.*]] = arith.extf %{{.+}} : f16 to f32
// CHECK: %[[RHS:.*]] = arith.extf %{{.+}} : f16 to f32
// CHECK: %[[POWF:.*]] = math.powf %[[LHS]], %[[RHS]] : f32
// CHECK: %[[TRUNC:.*]] = arith.truncf %[[POWF]] : f32 to f16
// CHECK: linalg.yield %[[TRUNC:.*]] : f16
// CHECK: return %[[GEN:.*]] : tensor<4xf16>

0 comments on commit d7c6c7b

Please sign in to comment.