forked from kokkos/kokkos
-
Notifications
You must be signed in to change notification settings - Fork 3
/
strided_slice.hpp
48 lines (38 loc) · 1.57 KB
/
strided_slice.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//@HEADER
// ************************************************************************
//
// Kokkos v. 4.0
// Copyright (2022) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions.
// See https://kokkos.org/LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//@HEADER
#pragma once
#include <type_traits>
namespace MDSPAN_IMPL_STANDARD_NAMESPACE {
namespace {
template<class T>
struct __mdspan_is_integral_constant: std::false_type {};
template<class T, T val>
struct __mdspan_is_integral_constant<std::integral_constant<T,val>>: std::true_type {};
}
// Slice Specifier allowing for strides and compile time extent
template <class OffsetType, class ExtentType, class StrideType>
struct strided_slice {
using offset_type = OffsetType;
using extent_type = ExtentType;
using stride_type = StrideType;
_MDSPAN_NO_UNIQUE_ADDRESS OffsetType offset{};
_MDSPAN_NO_UNIQUE_ADDRESS ExtentType extent{};
_MDSPAN_NO_UNIQUE_ADDRESS StrideType stride{};
static_assert(std::is_integral_v<OffsetType> || __mdspan_is_integral_constant<OffsetType>::value);
static_assert(std::is_integral_v<ExtentType> || __mdspan_is_integral_constant<ExtentType>::value);
static_assert(std::is_integral_v<StrideType> || __mdspan_is_integral_constant<StrideType>::value);
};
} // MDSPAN_IMPL_STANDARD_NAMESPACE