diff --git a/cpp/src/reductions/simple.cuh b/cpp/src/reductions/simple.cuh index 76ed864a92d..5fe7b91e28a 100644 --- a/cpp/src/reductions/simple.cuh +++ b/cpp/src/reductions/simple.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -115,37 +115,12 @@ std::unique_ptr fixed_point_reduction( { using Type = device_storage_type_t; - auto dcol = cudf::column_device_view::create(col, stream); - auto simple_op = Op{}; - - // Cast initial value - std::optional const initial_value = [&] { - if (init.has_value() && init.value().get().is_valid()) { - using ScalarType = cudf::scalar_type_t; - return std::optional( - static_cast(&init.value().get())->value(stream)); - } else { - return std::optional(std::nullopt); - } - }(); - - auto result = [&] { - if (col.has_nulls()) { - auto f = simple_op.template get_null_replacing_element_transformer(); - auto it = thrust::make_transform_iterator(dcol->pair_begin(), f); - return cudf::reduction::detail::reduce(it, col.size(), simple_op, initial_value, stream, mr); - } else { - auto f = simple_op.template get_element_transformer(); - auto it = thrust::make_transform_iterator(dcol->begin(), f); - return cudf::reduction::detail::reduce(it, col.size(), simple_op, initial_value, stream, mr); - } - }(); + auto result = simple_reduction(col, init, stream, mr); auto const scale = [&] { if (std::is_same_v) { auto const valid_count = static_cast(col.size() - col.null_count()); - return numeric::scale_type{col.type().scale() * - (valid_count + (initial_value.has_value() ? 1 : 0))}; + return numeric::scale_type{col.type().scale() * (valid_count + (init.has_value() ? 1 : 0))}; } else if (std::is_same_v) { return numeric::scale_type{col.type().scale() * 2}; } diff --git a/cpp/tests/reductions/reduction_tests.cpp b/cpp/tests/reductions/reduction_tests.cpp index 997a5daa189..5a358687893 100644 --- a/cpp/tests/reductions/reduction_tests.cpp +++ b/cpp/tests/reductions/reduction_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -294,7 +294,6 @@ TYPED_TEST(SumReductionTest, Sum) .second); } -using ReductionTypes = cudf::test::Types; TYPED_TEST_SUITE(ReductionTest, cudf::test::NumericTypes); TYPED_TEST(ReductionTest, Product)