Template Class BorderWrap

Inheritance Relationships

Base Type

Class Documentation

template<class TW, NVCVBorderType B, bool... ActiveDimensions>
class BorderWrap : public nvcv::cuda::detail::BorderWrapImpl<TW, B, ActiveDimensions...>

Border wrapper class used to wrap a TensorWrap adding border handling to it.

This class wraps a TensorWrap to add border handling functionality. It provides the methods ptr and operator[] to do the same semantic access, pointer or reference respectively, in the wrapped TensorWrap but border aware. It also provides a compile-time set of boolean flags to inform active border-aware dimensions. Active dimensions participate in border handling, storing the corresponding dimension shape. Inactive dimensions are not checked, the dimension shape is not stored, and thus core dump (or segmentation fault) might happen if accessing outside boundaries of inactive dimensions.

using DataType = ...;
using TensorWrap2D = TensorWrap<-1, -1, DataType>;
using BorderWrap2D = BorderWrap<TensorWrap2D, NVCV_BORDER_REFLECT, true, true>;
TensorWrap2D tensorWrap(...);
int2 tensorShape = ...;
BorderWrap2D borderAwareTensor(tensorWrap, tensorShape.x, tensorShape.y);
// Now use borderAwareTensor instead of tensorWrap to access elements inside or outside the tensor,
// outside elements use reflect border, that is the outside index is reflected back inside the tensor

See also

NVCV_CPP_CUDATOOLS_BORDERWRAPS

Template Parameters:
  • TW – It is a TensorWrap class with any dimension and type.

  • B – It is a NVCVBorderType indicating the border to be used.

  • ActiveDimensions – Flags to inform active (true) or inactive (false) dimensions.

Public Functions

BorderWrap() = default
template<typename... Args> inline explicit __host__ __device__ BorderWrap (TensorWrapper tensorWrap, ValueType borderValue, Args... tensorShape)

Constructs a BorderWrap by wrapping a tensorWrap.

Parameters:
  • tensorWrap[in] A TensorWrap or FullTensorWrap object to be wrapped.

  • borderValue[in] The border value is ignored in non-constant border types.

  • tensorShape0..D[in] Each shape from first to last dimension of the TensorWrap. This may be empty in case of wrapping a FullTensorWrap.

inline explicit __host__ BorderWrap(const TensorDataStridedCuda &tensor, ValueType borderValue = {})

Constructs a BorderWrap by wrapping a tensor.

Parameters:
  • tensor[in] A TensorDataStridedCuda object to be wrapped.

  • borderValue[in] The border value is ignored in non-constant border types.

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

Subscript operator for read-only or read-and-write access (depending on value type).

Parameters:

c[in] N-D coordinate (from last to first dimension) to be accessed.

Returns:

Accessed reference.

template<typename... Args> inline __host__ __device__ ValueType * ptr (Args... c) const

Get a read-only or read-and-write proxy (as pointer) at the Dth dimension.

Parameters:

c0..D[in] Each coordinate from first to last dimension.

Returns:

The (const) pointer to the beginning at the Dth dimension.