diff --git a/cpp/include/cudf/detail/segmented_reduction.cuh b/cpp/include/cudf/detail/segmented_reduction.cuh index 9a49c1abe38..1c39d5eab1e 100644 --- a/cpp/include/cudf/detail/segmented_reduction.cuh +++ b/cpp/include/cudf/detail/segmented_reduction.cuh @@ -145,10 +145,10 @@ void segmented_reduce(InputIterator d_in, size_type* d_valid_counts, rmm::cuda_stream_view stream) { - using OutputType = typename thrust::iterator_value::type; - using IntermediateType = typename thrust::iterator_value::type; - auto num_segments = static_cast(std::distance(d_offset_begin, d_offset_end)); - auto const binary_op = op.get_binary_op(); + using OutputType = typename thrust::iterator_value::type; + using IntermediateType = typename thrust::iterator_value::type; + auto num_segments = static_cast(std::distance(d_offset_begin, d_offset_end)) - 1; + auto const binary_op = op.get_binary_op(); auto const initial_value = op.template get_identity(); rmm::device_uvector intermediate_result{static_cast(num_segments),