Skip to content

Commit e6dc5e2

Browse files
authored
Avoiding of finiteness checker overheads (#950)
1 parent c1910f5 commit e6dc5e2

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

daal4py/sklearn/utils/validation.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,22 @@
2424
from numpy.core.numeric import ComplexWarning
2525
from sklearn.utils.validation import (_num_samples, _ensure_no_complex_data,
2626
_ensure_sparse_format, column_or_1d,
27-
check_consistent_length)
27+
check_consistent_length, _assert_all_finite)
28+
from sklearn.utils.extmath import _safe_accumulator_op
2829
from .._utils import is_DataFrame, get_dtype, get_number_of_types
2930

3031

3132
def _daal_assert_all_finite(X, allow_nan=False, msg_dtype=None):
32-
"""Like assert_all_finite, but only for ndarray."""
33-
# validation is also imported in extmath
34-
from sklearn.utils.extmath import _safe_accumulator_op
35-
3633
if _get_config()['assume_finite']:
3734
return
3835

36+
# Data with small size has too big relative overhead
37+
# TODO: tune threshold size
38+
if hasattr(X, 'size'):
39+
if X.size < 32768:
40+
_assert_all_finite(X, allow_nan=allow_nan, msg_dtype=msg_dtype)
41+
return
42+
3943
is_df = is_DataFrame(X)
4044
num_of_types = get_number_of_types(X)
4145

0 commit comments

Comments
 (0)