Skip to content

Commit

Permalink
disable non-IEEE 754 math
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbkoch committed Jan 15, 2025
1 parent ad0ebc1 commit 976efe0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ all_args="$all_args -Wformat=2"
all_args="$all_args -Wno-format-nonliteral"
all_args="$all_args -Wno-parentheses"
all_args="$all_args -fvisibility=hidden -fvisibility-inlines-hidden"
all_args="$all_args -fno-math-errno -fno-trapping-math"
all_args="$all_args -fno-math-errno -fno-trapping-math -fno-fast-math -ffp-contract=off"
# 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
# TODO: check no-plt compiler option
all_args="$all_args -fpic"
Expand Down
5 changes: 1 addition & 4 deletions python/interpret-core/tests/glassbox/ebm/test_ebm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1245,9 +1245,6 @@ def test_replicatability_classification():
break


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

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

expected = 2.220446049250313e-15
expected = -3.941291737419306e-15
if total != expected:
assert total == expected
break
Expand Down
6 changes: 5 additions & 1 deletion shared/libebm/interpretable_numerics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1379,6 +1379,9 @@ static double Mean(const size_t cSamples,
// https://stackoverflow.com/questions/895929/how-do-i-determine-the-standard-deviation-stddev-of-a-set-of-values
// https://www.johndcook.com/blog/standard_deviation/

// do not put multiple floating point operations in the same statement since that can be optimized
// https://clang.llvm.org/docs/UsersManual.html

double factor = 1.0;
double mean;
size_t cNaN;
Expand Down Expand Up @@ -1440,7 +1443,8 @@ static double Mean(const size_t cSamples,
// if all the weights are zero, then weigh them all equally
ratio = double{1} / static_cast<double>(cNormal);
}
mean += numerator * ratio;
const double multiple = numerator * ratio;
mean += multiple;
}
if(nullptr != pWeight) {
++pWeight;
Expand Down

0 comments on commit 976efe0

Please sign in to comment.