Skip to content

Commit

Permalink
Merge branch 'rapidsai:branch-21.10' into select_dtypes_list
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahyurick authored Jul 27, 2021
2 parents 25e85cb + d942100 commit 3ad6f78
Show file tree
Hide file tree
Showing 74 changed files with 689 additions and 372 deletions.
6 changes: 3 additions & 3 deletions cpp/benchmarks/common/generate_benchmark_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ struct random_value_fn<T, typename std::enable_if_t<cudf::is_fixed_point<T>()>>
template <typename T>
struct random_value_fn<
T,
typename std::enable_if_t<!std::is_same<T, bool>::value && cudf::is_numeric<T>()>> {
typename std::enable_if_t<!std::is_same_v<T, bool> && cudf::is_numeric<T>()>> {
T const lower_bound;
T const upper_bound;
distribution_fn<T> dist;
Expand All @@ -194,7 +194,7 @@ struct random_value_fn<
* @brief Creates an boolean value with given probability of returning `true`.
*/
template <typename T>
struct random_value_fn<T, typename std::enable_if_t<std::is_same<T, bool>::value>> {
struct random_value_fn<T, typename std::enable_if_t<std::is_same_v<T, bool>>> {
std::bernoulli_distribution b_dist;

random_value_fn(distribution_params<bool> const& desc) : b_dist{desc.probability_true} {}
Expand Down Expand Up @@ -235,7 +235,7 @@ struct stored_as {

// Use `int8_t` for bools because that's how they're stored in columns
template <typename T>
struct stored_as<T, typename std::enable_if_t<std::is_same<T, bool>::value>> {
struct stored_as<T, typename std::enable_if_t<std::is_same_v<T, bool>>> {
using type = int8_t;
};

Expand Down
23 changes: 11 additions & 12 deletions cpp/benchmarks/common/generate_benchmark_input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ distribution_id default_distribution_id()
}

template <typename T,
std::enable_if_t<!std::is_same<T, bool>::value && std::is_unsigned<T>::value &&
std::enable_if_t<!std::is_same_v<T, bool> && std::is_unsigned<T>::value &&
cudf::is_numeric<T>()>* = nullptr>
distribution_id default_distribution_id()
{
Expand Down Expand Up @@ -130,7 +130,7 @@ struct distribution_params;
template <typename T>
struct distribution_params<
T,
typename std::enable_if_t<!std::is_same<T, bool>::value && cudf::is_numeric<T>()>> {
typename std::enable_if_t<!std::is_same_v<T, bool> && cudf::is_numeric<T>()>> {
distribution_id id;
T lower_bound;
T upper_bound;
Expand All @@ -140,7 +140,7 @@ struct distribution_params<
* @brief Booleans are parameterized with the probability of getting `true` value.
*/
template <typename T>
struct distribution_params<T, typename std::enable_if_t<std::is_same<T, bool>::value>> {
struct distribution_params<T, typename std::enable_if_t<std::is_same_v<T, bool>>> {
double probability_true;
};

Expand All @@ -158,8 +158,7 @@ struct distribution_params<T, typename std::enable_if_t<cudf::is_chrono<T>()>> {
* @brief Strings are parameterized by the distribution of their length, as an integral value.
*/
template <typename T>
struct distribution_params<T,
typename std::enable_if_t<std::is_same<T, cudf::string_view>::value>> {
struct distribution_params<T, typename std::enable_if_t<std::is_same_v<T, cudf::string_view>>> {
distribution_params<uint32_t> length_params;
};

Expand All @@ -168,7 +167,7 @@ struct distribution_params<T,
* the element type.
*/
template <typename T>
struct distribution_params<T, typename std::enable_if_t<std::is_same<T, cudf::list_view>::value>> {
struct distribution_params<T, typename std::enable_if_t<std::is_same_v<T, cudf::list_view>>> {
cudf::type_id element_type;
distribution_params<uint32_t> length_params;
cudf::size_type max_depth;
Expand Down Expand Up @@ -224,9 +223,9 @@ class data_profile {
cudf::size_type avg_run_length = 4;

public:
template <typename T,
typename std::enable_if_t<!std::is_same<T, bool>::value && std::is_integral<T>::value,
T>* = nullptr>
template <
typename T,
typename std::enable_if_t<!std::is_same_v<T, bool> && std::is_integral<T>::value, T>* = nullptr>
distribution_params<T> get_distribution_params() const
{
auto it = int_params.find(cudf::type_to_id<T>());
Expand All @@ -252,7 +251,7 @@ class data_profile {
}
}

template <typename T, std::enable_if_t<std::is_same<T, bool>::value>* = nullptr>
template <typename T, std::enable_if_t<std::is_same_v<T, bool>>* = nullptr>
distribution_params<T> get_distribution_params() const
{
return distribution_params<T>{bool_probability};
Expand All @@ -272,13 +271,13 @@ class data_profile {
}
}

template <typename T, std::enable_if_t<std::is_same<T, cudf::string_view>::value>* = nullptr>
template <typename T, std::enable_if_t<std::is_same_v<T, cudf::string_view>>* = nullptr>
distribution_params<T> get_distribution_params() const
{
return string_dist_desc;
}

template <typename T, std::enable_if_t<std::is_same<T, cudf::list_view>::value>* = nullptr>
template <typename T, std::enable_if_t<std::is_same_v<T, cudf::list_view>>* = nullptr>
distribution_params<T> get_distribution_params() const
{
return list_dist_desc;
Expand Down
16 changes: 8 additions & 8 deletions cpp/include/cudf/ast/detail/operators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ struct operator_functor<ast_operator::MOD> {

template <typename LHS,
typename RHS,
typename CommonType = std::common_type_t<LHS, RHS>,
std::enable_if_t<std::is_same<CommonType, float>::value>* = nullptr>
typename CommonType = std::common_type_t<LHS, RHS>,
std::enable_if_t<std::is_same_v<CommonType, float>>* = nullptr>
CUDA_DEVICE_CALLABLE auto operator()(LHS lhs, RHS rhs)
-> decltype(fmodf(static_cast<CommonType>(lhs), static_cast<CommonType>(rhs)))
{
Expand All @@ -305,8 +305,8 @@ struct operator_functor<ast_operator::MOD> {

template <typename LHS,
typename RHS,
typename CommonType = std::common_type_t<LHS, RHS>,
std::enable_if_t<std::is_same<CommonType, double>::value>* = nullptr>
typename CommonType = std::common_type_t<LHS, RHS>,
std::enable_if_t<std::is_same_v<CommonType, double>>* = nullptr>
CUDA_DEVICE_CALLABLE auto operator()(LHS lhs, RHS rhs)
-> decltype(fmod(static_cast<CommonType>(lhs), static_cast<CommonType>(rhs)))
{
Expand Down Expand Up @@ -334,8 +334,8 @@ struct operator_functor<ast_operator::PYMOD> {

template <typename LHS,
typename RHS,
typename CommonType = std::common_type_t<LHS, RHS>,
std::enable_if_t<std::is_same<CommonType, float>::value>* = nullptr>
typename CommonType = std::common_type_t<LHS, RHS>,
std::enable_if_t<std::is_same_v<CommonType, float>>* = nullptr>
CUDA_DEVICE_CALLABLE auto operator()(LHS lhs, RHS rhs)
-> decltype(fmodf(fmodf(static_cast<CommonType>(lhs), static_cast<CommonType>(rhs)) +
static_cast<CommonType>(rhs),
Expand All @@ -348,8 +348,8 @@ struct operator_functor<ast_operator::PYMOD> {

template <typename LHS,
typename RHS,
typename CommonType = std::common_type_t<LHS, RHS>,
std::enable_if_t<std::is_same<CommonType, double>::value>* = nullptr>
typename CommonType = std::common_type_t<LHS, RHS>,
std::enable_if_t<std::is_same_v<CommonType, double>>* = nullptr>
CUDA_DEVICE_CALLABLE auto operator()(LHS lhs, RHS rhs)
-> decltype(fmod(fmod(static_cast<CommonType>(lhs), static_cast<CommonType>(rhs)) +
static_cast<CommonType>(rhs),
Expand Down
20 changes: 10 additions & 10 deletions cpp/include/cudf/column/column_device_view.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ class alignas(16) column_device_view_base {
*`data<T>()`.
*
* This function will only participate in overload resolution if `is_rep_layout_compatible<T>()`
* or `std::is_same<T,void>::value` are true.
* or `std::is_same_v<T,void>` are true.
*
* @tparam The type to cast to
* @return T const* Typed pointer to underlying data
*/
template <typename T = void,
CUDF_ENABLE_IF(std::is_same<T, void>::value or is_rep_layout_compatible<T>())>
CUDF_ENABLE_IF(std::is_same_v<T, void> or is_rep_layout_compatible<T>())>
__host__ __device__ T const* head() const noexcept
{
return static_cast<T const*>(_data);
Expand Down Expand Up @@ -350,7 +350,7 @@ class alignas(16) column_device_view : public detail::column_device_view_base {
* @param element_index Position of the desired string element
* @return string_view instance representing this element at this index
*/
template <typename T, CUDF_ENABLE_IF(std::is_same<T, string_view>::value)>
template <typename T, CUDF_ENABLE_IF(std::is_same_v<T, string_view>)>
__device__ T element(size_type element_index) const noexcept
{
size_type index = element_index + offset(); // account for this view's _offset
Expand Down Expand Up @@ -411,7 +411,7 @@ class alignas(16) column_device_view : public detail::column_device_view_base {
* @param element_index Position of the desired element
* @return dictionary32 instance representing this element at this index
*/
template <typename T, CUDF_ENABLE_IF(std::is_same<T, dictionary32>::value)>
template <typename T, CUDF_ENABLE_IF(std::is_same_v<T, dictionary32>)>
__device__ T element(size_type element_index) const noexcept
{
size_type index = element_index + offset(); // account for this view's _offset
Expand All @@ -429,7 +429,7 @@ class alignas(16) column_device_view : public detail::column_device_view_base {
* @param element_index Position of the desired element
* @return numeric::decimal32 representing the element at this index
*/
template <typename T, CUDF_ENABLE_IF(std::is_same<T, numeric::decimal32>::value)>
template <typename T, CUDF_ENABLE_IF(std::is_same_v<T, numeric::decimal32>)>
__device__ T element(size_type element_index) const noexcept
{
using namespace numeric;
Expand All @@ -447,7 +447,7 @@ class alignas(16) column_device_view : public detail::column_device_view_base {
* @param element_index Position of the desired element
* @return numeric::decimal64 representing the element at this index
*/
template <typename T, CUDF_ENABLE_IF(std::is_same<T, numeric::decimal64>::value)>
template <typename T, CUDF_ENABLE_IF(std::is_same_v<T, numeric::decimal64>)>
__device__ T element(size_type element_index) const noexcept
{
using namespace numeric;
Expand Down Expand Up @@ -931,7 +931,7 @@ class alignas(16) mutable_column_device_view : public detail::column_device_view
* the specified type.
*
* This function will only participate in overload resolution if `is_rep_layout_compatible<T>()`
* or `std::is_same<T,void>::value` are true.
* or `std::is_same_v<T,void>` are true.
*
* @note If `offset() == 0`, then `head<T>() == data<T>()`
*
Expand All @@ -943,7 +943,7 @@ class alignas(16) mutable_column_device_view : public detail::column_device_view
* @return T* Typed pointer to underlying data
*/
template <typename T = void,
CUDF_ENABLE_IF(std::is_same<T, void>::value or is_rep_layout_compatible<T>())>
CUDF_ENABLE_IF(std::is_same_v<T, void> or is_rep_layout_compatible<T>())>
__host__ __device__ T* head() const noexcept
{
return const_cast<T*>(detail::column_device_view_base::head<T>());
Expand Down Expand Up @@ -1361,13 +1361,13 @@ struct pair_rep_accessor {
}

private:
template <typename R, std::enable_if_t<std::is_same<R, rep_type>::value, void>* = nullptr>
template <typename R, std::enable_if_t<std::is_same_v<R, rep_type>, void>* = nullptr>
CUDA_DEVICE_CALLABLE auto get_rep(cudf::size_type i) const
{
return col.element<R>(i);
}

template <typename R, std::enable_if_t<not std::is_same<R, rep_type>::value, void>* = nullptr>
template <typename R, std::enable_if_t<not std::is_same_v<R, rep_type>, void>* = nullptr>
CUDA_DEVICE_CALLABLE auto get_rep(cudf::size_type i) const
{
return col.element<R>(i).value();
Expand Down
8 changes: 4 additions & 4 deletions cpp/include/cudf/column/column_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ class column_view_base {
*`data<T>()`.
*
* This function will only participate in overload resolution if `is_rep_layout_compatible<T>()`
* or `std::is_same<T,void>::value` are true.
* or `std::is_same_v<T,void>` are true.
*
* @tparam The type to cast to
* @return T const* Typed pointer to underlying data
*/
template <typename T = void,
CUDF_ENABLE_IF(std::is_same<T, void>::value or is_rep_layout_compatible<T>())>
CUDF_ENABLE_IF(std::is_same_v<T, void> or is_rep_layout_compatible<T>())>
T const* head() const noexcept
{
return static_cast<T const*>(_data);
Expand Down Expand Up @@ -452,7 +452,7 @@ class mutable_column_view : public detail::column_view_base {
* the specified type.
*
* This function will only participate in overload resolution if `is_rep_layout_compatible<T>()`
* or `std::is_same<T,void>::value` are true.
* or `std::is_same_v<T,void>` are true.
*
* @note If `offset() == 0`, then `head<T>() == data<T>()`
*
Expand All @@ -463,7 +463,7 @@ class mutable_column_view : public detail::column_view_base {
* @return T* Typed pointer to underlying data
*/
template <typename T = void,
CUDF_ENABLE_IF(std::is_same<T, void>::value or is_rep_layout_compatible<T>())>
CUDF_ENABLE_IF(std::is_same_v<T, void> or is_rep_layout_compatible<T>())>
T* head() const noexcept
{
return const_cast<T*>(detail::column_view_base::head<T>());
Expand Down
15 changes: 15 additions & 0 deletions cpp/include/cudf/datetime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,21 @@ std::unique_ptr<cudf::column> is_leap_year(
cudf::column_view const& column,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());

/**
* @brief Returns the quarter of the date
*
* `output[i]` will be a value from {1, 2, 3, 4} corresponding to the quater of month given by
* `column[i]`. It will be null if the input row at `column[i]` is null.
*
* @throw cudf::logic_error if input column datatype is not a TIMESTAMP
*
* @param The input column containing datetime values
* @return A column of INT16 type indicating which quarter the date is in
*/
std::unique_ptr<cudf::column> extract_quarter(
cudf::column_view const& column,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());

/** @} */ // end of group
} // namespace datetime
} // namespace cudf
4 changes: 2 additions & 2 deletions cpp/include/cudf/detail/copy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ namespace detail {
template <typename ColumnView>
ColumnView slice(ColumnView const& input, cudf::size_type begin, cudf::size_type end)
{
static_assert(std::is_same<ColumnView, cudf::column_view>::value or
std::is_same<ColumnView, cudf::mutable_column_view>::value,
static_assert(std::is_same_v<ColumnView, cudf::column_view> or
std::is_same_v<ColumnView, cudf::mutable_column_view>,
"slice can be performed only on column_view and mutable_column_view");
CUDF_EXPECTS(begin >= 0, "Invalid beginning of range.");
CUDF_EXPECTS(end >= begin, "Invalid end of range.");
Expand Down
4 changes: 2 additions & 2 deletions cpp/include/cudf/detail/copy_if.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,12 @@ struct DeviceType<T, std::enable_if_t<cudf::is_timestamp<T>()>> {
};

template <typename T>
struct DeviceType<T, std::enable_if_t<std::is_same<numeric::decimal32, T>::value>> {
struct DeviceType<T, std::enable_if_t<std::is_same_v<numeric::decimal32, T>>> {
using type = typename cudf::device_storage_type_t<T>;
};

template <typename T>
struct DeviceType<T, std::enable_if_t<std::is_same<numeric::decimal64, T>::value>> {
struct DeviceType<T, std::enable_if_t<std::is_same_v<numeric::decimal64, T>>> {
using type = typename cudf::device_storage_type_t<T>;
};

Expand Down
5 changes: 5 additions & 0 deletions cpp/include/cudf/detail/datetime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ std::unique_ptr<cudf::column> is_leap_year(
rmm::cuda_stream_view stream = rmm::cuda_stream_default,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());

std::unique_ptr<cudf::column> extract_quarter(
cudf::column_view const& column,
rmm::cuda_stream_view stream = rmm::cuda_stream_default,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());

} // namespace detail
} // namespace datetime
} // namespace cudf
2 changes: 1 addition & 1 deletion cpp/include/cudf/detail/reduction.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ std::unique_ptr<scalar> reduce(InputIterator d_in,
template <typename Op,
typename InputIterator,
typename OutputType = typename thrust::iterator_value<InputIterator>::type,
typename std::enable_if_t<std::is_same<OutputType, string_view>::value>* = nullptr>
typename std::enable_if_t<std::is_same_v<OutputType, string_view>>* = nullptr>
std::unique_ptr<scalar> reduce(InputIterator d_in,
cudf::size_type num_items,
op::simple_op<Op> sop,
Expand Down
14 changes: 6 additions & 8 deletions cpp/include/cudf/detail/utilities/device_operators.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ struct DeviceMin {

template <
typename T,
typename std::enable_if_t<!std::is_same<T, cudf::string_view>::value &&
!cudf::is_dictionary<T>() && !cudf::is_fixed_point<T>()>* = nullptr>
typename std::enable_if_t<!std::is_same_v<T, cudf::string_view> && !cudf::is_dictionary<T>() &&
!cudf::is_fixed_point<T>()>* = nullptr>
static constexpr T identity()
{
return std::numeric_limits<T>::max();
Expand All @@ -109,8 +109,7 @@ struct DeviceMin {
}

// @brief identity specialized for string_view
template <typename T,
typename std::enable_if_t<std::is_same<T, cudf::string_view>::value>* = nullptr>
template <typename T, typename std::enable_if_t<std::is_same_v<T, cudf::string_view>>* = nullptr>
CUDA_HOST_DEVICE_CALLABLE static constexpr T identity()
{
return string_view::max();
Expand All @@ -133,8 +132,8 @@ struct DeviceMax {

template <
typename T,
typename std::enable_if_t<!std::is_same<T, cudf::string_view>::value &&
!cudf::is_dictionary<T>() && !cudf::is_fixed_point<T>()>* = nullptr>
typename std::enable_if_t<!std::is_same_v<T, cudf::string_view> && !cudf::is_dictionary<T>() &&
!cudf::is_fixed_point<T>()>* = nullptr>
static constexpr T identity()
{
return std::numeric_limits<T>::lowest();
Expand All @@ -147,8 +146,7 @@ struct DeviceMax {
return std::numeric_limits<T>::lowest();
}

template <typename T,
typename std::enable_if_t<std::is_same<T, cudf::string_view>::value>* = nullptr>
template <typename T, typename std::enable_if_t<std::is_same_v<T, cudf::string_view>>* = nullptr>
CUDA_HOST_DEVICE_CALLABLE static constexpr T identity()
{
return string_view::min();
Expand Down
Loading

0 comments on commit 3ad6f78

Please sign in to comment.