Skip to content

Commit 976efe0

Browse files
committed
disable non-IEEE 754 math
1 parent ad0ebc1 commit 976efe0

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ all_args="$all_args -Wformat=2"
413413
all_args="$all_args -Wno-format-nonliteral"
414414
all_args="$all_args -Wno-parentheses"
415415
all_args="$all_args -fvisibility=hidden -fvisibility-inlines-hidden"
416-
all_args="$all_args -fno-math-errno -fno-trapping-math"
416+
all_args="$all_args -fno-math-errno -fno-trapping-math -fno-fast-math -ffp-contract=off"
417417
# TODO: once we have highly efficient tightly looped code, try no -fpic and see if that makes better code. The compiler can save a register in this case. See https://akkadia.org/drepper/dsohowto.pdf
418418
# TODO: check no-plt compiler option
419419
all_args="$all_args -fpic"

python/interpret-core/tests/glassbox/ebm/test_ebm.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,9 +1245,6 @@ def test_replicatability_classification():
12451245
break
12461246

12471247

1248-
@pytest.mark.skip(
1249-
reason="Fails on mac. Need to work on getting cross platform identical results."
1250-
)
12511248
def test_identical_classification():
12521249
from interpret.develop import get_option, set_option
12531250

@@ -1271,7 +1268,7 @@ def test_identical_classification():
12711268
pred = ebm.eval_terms(X)
12721269
total += np.sum(pred)
12731270

1274-
expected = 2.220446049250313e-15
1271+
expected = -3.941291737419306e-15
12751272
if total != expected:
12761273
assert total == expected
12771274
break

shared/libebm/interpretable_numerics.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1379,6 +1379,9 @@ static double Mean(const size_t cSamples,
13791379
// https://stackoverflow.com/questions/895929/how-do-i-determine-the-standard-deviation-stddev-of-a-set-of-values
13801380
// https://www.johndcook.com/blog/standard_deviation/
13811381

1382+
// do not put multiple floating point operations in the same statement since that can be optimized
1383+
// https://clang.llvm.org/docs/UsersManual.html
1384+
13821385
double factor = 1.0;
13831386
double mean;
13841387
size_t cNaN;
@@ -1440,7 +1443,8 @@ static double Mean(const size_t cSamples,
14401443
// if all the weights are zero, then weigh them all equally
14411444
ratio = double{1} / static_cast<double>(cNormal);
14421445
}
1443-
mean += numerator * ratio;
1446+
const double multiple = numerator * ratio;
1447+
mean += multiple;
14441448
}
14451449
if(nullptr != pWeight) {
14461450
++pWeight;

0 commit comments

Comments
 (0)