Skip to content

Commit bd2c7ac

Browse files
committed
Feedback, and remove expm1 test.
1 parent 8b3769a commit bd2c7ac

File tree

4 files changed

+21
-40
lines changed

4 files changed

+21
-40
lines changed

src/FastMathFunctions.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ Expr eval_poly_horner(const std::vector<double> &coefs, const Expr &x) {
6161
* R = a0 + x * a1 + x^2 * a2 + x^3 * a3
6262
* = a0 + x * (a1 + x * a2 + x^2 * a3)
6363
* = a0 + x * (a1 + x * (a2 + x * a3))
64+
*
65+
* This is known as Horner's method.
66+
* Fun fact: even if we don't program it like this, the Halide expression
67+
* rewriter will turn it into this Horner format.
6468
*/
6569
Type type = x.type();
6670
if (coefs.empty()) {
@@ -680,6 +684,10 @@ bool intrinsic_satisfies_precision(const IntrinsicsInfo &ii, const Approximation
680684
}
681685
} else {
682686
// We don't know?
687+
// TODO(mcourteaux): We haven't measured the intrinsics on this particular
688+
// device API yet. We could report a warning, but that's perhaps too invasive.
689+
// Let's report it in debug(1) instead to have people notice this.
690+
debug(1) << "Warning: intrinsic is defined but not yet measured in terms of ULP precision.\n";
683691
}
684692
}
685693
if (prec.constraint_max_absolute_error != 0) {
@@ -689,6 +697,8 @@ bool intrinsic_satisfies_precision(const IntrinsicsInfo &ii, const Approximation
689697
}
690698
} else {
691699
// We don't know?
700+
// TODO(mcourteaux): Read above.
701+
debug(1) << "Warning: intrinsic is defined but not yet measured in terms of MAE precision.\n";
692702
}
693703
}
694704
return true;
@@ -711,6 +721,11 @@ bool native_func_satisfies_precision(const IntrinsicsInfo &ii, const Approximati
711721
}
712722
} else {
713723
// We don't know?
724+
// TODO(mcourteaux): We could report a warning that we assume the
725+
// precision is unknown, but I'll postpone this for when we have
726+
// strict_float, and only warn in case of string_float requirements.
727+
// For now let's report it in debug(1) such that we won't forget about this.
728+
debug(1) << "Warning: native func is defined but not yet measured in terms of MAE precision.\n";
714729
}
715730
}
716731
if (prec.constraint_max_absolute_error != 0) {
@@ -720,6 +735,8 @@ bool native_func_satisfies_precision(const IntrinsicsInfo &ii, const Approximati
720735
}
721736
} else {
722737
// We don't know?
738+
// TODO(mcourteaux): Read above.
739+
debug(1) << "Warning: native func is defined but not yet measured in terms of ULP precision.\n";
723740
}
724741
}
725742
return true;

src/IROperator.cpp

-11
Original file line numberDiff line numberDiff line change
@@ -2194,17 +2194,6 @@ Expr hypot(const Expr &x, const Expr &y) {
21942194
return sqrt(x * x + y * y);
21952195
}
21962196

2197-
Expr expm1(Expr x) {
2198-
user_assert(x.defined()) << "exp of undefined Expr\n";
2199-
if (x.type() == Float(64)) {
2200-
return Call::make(Float(64), "expm1_f64", {std::move(x)}, Call::PureExtern);
2201-
} else if (x.type() == Float(16)) {
2202-
return Call::make(Float(16), "expm1_f16", {std::move(x)}, Call::PureExtern);
2203-
} else {
2204-
return Call::make(Float(32), "expm1_f32", {cast<float>(std::move(x))}, Call::PureExtern);
2205-
}
2206-
}
2207-
22082197
Expr exp(Expr x) {
22092198
user_assert(x.defined()) << "exp of undefined Expr\n";
22102199
if (x.type() == Float(64)) {

src/IROperator.h

+1-10
Original file line numberDiff line numberDiff line change
@@ -956,15 +956,6 @@ Expr hypot(const Expr &x, const Expr &y);
956956
* mantissa. Vectorizes cleanly. */
957957
Expr exp(Expr x);
958958

959-
/** Return the exponential of a floating-point expression. If the
960-
* argument is not floating-point, it is cast to Float(32). For
961-
* Float(64) arguments, this calls the system exp function, and does
962-
* not vectorize well. For Float(32) arguments, this function is
963-
* vectorizable, does the right thing for extremely small or extremely
964-
* large inputs, and is accurate up to the last bit of the
965-
* mantissa. Vectorizes cleanly. */
966-
Expr expm1(Expr x);
967-
968959
/** Return the logarithm of a floating-point expression. If the
969960
* argument is not floating-point, it is cast to Float(32). For
970961
* Float(64) arguments, this calls the system log function, and does
@@ -992,7 +983,7 @@ Expr erf(const Expr &x);
992983
* hardware instructions. If no hardware instructions are available, approximations
993984
* are implemented in Halide using polynomials or potentially Padé approximants.
994985
* Both the hardware instructions and the in-house approximations have a certain behavior
995-
* and precision. This struct allows you to specifiy which behavior and precision you
986+
* and precision. This struct allows you to specify which behavior and precision you
996987
* are interested in. Halide will select an appropriate implemenation that satisfies
997988
* these requirements.
998989
*

test/performance/fast_function_approximations.cpp

+3-19
Original file line numberDiff line numberDiff line change
@@ -252,39 +252,23 @@ int main(int argc, char **argv) {
252252
}
253253
if (should_be_faster) num_tests++;
254254

255-
int goodness = 0;
256-
257255
if (pipeline_time_ref < approx_pipeline_time * 0.90) {
258256
printf(" %6.1f%% slower", -100.0f * (1.0f - approx_pipeline_time / pipeline_time_ref));
259257
if (!should_be_faster) {
260-
printf(" (expected)");
261-
goodness = 1;
258+
printf(" (expected) 😐");
262259
} else {
263-
printf("!!");
264-
goodness = 0;
260+
printf("!! ❌");
265261
}
266262
} else if (pipeline_time_ref < approx_pipeline_time * 1.10) {
267263
printf(" equally fast (%+5.1f%% faster)",
268264
100.0f * (1.0f - approx_pipeline_time / pipeline_time_ref));
269265
if (should_be_faster) num_passed++;
270-
goodness = 1;
266+
printf(" 😐");
271267
} else {
272268
printf(" %4.1f%% faster",
273269
100.0f * (1.0f - approx_pipeline_time / pipeline_time_ref));
274270
if (should_be_faster) num_passed++;
275-
goodness = 2;
276-
}
277-
278-
switch (goodness) {
279-
case 0:
280-
printf("");
281-
break;
282-
case 1:
283-
printf(" 😐");
284-
break;
285-
case 2:
286271
printf("");
287-
break;
288272
}
289273
printf("\n");
290274
}

0 commit comments

Comments
 (0)