@@ -1016,20 +1016,20 @@ ExpApproximation::matchAndRewrite(math::ExpOp op,
1016
1016
// 2^-126.
1017
1017
1018
1018
// Constants.
1019
- Value cst_half = bcast (f32Cst (builder, 0 .5f ));
1020
- Value cst_one = bcast (f32Cst (builder, 1 .0f ));
1019
+ Value cstHalf = bcast (f32Cst (builder, 0 .5f ));
1020
+ Value cstOne = bcast (f32Cst (builder, 1 .0f ));
1021
1021
1022
1022
// 1/log(2)
1023
- Value cst_log2ef = bcast (f32Cst (builder, 1 .44269504088896341f ));
1023
+ Value cstLog2ef = bcast (f32Cst (builder, 1 .44269504088896341f ));
1024
1024
1025
- Value cst_exp_c1 = bcast (f32Cst (builder, -0 .693359375f ));
1026
- Value cst_exp_c2 = bcast (f32Cst (builder, 2 .12194440e-4f ));
1027
- Value cst_exp_p0 = bcast (f32Cst (builder, 1 .9875691500E-4f ));
1028
- Value cst_exp_p1 = bcast (f32Cst (builder, 1 .3981999507E-3f ));
1029
- Value cst_exp_p2 = bcast (f32Cst (builder, 8 .3334519073E-3f ));
1030
- Value cst_exp_p3 = bcast (f32Cst (builder, 4 .1665795894E-2f ));
1031
- Value cst_exp_p4 = bcast (f32Cst (builder, 1 .6666665459E-1f ));
1032
- Value cst_exp_p5 = bcast (f32Cst (builder, 5 .0000001201E-1f ));
1025
+ Value cstExpC1 = bcast (f32Cst (builder, -0 .693359375f ));
1026
+ Value cstExpC2 = bcast (f32Cst (builder, 2 .12194440e-4f ));
1027
+ Value cstExpP0 = bcast (f32Cst (builder, 1 .9875691500E-4f ));
1028
+ Value cstExpP1 = bcast (f32Cst (builder, 1 .3981999507E-3f ));
1029
+ Value cstExpP2 = bcast (f32Cst (builder, 8 .3334519073E-3f ));
1030
+ Value cstExpP3 = bcast (f32Cst (builder, 4 .1665795894E-2f ));
1031
+ Value cstExpP4 = bcast (f32Cst (builder, 1 .6666665459E-1f ));
1032
+ Value cstExpP5 = bcast (f32Cst (builder, 5 .0000001201E-1f ));
1033
1033
1034
1034
// Our computations below aren't particularly sensitive to the exact choices
1035
1035
// here, so we choose values a bit larger/smaller than
@@ -1038,7 +1038,7 @@ ExpApproximation::matchAndRewrite(math::ExpOp op,
1038
1038
// log(2^-126) = -87.337...
1039
1039
Value x = op.getOperand ();
1040
1040
x = clampWithNormals (builder, shape, x, -87 .8f , 88 .8f );
1041
- Value n = floor (fmla (x, cst_log2ef, cst_half ));
1041
+ Value n = floor (fmla (x, cstLog2ef, cstHalf ));
1042
1042
1043
1043
// When we eventually do the multiplication in e^a * 2^n, we need to handle
1044
1044
// the case when n > 127, the max fp32 exponent (so 2^n == inf) but e^a < 1
@@ -1082,24 +1082,24 @@ ExpApproximation::matchAndRewrite(math::ExpOp op,
1082
1082
n = clampWithNormals (builder, shape, n, -127 .0f , 127 .0f );
1083
1083
1084
1084
// Computes x = x - n' * log(2), the value for `a`
1085
- x = fmla (cst_exp_c1 , n, x);
1086
- x = fmla (cst_exp_c2 , n, x);
1085
+ x = fmla (cstExpC1 , n, x);
1086
+ x = fmla (cstExpC2 , n, x);
1087
1087
1088
1088
// Polynomial to compute z = e^a, accurate for a in (-0.5, 0.5).
1089
- Value z = fmla (x, cst_exp_p0, cst_exp_p1 );
1090
- z = fmla (z, x, cst_exp_p2 );
1091
- z = fmla (z, x, cst_exp_p3 );
1092
- z = fmla (z, x, cst_exp_p4 );
1093
- z = fmla (z, x, cst_exp_p5 );
1089
+ Value z = fmla (x, cstExpP0, cstExpP1 );
1090
+ z = fmla (z, x, cstExpP2 );
1091
+ z = fmla (z, x, cstExpP3 );
1092
+ z = fmla (z, x, cstExpP4 );
1093
+ z = fmla (z, x, cstExpP5 );
1094
1094
z = fmla (z, mul (x, x), x);
1095
- z = add (cst_one , z);
1095
+ z = add (cstOne , z);
1096
1096
1097
1097
// Convert n' to an i32. This is safe because we clamped it above.
1098
- auto i32_vec = broadcast (builder.getI32Type (), shape);
1099
- Value n_i32 = builder.create <arith::FPToSIOp>(i32_vec , n);
1098
+ auto i32Vec = broadcast (builder.getI32Type (), shape);
1099
+ Value nI32 = builder.create <arith::FPToSIOp>(i32Vec , n);
1100
1100
1101
1101
// Creates the value 2^n' if -126 <= n' <= 127 and 0 if n' = -127.
1102
- Value pow2 = exp2I32 (builder, n_i32 );
1102
+ Value pow2 = exp2I32 (builder, nI32 );
1103
1103
1104
1104
// Return z * 2^n' if -126 <= n' <= 127 and 0 if n = -127.
1105
1105
Value ret = mul (z, pow2);
0 commit comments