Skip to content

Commit 49074de

Browse files
committed
Get rid of block size
1 parent c2c6212 commit 49074de

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

dpnp/dpnp_iface_histograms.py

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -298,16 +298,12 @@ def histogram(a, bins=10, range=None, density=None, weights=None):
298298
else:
299299
ntype = weights.dtype
300300

301-
# We set a block size, as this allows us to iterate over chunks when
302-
# computing histograms, to minimize memory usage.
303-
block_size = 65536
304-
305301
# The fast path uses bincount, but that only works for certain types
306302
# of weight
307303
# simple_weights = (
308304
# weights is None or
309-
# np.can_cast(weights.dtype, np.double) or
310-
# np.can_cast(weights.dtype, complex)
305+
# dpnp.can_cast(weights.dtype, dpnp.double) or
306+
# dpnp.can_cast(weights.dtype, complex)
311307
# )
312308
# TODO: implement a fast path
313309
simple_weights = False
@@ -317,24 +313,19 @@ def histogram(a, bins=10, range=None, density=None, weights=None):
317313
pass
318314
else:
319315
# Compute via cumulative histogram
320-
cum_n = dpnp.zeros_like(bin_edges, dtype=ntype)
321316
if weights is None:
322-
for i in _range(0, len(a), block_size):
323-
sa = dpnp.sort(a[i : i + block_size])
324-
cum_n += _search_sorted_inclusive(sa, bin_edges)
317+
sa = dpnp.sort(a)
318+
cum_n = _search_sorted_inclusive(sa, bin_edges)
325319
else:
326320
zero = dpnp.zeros(
327321
1, dtype=ntype, sycl_queue=a.sycl_queue, usm_type=a.usm_type
328322
)
329-
for i in _range(0, len(a), block_size):
330-
tmp_a = a[i : i + block_size]
331-
tmp_w = weights[i : i + block_size]
332-
sorting_index = dpnp.argsort(tmp_a)
333-
sa = tmp_a[sorting_index]
334-
sw = tmp_w[sorting_index]
335-
cw = dpnp.concatenate((zero, sw.cumsum(dtype=ntype)))
336-
bin_index = _search_sorted_inclusive(sa, bin_edges)
337-
cum_n += cw[bin_index]
323+
sorting_index = dpnp.argsort(a)
324+
sa = a[sorting_index]
325+
sw = weights[sorting_index]
326+
cw = dpnp.concatenate((zero, sw.cumsum(dtype=ntype)))
327+
bin_index = _search_sorted_inclusive(sa, bin_edges)
328+
cum_n = cw[bin_index]
338329

339330
n = dpnp.diff(cum_n)
340331

0 commit comments

Comments
 (0)