Template Class FullTensorWrap
Defined in File FullTensorWrap.hpp
Class Documentation
-
template<typename T, int N>
class FullTensorWrap FullTensorWrap class is a non-owning wrap of a N-D tensor used for easy access of its elements in CUDA device.
FullTensorWrap is a wrapper of a multi-dimensional tensor that holds all information related to it, i.e.
N
strides andN
shapes, whereN
is its number of dimensions.Template arguments:
T type of the values inside the tensor
N dimensions
FullTensor wrapper class specialized for non-constant value type.
- Template Parameters:
T – Type (it can be const) of each element (or value) inside the tensor wrapper.
N – dimensions.
T – Type (non-const) of each element inside the tensor wrapper.
N – Number of dimensions.
Public Functions
-
FullTensorWrap() = default
- template<typename DataType> inline explicit __host__ __device__ FullTensorWrap (DataType *data, const int(&strides)[N], const int(&shapes)[N])
Constructs a FullTensorWrap by wrapping a
data
pointer argument.
-
inline __host__ FullTensorWrap(const TensorDataStridedCuda &tensor)
Constructs a FullTensorWrap by wrapping a
tensor
argument.- Parameters:
tensor – [in] Tensor reference to the tensor that will be wrapped.
- template<typename DimType> inline __host__ __device__ T & operator[] (DimType c) const
Subscript operator for read-and-write access.
- Parameters:
c – [in] N-D coordinate (from last to first dimension) to be accessed.
- Returns:
Accessed reference.
- template<typename... Args> inline __host__ __device__ T * ptr (Args... c) const
Get a read-and-write proxy (as pointer) at the Dth dimension.
- Parameters:
c0..D – [in] Each coordinate from first to last dimension
- Returns:
The pointer to the beginning of the Dth dimension
- inline __host__ __device__ const int * strides () const
Get strides in bytes for read-only access.
- Returns:
The const array (as a pointer) containing the strides in bytes.
- inline __host__ __device__ const int * shapes () const
Get shapes for read-only access.
- Returns:
The const array (as a pointer) containing the shapes.
Public Static Attributes
-
static constexpr int kConstantStrides
-
static constexpr int kNumDimensions
-
static constexpr int kVariableStrides
Protected Functions
- template<typename... Args> inline __host__ __device__ T * doGetPtr (Args... c) const