vt::CuTensor#
-
template<typename T, size_t N>
class CuTensor# CuTensor class. It is used to adapt a Tensor to be used in CUDA kernel.
- Template Parameters:
T – Data type of the tensor.
N – Number of dimensions of the tensor.
Public Functions
-
inline __host__ CuTensor(Tensor<T, N> tensor)#
Construct a new CuTensor object from a Tensor.
- Parameters:
tensor – The tensor to be adapted.
- inline __host__ __device__ CuTensor (T *data, const size_t *shape, const size_t *strides, const size_t start, const size_t size, const Order order, const bool contiguous)
Construct a new CuTensor object from a raw pointer, shape, strides, start index, and contiguous flag.
- Parameters:
data – The raw pointer to the data.
shape – The shape of the tensor.
strides – The strides of the tensor.
start – The start index of the tensor.
size – The size of the tensor.
order – The order of the tensor.
contiguous – The contiguous flag of the tensor.
- template<typename... Args> inline __host__ __device__ size_t get_tensor_index (Args... args) const
Helper function to get the tensor index. (e.x. tensor(0, 1, 2))
- Parameters:
args – The indices of the tensor.
- Template Parameters:
Args – Variadic template for mulitple arguments.
- Returns:
size_t: The index of the tensor.
- template<typename... Args> inline __host__ __device__ T & operator() (Args... args)
Return the data given the indices.
- Parameters:
args – The indices of the tensor.
- Template Parameters:
Args – Variadic template for mulitple arguments.
- Returns:
T: The data of the tensor.
- template<typename... Args> inline __host__ __device__ const T & operator() (Args... args) const
Return the data given the indices.
- Parameters:
args – The indices of the tensor.
- Template Parameters:
Args – Variadic template for mulitple arguments.
- Returns:
T: The data of the tensor.
- inline __host__ __device__ T & operator[] (size_t n)
Return the data given the iterative index.
- Parameters:
n – The 1D index of the tensor.
- Returns:
T: The data of the tensor.
- inline __host__ __device__ const T & operator[] (size_t n) const
Return the data given the iterative index.
- Parameters:
n – The 1D index of the tensor.
- Returns:
T: The data of the tensor.