Skip to content

Commit

Permalink
fix is_row/col_order for strided layouts (#2173)
Browse files Browse the repository at this point in the history
Add additional constraint to is_row/col_major check.

Authors:
   - Malte Förster (https://github.com/mfoerste4)

Approvers:
   - Tamas Bela Feher (https://github.com/tfeher)
  • Loading branch information
mfoerste4 authored Feb 12, 2024
1 parent 9446430 commit dc75590
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions cpp/include/raft/util/input_validation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ constexpr bool is_row_or_column_major(mdspan<ElementType, Extents, layout_right,
template <class ElementType, class Extents, class Accessor>
constexpr bool is_row_or_column_major(mdspan<ElementType, Extents, layout_stride, Accessor> m)
{
return m.stride(0) == typename Extents::index_type(1) ||
m.stride(1) == typename Extents::index_type(1);
return is_row_major(m) || is_col_major(m);
}

template <class ElementType, class Extents, class Layout, class Accessor>
Expand All @@ -64,7 +63,7 @@ constexpr bool is_row_major(mdspan<ElementType, Extents, layout_right, Accessor>
template <class ElementType, class Extents, class Accessor>
constexpr bool is_row_major(mdspan<ElementType, Extents, layout_stride, Accessor> m)
{
return m.stride(1) == typename Extents::index_type(1);
return m.stride(1) == typename Extents::index_type(1) && m.stride(0) >= m.extent(1);
}

template <class ElementType, class Extents, class Layout, class Accessor>
Expand All @@ -88,7 +87,7 @@ constexpr bool is_col_major(mdspan<ElementType, Extents, layout_right, Accessor>
template <class ElementType, class Extents, class Accessor>
constexpr bool is_col_major(mdspan<ElementType, Extents, layout_stride, Accessor> m)
{
return m.stride(0) == typename Extents::index_type(1);
return m.stride(0) == typename Extents::index_type(1) && m.stride(1) >= m.extent(0);
}

template <class ElementType, class IndexType, size_t... Exts, class Layout, class Accessor>
Expand Down

0 comments on commit dc75590

Please sign in to comment.