Skip to content

Commit

Permalink
Cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
trivialfis committed Jan 11, 2022
1 parent 239f284 commit 5409a45
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 deletions cpp/include/raft/linalg/mdarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,29 +257,20 @@ class mdarray {
using reference = typename container_policy_type::reference;
using const_reference = typename container_policy_type::const_reference;

private:
template <typename E>
using view_type_impl = std::conditional_t<
container_policy_type::is_host_type::value,
host_mdspan<E, extents_type, layout_type, typename container_policy_type::accessor_policy>,
device_mdspan<E, extents_type, layout_type, typename container_policy_type::accessor_policy>>;


public:
/**
* \brief the mdspan type returned by view method.
*/
using view_type =
std::conditional_t<container_policy_type::is_host_type::value,
host_mdspan<element_type,
extents_type,
layout_type,
typename container_policy_type::accessor_policy>,
device_mdspan<element_type,
extents_type,
layout_type,
typename container_policy_type::accessor_policy>>;
using const_view_type =
std::conditional_t<container_policy_type::is_host_type::value,
host_mdspan<element_type const,
extents_type,
layout_type,
typename container_policy_type::accessor_policy>,
device_mdspan<element_type const,
extents_type,
layout_type,
typename container_policy_type::accessor_policy>>;
using view_type = view_type_impl<element_type>;
using const_view_type = view_type_impl<element_type const>;

public:
constexpr mdarray() noexcept(std::is_nothrow_default_constructible<container_type>::value) =
Expand All @@ -297,6 +288,10 @@ class mdarray {

~mdarray() noexcept(std::is_nothrow_destructible<container_type>::value) = default;

/**
* @brief The only constructor that can create storage, this is to make sure CUDA stream is being
* used.
*/
constexpr mdarray(mapping_type const& m, container_policy_type const& cp)
: cp_(cp), map_(m), c_(cp_.create(map_.required_span_size()))
{
Expand Down

0 comments on commit 5409a45

Please sign in to comment.