"...git@developer.sourcefind.cn:OpenDAS/torch-scatter.git" did not exist on "b3091036537f1034f38c67521766019e9e4f977d"
dimension.hpp 598 Bytes
Newer Older
Chao Liu's avatar
Chao Liu committed
1
2
3
4
5
6
7
8
#ifndef CK_DIMENSION_HPP
#define CK_DIMENSION_HPP

#include "common_header.hpp"

namespace ck {

template <index_t Length, index_t Stride>
Chao Liu's avatar
Chao Liu committed
9
struct NativeDimension
Chao Liu's avatar
Chao Liu committed
10
{
Chao Liu's avatar
Chao Liu committed
11
12
    __host__ __device__ static constexpr auto GetLength() { return Number<Length>{}; }

Chao Liu's avatar
Chao Liu committed
13
14
    __host__ __device__ static constexpr auto GetStride() { return Number<Stride>{}; }

Chao Liu's avatar
Chao Liu committed
15
    __host__ __device__ static constexpr index_t CalculateOffset(index_t i) { return i * Stride; }
Chao Liu's avatar
Chao Liu committed
16

Chao Liu's avatar
Chao Liu committed
17
    __host__ __device__ static constexpr index_t CalculateOffsetDiff(index_t i_diff)
Chao Liu's avatar
Chao Liu committed
18
    {
Chao Liu's avatar
Chao Liu committed
19
        return i_diff * Stride;
Chao Liu's avatar
Chao Liu committed
20
21
22
23
24
    }
};

} // namespace ck
#endif