TensorBatchWrap classes

group NVCV_CPP_CUDATOOLS_TENSORBATCHWRAP
template<typename T, int... Strides>
class TensorBatchWrap
#include <TensorBatchWrap.hpp>

TensorBatchWrap class is a non-owning wrap of a batch of N-D tensors used for easy access of its elements in CUDA device.

TensorBatchWrap is a wrapper of a batch of multi-dimensional tensors that can have one or more of its N dimension strides, or pitches, defined either at compile-time or at run-time. Each pitch in Strides represents the offset in bytes as a compile-time template parameter that will be applied from the first (slowest changing) dimension to the last (fastest changing) dimension of the tensor, in that order. Each dimension with run-time pitch is specified as -1 in the Strides template parameter.

Template arguments:

  • T type of the values inside the tensors

  • Strides sequence of compile- or run-time pitches (-1 indicates run-time)

    • Y compile-time pitches

    • X run-time pitches

    • N dimensions, where N = X + Y

For example, in the code below a wrap is defined for a batch of HWC 3D tensors where each row in H has a run-time row pitch (second -1), a pixel in W has a compile-time constant pitch as the size of the pixel type and a channel in C has also a compile-time constant pitch as the size of the channel type.

using DataType = ...;
using ChannelType = BaseType<DataType>;
using TensorBatchWrap = TensorBatchWrap<ChannelType, -1, sizeof(DataType), sizeof(ChannelType)>;
TensorBatch tensorBatch = ...;
TensorBatchWrap tensorBatchWrap(tensorBatch.data());
// Elements may be accessed via operator[] using an int4 argument.  They can also be accessed via pointer using
// the ptr method with up to 4 integer arguments or by accessing each TensorWrap separately with tensor(...) method.

TensorBatch wrapper class specialized for non-constant value type.

Template Parameters:
  • T – Type (it can be const) of each element inside the tensor wrapper.

  • Strides – Each compile-time (use -1 for run-time) pitch in bytes from first to last dimension.

  • T – Type (non-const) of each element inside the tensor batch wrapper.

  • Strides – Each compile-time (use -1 for run-time) pitch in bytes from first to last dimension.

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