Template Class TensorBatchWrap< const T, Strides… >

Class Documentation

template<typename T, int... Strides>
class TensorBatchWrap<const T, Strides...>

Public Types

using ValueType = const T

Public Functions

TensorBatchWrap() = default
inline __host__ TensorBatchWrap(const TensorBatchDataStridedCuda &data)

Constructs a constant TensorBatchWrap by wrapping a data argument.

Parameters:

data[in] Tensor batch data to wrap.

inline __host__ __device__ TensorBatchWrap (const NVCVTensorBatchData &data)

Constructs a constant TensorBatchWrap by wrapping a data argument.

Parameters:

data[in] Tensor batch data to wrap.

template<typename... Coords> inline const __host__ __device__ T * ptr (int t, Coords... c) const

Get a read-only proxy (as pointer) of the given tensor at the given coordinates.

Parameters:
  • t[in] Tensor index in the list.

  • c[in] Coordinates in the given tensor;

Returns:

The const pointer to the beginning of the given coordinates.

template<typename DimType, class = Require<std::is_same_v<int, BaseType<DimType>>>> inline const __host__ __device__ T & operator[] (DimType c) const

Subscript operator for read-and-write access.

Parameters:
  • t[in] Tensor index in the list.

  • c[in] (N+1)-D coordinates tensor index and coords (from last to first dimension) to be accessed. E.g. for a 2-dimensional tensors, the coordinates would be: {tensor_id, column, row}

Returns:

Accessed reference.

inline const __host__ __device__ auto tensor (int t) const

Constructs a read-only wrapper for the tensor on index t The list of static strides can be provided as a template parameter. It should be a list of N outer strides (from inner to outer).

Template Parameters:

Strides – static strides

Parameters:

t – index of the tensor

inline __host__ __device__ int32_t numTensors () const

Returns a number of tensors in the batch.

inline const __host__ __device__ int64_t * shape (int t) const

Returns a pointer to shape buffer of the tensor at index t.

Parameters:

t – tensor index

inline const __host__ __device__ int64_t * strides (int t) const

Returns a pointer to a stride buffer of the tensor at index t.

Parameters:

t – tensor index

Public Static Attributes

static constexpr int kNumDimensions = sizeof...(Strides)
static constexpr int kVariableStrides = ((Strides == -1) + ...)
static constexpr int kConstantStrides = kNumDimensions - kVariableStrides

Protected Functions

template<typename... Args> inline __host__ __device__ T * doGetPtr (int t, Args... c) const

Protected Attributes

int32_t m_numTensors
NVCVTensorBatchElementStridedRec *m_tensors