Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mdspan accessor mixin offset policy. #628

Merged
merged 1 commit into from
Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cpp/include/raft/detail/mdarray.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ struct accessor_mixin : public AccessorPolicy {
using is_host_type = std::conditional_t<is_host, std::true_type, std::false_type>;
// make sure the explicit ctor can fall through
using AccessorPolicy::AccessorPolicy;
using offset_policy = accessor_mixin;
accessor_mixin(AccessorPolicy const& that) : AccessorPolicy{that} {} // NOLINT
};

Expand Down
14 changes: 8 additions & 6 deletions cpp/test/mdarray.cu
Original file line number Diff line number Diff line change
Expand Up @@ -409,12 +409,14 @@ TEST(MDArray, FuncArg)
make_device_matrix<float, layout_f_contiguous>(10, 10, rmm::cuda_stream_default);
check_matrix_layout(d_matrix.view());

// FIXME(jiamingy): The slice has a default accessor instead of accessor_mixin, due to
// the hardcoded policy in submdspan implementation. We need to have a rewritten
// version of submdspan for implementing padding.
// auto slice =
// stdex::submdspan(d_matrix.view(), std::make_tuple(2ul, 4ul), std::make_tuple(2ul, 5ul));
// check_matrix_layout(slice);
auto slice =
stdex::submdspan(d_matrix.view(), std::make_tuple(2ul, 4ul), std::make_tuple(2ul, 5ul));
static_assert(slice.is_strided());
ASSERT_EQ(slice.extent(0), 2);
ASSERT_EQ(slice.extent(1), 3);
// is using device_accessor mixin.
static_assert(
std::is_same_v<decltype(slice)::accessor_type, device_matrix_view<float>::accessor_type>);
}
}
} // namespace raft