Skip to content

Commit

Permalink
add transformer_mean for column MEAN reduction - enables timestamp MEAN
Browse files Browse the repository at this point in the history
  • Loading branch information
karthikeyann committed May 29, 2020
1 parent a5067bd commit 3e72ab0
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion cpp/include/cudf/detail/reduction_operators.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,33 @@ struct compound_op : public simple_op<Derived> {
// computes the final ResultType from the IntermediateType.
// intermediate::compute_result method is enforced by CRTP base class compound_op

template <typename T, typename Enable = void>
class transformer_mean;
template <typename T>
class transformer_mean<T, typename std::enable_if_t<!cudf::is_timestamp<T>()>> {
public:
template <typename InputType>
CUDA_HOST_DEVICE_CALLABLE auto operator()(InputType const& t) const
{
return thrust::identity<T>{}(t);
}
};
template <typename T>
class transformer_mean<T, typename std::enable_if_t<cudf::is_timestamp<T>()>> {
public:
template <typename InputType>
CUDA_HOST_DEVICE_CALLABLE auto operator()(InputType const& t) const
{
return thrust::identity<T>{}(t).time_since_epoch();
}
};

// operator for `mean`
struct mean : public compound_op<mean> {
using op = cudf::DeviceSum;

template <typename ResultType>
using transformer = thrust::identity<ResultType>;
using transformer = transformer_mean<ResultType>;

template <typename ResultType>
struct intermediate {
Expand Down

0 comments on commit 3e72ab0

Please sign in to comment.