Math operators
- group NVCV_CPP_CUDATOOLS_MATHOPERATORS
Operators on CUDA compound types resembling the same operator on corresponding regular C type.
This whole group defines a set of arithmetic and bitwise operators defined on CUDA compound types. They work the same way as the corresponding regular C type. For instance, three int3 a, b and c, will accept the operation a += b * c (see example below). Furthermore, the operators accept mixed operands as CUDA compound and regular C types, e.g. two int3 a and b and one int c will accept the operation a += b * c, where the scalar c propagates its value for all components of b in the multiplication and the int3 result in the assignment to a.
using DataType = ...; DataType pix = ...; float kernel = ...; ConvertBaseTypeTo<float, DataType> res = {0}; res += kernel * pix;
- tparam T:
Type of the first CUDA compound or regular C type operand.
- tparam U:
Type of the second CUDA compound or regular C type operand.
- param a:
[in] First operand.
- param b:
[in] Second operand.
- return:
Return value of applying the operator on
a
andb
.
Defines
-
NVCV_CUDA_UNARY_OPERATOR(OPERATOR, REQUIREMENT)
-
NVCV_CUDA_BINARY_OPERATOR(OPERATOR, REQUIREMENT)
Functions
- template<typename T, class = nvcv::cuda::Require< nvcv::cuda::IsCompound <T>>> inline __host__ __device__ auto operator- (T a)
- template<typename T, class = nvcv::cuda::Require< nvcv::cuda::IsCompound <T>>> inline __host__ __device__ auto operator+ (T a)
- template<typename T, class = nvcv::cuda::Require< nvcv::cuda::detail::IsIntegralCompound <T>>> inline __host__ __device__ auto operator~ (T a)
- template<typename T, typename U, class = nvcv::cuda::Require< nvcv::cuda::detail::OneIsCompound <T, U>>> inline __host__ __device__ auto operator- (T a, U b)
- template<typename T, typename U, class = nvcv::cuda::Require<nvcv::cuda::IsCompound<T>>> inline __host__ __device__ T & operator-= (T &a, U b)
- template<typename T, typename U, class = nvcv::cuda::Require< nvcv::cuda::detail::OneIsCompound <T, U>>> inline __host__ __device__ auto operator+ (T a, U b)
- template<typename T, typename U, class = nvcv::cuda::Require<nvcv::cuda::IsCompound<T>>> inline __host__ __device__ T & operator+= (T &a, U b)
- template<typename T, typename U, class = nvcv::cuda::Require< nvcv::cuda::detail::OneIsCompound <T, U>>> inline __host__ __device__ auto operator* (T a, U b)
- template<typename T, typename U, class = nvcv::cuda::Require<nvcv::cuda::IsCompound<T>>> inline __host__ __device__ T & operator*= (T &a, U b)
- template<typename T, typename U, class = nvcv::cuda::Require< nvcv::cuda::detail::OneIsCompound <T, U>>> inline __host__ __device__ auto operator/ (T a, U b)
- template<typename T, typename U, class = nvcv::cuda::Require<nvcv::cuda::IsCompound<T>>> inline __host__ __device__ T & operator/= (T &a, U b)
- template<typename T, typename U, class = nvcv::cuda::Require< nvcv::cuda::detail::OneIsCompoundAndBothAreIntegral <T, U>>> inline __host__ __device__ auto operator% (T a, U b)
- template<typename T, typename U, class = nvcv::cuda::Require<nvcv::cuda::IsCompound<T>>> inline __host__ __device__ T & operator%= (T &a, U b)
- template<typename T, typename U, class = nvcv::cuda::Require< nvcv::cuda::detail::OneIsCompoundAndBothAreIntegral <T, U>>> inline __host__ __device__ auto operator& (T a, U b)
- template<typename T, typename U, class = nvcv::cuda::Require<nvcv::cuda::IsCompound<T>>> inline __host__ __device__ T & operator&= (T &a, U b)
- template<typename T, typename U, class = nvcv::cuda::Require< nvcv::cuda::detail::OneIsCompoundAndBothAreIntegral <T, U>>> inline __host__ __device__ auto operator| (T a, U b)
- template<typename T, typename U, class = nvcv::cuda::Require<nvcv::cuda::IsCompound<T>>> inline __host__ __device__ T & operator|= (T &a, U b)
- template<typename T, typename U, class = nvcv::cuda::Require< nvcv::cuda::detail::OneIsCompoundAndBothAreIntegral <T, U>>> inline __host__ __device__ auto operator^ (T a, U b)
- template<typename T, typename U, class = nvcv::cuda::Require<nvcv::cuda::IsCompound<T>>> inline __host__ __device__ T & operator^= (T &a, U b)
- template<typename T, typename U, class = nvcv::cuda::Require< nvcv::cuda::detail::OneIsCompoundAndBothAreIntegral <T, U>>> inline __host__ __device__ auto operator<< (T a, U b)
- template<typename T, typename U, class = nvcv::cuda::Require<nvcv::cuda::IsCompound<T>>> inline __host__ __device__ T & operator<<= (T &a, U b)
- template<typename T, typename U, class = nvcv::cuda::Require< nvcv::cuda::detail::OneIsCompoundAndBothAreIntegral <T, U>>> inline __host__ __device__ auto operator>> (T a, U b)
- template<typename T, typename U, class = nvcv::cuda::Require<nvcv::cuda::IsCompound<T>>> inline __host__ __device__ T & operator>>= (T &a, U b)
- template<typename T, typename U, class = nvcv::cuda::Require<nvcv::cuda::detail::IsSameCompound<T, U>>> inline __host__ __device__ bool operator== (T a, U b)
- template<typename T, typename U, class = nvcv::cuda::Require<nvcv::cuda::detail::IsSameCompound<T, U>>> inline __host__ __device__ bool operator!= (T a, U b)
-
namespace nvcv
Typedefs
-
using CustomHostMemAllocator = CustomMemAllocator<HostMemAllocator>
-
using CustomHostPinnedMemAllocator = CustomMemAllocator<HostPinnedMemAllocator>
-
using CustomCudaMemAllocator = CustomMemAllocator<CudaMemAllocator>
-
using ArrayDataCleanupCallback = CleanupCallback<ArrayDataCleanupFunc, detail::RemovePointer_t<NVCVArrayDataCleanupFunc>, TranslateArrayDataCleanup>
-
using ArrayWrapHandle = NonOwningResource<Array>
-
template<class T>
using HandleTypeOf = typename std::remove_pointer<T>::type::HandleType Helper type alias to deduce the handle type of a given class
T
.This type alias uses std::remove_pointer to strip the pointer off of
T
(if any), and then accesses theHandleType
nested type withinT
.- Template Parameters:
T – The class type from which to deduce the handle type.
-
using ExtraChannelInfo = NVCVExtraChannelInfo
-
template<typename CppFuncType, typename CFuncType = detail::AddContext_t<CppFuncType>, typename TranslateCall = detail::NoTranslation>
using CleanupCallback = Callback<CppFuncType, CFuncType, TranslateCall, true>
-
typedef CleanupCallback<ImageDataCleanupFunc, detail::RemovePointer_t<NVCVImageDataCleanupFunc>, TranslateImageDataCleanup> ImageDataCleanupCallback
-
using ImageWrapHandle = NonOwningResource<Image>
-
using ImageBatchWrapHandle = NonOwningResource<ImageBatch>
-
using ImageBatchVarShapeWrapHandle = NonOwningResource<ImageBatchVarShape>
-
using OptionalImageBatchVarShapeConstRef = nvcv::Optional<std::reference_wrapper<const nvcv::ImageBatchVarShape>>
-
using ImageBufferStrided = NVCVImageBufferStrided
-
using ImagePlaneStrided = NVCVImagePlaneStrided
-
using TensorDataCleanupFunc = void(const TensorData&)
-
using TensorDataCleanupCallback = CleanupCallback<TensorDataCleanupFunc, detail::RemovePointer_t<NVCVTensorDataCleanupFunc>, TranslateTensorDataCleanup>
-
using TensorWrapHandle = NonOwningResource<Tensor>
-
using TensorBatchWrapHandle = NonOwningResource<TensorBatch>
Enums
-
enum class ColorModel : int8_t
Values:
-
enumerator UNDEFINED
-
enumerator YCbCr
-
enumerator RGB
-
enumerator RAW
-
enumerator XYZ
-
enumerator UNDEFINED
-
enum class ColorSpace : int8_t
Values:
-
enumerator BT601
-
enumerator BT709
-
enumerator BT2020
-
enumerator DCIP3
-
enumerator BT601
-
enum class YCbCrEncoding : int8_t
Values:
-
enumerator UNDEFINED
-
enumerator BT601
-
enumerator BT709
-
enumerator BT2020
-
enumerator BT2020c
-
enumerator SMPTE240M
-
enumerator UNDEFINED
-
enum class ColorTransferFunction : int8_t
Values:
-
enumerator LINEAR
-
enumerator sRGB
-
enumerator sYCC
-
enumerator PQ
-
enumerator BT709
-
enumerator BT2020
-
enumerator SMPTE240M
-
enumerator LINEAR
-
enum class ChromaLocation : int8_t
Values:
-
enumerator EVEN
-
enumerator CENTER
-
enumerator ODD
-
enumerator BOTH
-
enumerator EVEN
-
enum class RawPattern : uint8_t
Values:
-
enumerator BAYER_RGGB
-
enumerator BAYER_BGGR
-
enumerator BAYER_GRBG
-
enumerator BAYER_GBRG
-
enumerator BAYER_RCCB
-
enumerator BAYER_BCCR
-
enumerator BAYER_CRBC
-
enumerator BAYER_CBRC
-
enumerator BAYER_RCCC
-
enumerator BAYER_CRCC
-
enumerator BAYER_CCRC
-
enumerator BAYER_CCCR
-
enumerator BAYER_CCCC
-
enumerator BAYER_RGGB
-
enum class ChromaSubsampling : int8_t
Values:
-
enumerator NONE
-
enumerator CSS_444
-
enumerator CSS_422
-
enumerator CSS_422R
-
enumerator CSS_411
-
enumerator CSS_411R
-
enumerator CSS_420
-
enumerator CSS_440
-
enumerator CSS_410
-
enumerator CSS_410R
-
enumerator NONE
-
enum class Packing : int32_t
Values:
-
enumerator NONE
-
enumerator X1
One 1-bit channel.
-
enumerator X2
One 2-bit channel.
-
enumerator X4
One 4-bit channel.
-
enumerator X8
One 8-bit channel.
-
enumerator X4Y4
Two 4-bit channels in one word.
-
enumerator X3Y3Z2
Three 3-, 3- and 2-bit channels in one 8-bit word.
-
enumerator X16
One 16-bit channel.
-
enumerator b6X10
One LSB 10-bit channel in one 16-bit word.
-
enumerator X10b6
One MSB 10-bit channel in one 16-bit word.
-
enumerator b4X12
One LSB 12-bit channel in one 16-bit word.
-
enumerator X12b4
One MSB 12-bit channel in one 16-bit word.
-
enumerator b2X14
One LSB 14-bit channel in one 16-bit word.
-
enumerator X8_Y8
Two 8-bit channels in two 8-bit words.
-
enumerator X5Y5Z6
Three 5-, 5- and 6-bit channels in one 16-bit word.
-
enumerator X5Y6Z5
Three 5-, 6- and 5-bit channels in one 16-bit word.
-
enumerator X6Y5Z5
Three 6-, 5- and 5-bit channels in one 16-bit word.
-
enumerator b4X4Y4Z4
Three 4-bit channels in one 16-bit word.
-
enumerator b1X5Y5Z5
Three 5-bit channels in one 16-bit word.
-
enumerator X5Y5b1Z5
Three 5-bit channels in one 16-bit word.
-
enumerator X1Y5Z5W5
Four 1-, 5-, 5- and 5-bit channels in one 16-bit word.
-
enumerator X4Y4Z4W4
Four 4-bit channels in one 16-bit word.
-
enumerator X5Y1Z5W5
Four 5-, 1-, 5- and 5-bit channels in one 16-bit word.
-
enumerator X5Y5Z1W5
Four 5-, 5-, 1- and 5-bit channels in one 16-bit word.
-
enumerator X5Y5Z5W1
Four 5-, 5-, 5- and 1-bit channels in one 16-bit word.
-
enumerator X8_Y8__X8_Z8
2 pixels of 2 8-bit channels each, totalling 4 8-bit words.
-
enumerator Y8_X8__Z8_X8
2 pixels of 2 swapped 8-bit channels each, totalling 4 8-bit words.
-
enumerator X24
One 24-bit channel.
-
enumerator X8_Y8_Z8
Three 8-bit channels in three 8-bit words.
-
enumerator X32
One 32-bit channel.
-
enumerator b12X20
One LSB 20-bit channel in one 32-bit word.
-
enumerator X16_Y16
Two 16-bit channels in two 16-bit words.
-
enumerator X10b6_Y10b6
Two MSB 10-bit channels in two 16-bit words.
-
enumerator X12b4_Y12b4
Two MSB 12-bit channels in two 16-bit words.
-
enumerator X10Y11Z11
Three 10-, 11- and 11-bit channels in one 32-bit word.
-
enumerator X11Y11Z10
Three 11-, 11- and 10-bit channels in one 32-bit word.
-
enumerator X8_Y8_Z8_W8
Four 8-bit channels in one 32-bit word.
-
enumerator X2Y10Z10W10
Four 2-, 10-, 10- and 10-bit channels in one 32-bit word.
-
enumerator X10Y10Z10W2
Four 10-, 10-, 10- and 2-bit channels in one 32-bit word.
-
enumerator X48
One 48-bit channel.
-
enumerator X16_Y16_Z16
Three 16-bit channels in three 16-bit words.
-
enumerator X64
One 64-bit channel.
-
enumerator X32_Y32
Two 32-bit channels in two 32-bit words.
-
enumerator X16_Y16_Z16_W16
Four 16-bit channels in one 64-bit word.
-
enumerator X96
One 96-bit channel.
-
enumerator X32_Y32_Z32
Three 32-bit channels in three 32-bit words.
-
enumerator X128
One 128-bit channel.
-
enumerator X64_Y64
Two 64-bit channels in two 64-bit words.
-
enumerator X32_Y32_Z32_W32
Four 32-bit channels in three 32-bit words.
-
enumerator X192
One 192-bit channel.
-
enumerator X64_Y64_Z64
Three 64-bit channels in three 64-bit words.
-
enumerator X256
One 256-bit channel.
-
enumerator X128_Y128
Two 128-bit channels in two 128-bit words.
-
enumerator X64_Y64_Z64_W64
Four 64-bit channels in four 64-bit words.
-
enumerator NONE
-
enum class DataKind : int8_t
Values:
-
enumerator UNSPECIFIED
-
enumerator UNSIGNED
-
enumerator SIGNED
-
enumerator FLOAT
-
enumerator COMPLEX
-
enumerator UNSPECIFIED
-
enum class MemLayout : int8_t
Values:
-
enumerator PITCH_LINEAR
-
enumerator BLOCK1_LINEAR
-
enumerator BLOCK2_LINEAR
-
enumerator BLOCK4_LINEAR
-
enumerator BLOCK8_LINEAR
-
enumerator BLOCK16_LINEAR
-
enumerator BLOCK32_LINEAR
-
enumerator BLOCK_LINEAR
-
enumerator PL
-
enumerator BL
-
enumerator PITCH_LINEAR
-
enum class Channel : int8_t
Values:
-
enumerator NONE
-
enumerator X
-
enumerator Y
-
enumerator Z
-
enumerator W
-
enumerator MAX
-
enumerator NONE
-
enum class Swizzle : int32_t
Values:
-
enumerator S_0000
-
enumerator S_1000
-
enumerator S_0001
-
enumerator S_XYZW
-
enumerator S_ZYXW
-
enumerator S_WXYZ
-
enumerator S_WZYX
-
enumerator S_YZWX
-
enumerator S_XYZ1
-
enumerator S_XYZ0
-
enumerator S_YZW1
-
enumerator S_XXX1
-
enumerator S_XZY1
-
enumerator S_ZYX1
-
enumerator S_ZYX0
-
enumerator S_WZY1
-
enumerator S_X000
-
enumerator S_0X00
-
enumerator S_00X0
-
enumerator S_000X
-
enumerator S_Y000
-
enumerator S_0Y00
-
enumerator S_00Y0
-
enumerator S_000Y
-
enumerator S_0XY0
-
enumerator S_XXXY
-
enumerator S_YYYX
-
enumerator S_0YX0
-
enumerator S_X00Y
-
enumerator S_Y00X
-
enumerator S_X001
-
enumerator S_XY01
-
enumerator S_XY00
-
enumerator S_0XZ0
-
enumerator S_0ZX0
-
enumerator S_XZY0
-
enumerator S_YZX1
-
enumerator S_ZYW1
-
enumerator S_0YX1
-
enumerator S_XYXZ
-
enumerator S_YXZX
-
enumerator S_XZ00
-
enumerator S_WYXZ
-
enumerator S_YX00
-
enumerator S_YX01
-
enumerator S_00YX
-
enumerator S_00XY
-
enumerator S_0XY1
-
enumerator S_0X01
-
enumerator S_YZXW
-
enumerator S_YW00
-
enumerator S_XYW0
-
enumerator S_YZW0
-
enumerator S_YZ00
-
enumerator S_00X1
-
enumerator S_0ZXY
-
enumerator S_UNSUPPORTED
-
enumerator S_0000
-
enum class Status : int8_t
Values:
-
enumerator SUCCESS
-
enumerator ERROR_NOT_IMPLEMENTED
-
enumerator ERROR_INVALID_ARGUMENT
-
enumerator ERROR_INVALID_IMAGE_FORMAT
-
enumerator ERROR_INVALID_OPERATION
-
enumerator ERROR_DEVICE
-
enumerator ERROR_NOT_READY
-
enumerator ERROR_OUT_OF_MEMORY
-
enumerator ERROR_INTERNAL
-
enumerator ERROR_NOT_COMPATIBLE
-
enumerator ERROR_OVERFLOW
-
enumerator ERROR_UNDERFLOW
-
enumerator SUCCESS
Functions
-
template<>
inline int HandleDecRef<NVCVAllocatorHandle>(NVCVAllocatorHandle h)
-
template<>
inline int HandleIncRef<NVCVAllocatorHandle>(NVCVAllocatorHandle h)
-
template<>
inline int HandleRefCount<NVCVAllocatorHandle>(NVCVAllocatorHandle h)
-
template<typename ...ResourceAllocators>
CustomAllocator<ResourceAllocators...> CreateCustomAllocator(ResourceAllocators&&... allocators) Constructs a
CustomAllocator
from a set of resource allocators.
-
inline int64_t CalcTotalSizeBytes(const Requirements::ConstMemory &mem)
-
template<>
inline int HandleDecRef<NVCVArrayHandle>(NVCVArrayHandle h)
-
template<>
inline int HandleIncRef<NVCVArrayHandle>(NVCVArrayHandle h)
-
template<>
inline int HandleRefCount<NVCVArrayHandle>(NVCVArrayHandle h)
-
inline Array ArrayWrapData(const ArrayData &data, ArrayDataCleanupCallback &&cleanup = {})
-
template<class T>
auto StaticCast(HandleTypeOf<T> h) -> decltype(detail::StaticCast<T>::cast(h)) A templated function to perform a static cast on the handle type of a given class
T
.This function uses the
StaticCast
structure in thedetail
namespace to perform the static cast. Thedecltype
keyword is used to deduce the return type of the function.- Template Parameters:
T – The class type to use for the static cast.
- Parameters:
h – The handle type instance to be cast.
- Returns:
Returns the result of the static cast operation.
-
template<class T>
auto DynamicCast(HandleTypeOf<T> h) -> decltype(detail::StaticCast<T>::cast(h)) A templated function to perform a dynamic cast on the handle type of a given class
T
.This function uses the
DynamicCast
structure in thedetail
namespace to perform the dynamic cast. Thedecltype
keyword is used to deduce the return type of the function.- Template Parameters:
T – The class type to use for the dynamic cast.
- Parameters:
h – The handle type instance to be cast.
- Returns:
Returns the result of the dynamic cast operation.
-
inline ChromaSubsampling MakeChromaSubsampling(int samplesHoriz, int samplesVert)
-
inline int GetSamplesHoriz(ChromaSubsampling css)
-
inline int GetSamplesVert(ChromaSubsampling css)
-
inline bool NeedsColorspec(ColorModel cmodel)
-
inline std::ostream &operator<<(std::ostream &out, ColorModel colorModel)
-
inline std::ostream &operator<<(std::ostream &out, ChromaSubsampling chromaSub)
-
inline std::ostream &operator<<(std::ostream &out, ColorTransferFunction xferFunc)
-
inline std::ostream &operator<<(std::ostream &out, YCbCrEncoding enc)
-
inline std::ostream &operator<<(std::ostream &out, ColorRange range)
-
inline std::ostream &operator<<(std::ostream &out, WhitePoint whitePoint)
-
inline std::ostream &operator<<(std::ostream &out, ColorSpace color_space)
-
inline std::ostream &operator<<(std::ostream &out, ChromaLocation loc)
-
inline std::ostream &operator<<(std::ostream &out, RawPattern raw)
-
inline Packing MakePacking(const PackingParams ¶ms)
-
inline PackingParams GetParams(Packing packing)
-
inline ImageBatchVarShape::Iterator operator+(ImageBatchVarShape::Iterator::difference_type diff, const ImageBatchVarShape::Iterator &it)
-
inline Image ImageWrapData(const ImageData &data, ImageDataCleanupCallback &&cleanup)
-
inline Tensor TensorWrapData(const TensorData &data, TensorDataCleanupCallback &&cleanup = {})
Wraps tensor data into a tensor object.
- Parameters:
data – Tensor data to be wrapped.
cleanup – Cleanup callback to manage the tensor data’s lifecycle.
- Returns:
A tensor object wrapping the given data.
-
inline Tensor TensorWrapImage(const Image &img)
Wraps an image into a tensor object.
- Parameters:
img – Image to be wrapped.
- Returns:
A tensor object wrapping the given image.
-
inline void SetThreadError(std::exception_ptr e)
Sets the thread’s error status based on a captured exception.
This function tries to rethrow the given exception and based on its type, it sets the appropriate error status for the current thread using the
nvcvSetThreadStatus
function.- Parameters:
e – The captured exception to be rethrown and processed.
-
template<class F>
NVCVStatus ProtectCall(F &&fn) Safely executes a function, capturing and setting any exceptions that arise.
This function acts as a wrapper to safely execute a given function or lambda (
fn
). If the function throws any exception, the exception is captured, and the error status is set for the current thread using theSetThreadError
function.- Parameters:
fn – The function or lambda to be executed.
- Template Parameters:
F – The type of the function or lambda.
- Returns:
NVCV_SUCCESS if
fn
executed without exceptions, otherwise the error code from the caught exception.
-
template<typename HandleType>
int HandleDecRef(HandleType handle)
-
template<typename HandleType>
int HandleIncRef(HandleType handle)
-
template<typename HandleType>
int HandleRefCount(HandleType handle)
-
template<typename HandleType>
void HandleDestroy(HandleType handle)
-
template<typename HandleType>
constexpr HandleType NullHandle()
-
template<typename HandleType>
constexpr bool HandleIsNull(HandleType h)
-
template<>
inline int HandleDecRef<NVCVImageHandle>(NVCVImageHandle h)
-
template<>
inline int HandleIncRef<NVCVImageHandle>(NVCVImageHandle h)
-
template<>
inline int HandleRefCount<NVCVImageHandle>(NVCVImageHandle h)
-
template<>
inline int HandleDecRef<NVCVImageBatchHandle>(NVCVImageBatchHandle h)
-
template<>
inline int HandleIncRef<NVCVImageBatchHandle>(NVCVImageBatchHandle h)
-
template<>
inline int HandleRefCount<NVCVImageBatchHandle>(NVCVImageBatchHandle h)
-
inline std::ostream &operator<<(std::ostream &out, ImageFormat fmt)
-
inline bool HasSameDataLayout(ImageFormat a, ImageFormat b)
-
constexpr Size2D MaxSize(const Size2D &a, const Size2D &b)
Computes the maximum size in each dimension.
- Parameters:
a – First size to compare.
b – Second size to compare.
- Returns:
The size with
w
andh
computed as a maximum of the respective fields ina
andb
.
-
inline std::ostream &operator<<(std::ostream &out, const nvcv::Size2D &size)
Overloads the stream insertion operator for Size2D.
This allows for easy printing of Size2D structures in the format “width x height”.
- Parameters:
out – Output stream to which the size string will be written.
size – Size2D structure to be output.
- Returns:
Reference to the modified output stream.
-
inline const char *GetName(Status status)
Retrieves the name (string representation) of the given status.
- Parameters:
status – Status code whose name is to be retrieved.
- Returns:
String representation of the status.
-
inline std::ostream &operator<<(std::ostream &out, Status status)
Overloads the stream insertion operator for Status enum.
- Parameters:
out – Output stream to which the status string will be written.
status – Status code to be output.
- Returns:
Reference to the modified output stream.
-
inline std::ostream &operator<<(std::ostream &out, NVCVStatus status)
Overloads the stream insertion operator for NVCVStatus.
- Parameters:
out – Output stream to which the status string will be written.
status – NVCVStatus code to be output.
- Returns:
Reference to the modified output stream.
-
template<>
inline int HandleDecRef<NVCVTensorHandle>(NVCVTensorHandle h)
-
template<>
inline int HandleIncRef<NVCVTensorHandle>(NVCVTensorHandle h)
-
template<>
inline int HandleRefCount<NVCVTensorHandle>(NVCVTensorHandle h)
-
template<>
inline int HandleDecRef<NVCVTensorBatchHandle>(NVCVTensorBatchHandle h)
-
template<>
inline int HandleIncRef<NVCVTensorBatchHandle>(NVCVTensorBatchHandle h)
-
template<>
inline int HandleRefCount<NVCVTensorBatchHandle>(NVCVTensorBatchHandle h)
-
constexpr const TensorLayout &GetImplicitTensorLayout(int rank)
Retrieves the default tensor layout based on the rank (number of dimensions).
This function maps commonly used tensor ranks to their typical tensor layouts. For example, a rank of 4 typically corresponds to the NCHW layout (Batch, Channel, Height, Width).
- Parameters:
rank – The rank (number of dimensions) of the tensor.
- Returns:
The corresponding default tensor layout. Returns TENSOR_NONE for unsupported ranks.
-
inline bool operator==(const TensorLayout &a, const TensorLayout &b)
-
inline std::ostream &operator<<(std::ostream &out, const TensorLayout &that)
- Parameters:
out – The output stream.
that – The TensorLayout to output.
- Returns:
The output stream.
-
inline bool operator==(const TensorLayout &lhs, const NVCVTensorLayout &rhs)
-
inline bool operator!=(const TensorLayout &lhs, const NVCVTensorLayout &rhs)
-
inline bool operator<(const TensorLayout &lhs, const NVCVTensorLayout &rhs)
-
inline TensorShape Permute(const TensorShape &src, TensorLayout dstLayout)
Function to permute the dimensions of a tensor to a new layout.
This function rearranges the dimensions of the tensor according to a new layout. It can be used to change the order of dimensions, for example, from NHWC (channel-last) to NCHW (channel-first) and vice versa.
- Parameters:
src – The original tensor shape.
dstLayout – The desired layout after permutation.
- Returns:
The new TensorShape with permuted dimensions according to the desired layout.
Variables
-
constexpr const TensorLayout TENSOR_NONE = {NVCV_TENSOR_NONE}
-
class Allocator : public nvcv::CoreResource<NVCVAllocatorHandle, Allocator>
- #include <Allocator.hpp>
Represents a reference to an allocator object.
The allocator object defines functions for allocating various resources, including different kinds of memory.
A custom allocator can be created via
nvcv::CustomAllocator
helper class.Subclassed by nvcv::CustomAllocator< ResourceAllocators >
-
class Array : public nvcv::CoreResource<NVCVArrayHandle, Array>
- #include <Array.hpp>
-
class ArrayData
- #include <ArrayData.hpp>
Subclassed by nvcv::ArrayDataCuda, nvcv::ArrayDataHost, nvcv::ArrayDataHostPinned
-
class ArrayDataAccess : public nvcv::detail::ArrayDataAccessImpl<ArrayData>
- #include <ArrayDataAccess.hpp>
-
class ArrayDataAccessCuda : public nvcv::detail::ArrayDataAccessImpl<ArrayDataCuda>
- #include <ArrayDataAccess.hpp>
-
class ArrayDataAccessHost : public nvcv::detail::ArrayDataAccessImpl<ArrayDataHost>
- #include <ArrayDataAccess.hpp>
-
class ArrayDataAccessHostPinned : public nvcv::detail::ArrayDataAccessImpl<ArrayDataHostPinned>
- #include <ArrayDataAccess.hpp>
-
template<typename CppFuncType, typename CFuncType = detail::AddContext_t<CppFuncType>, typename TranslateCall = detail::NoTranslation, bool SingleUse = false>
class Callback - #include <Callback.hpp>
-
template<typename Ret, typename ...Args, typename CRet, typename CtxArg, typename ...CArgs, typename TranslateCall, bool SingleUse>
class Callback<Ret(Args...), CRet(CtxArg, CArgs...), TranslateCall, SingleUse> - #include <Callback.hpp>
Manages an object callable with Args and returning Ret
In many ways, this object is similar to std::function, but aimed at providing C interface. The C interface consists of the following triple:
a “call” function with a context prepended to the argument list
a context blob
a context cleanup function
The user may also add extra marshalling step by providing a (stateless) adapter between the C++ and C callbacks. This is useful for avoiding C API leaking to C++ in callback signatures while still allowing to pass them with little state.
In case when the C consumer cannot handle the destruction of a callback, the presence thereof can be detected at run-time.
- Template Parameters:
Ret – The return type of the C++ callback
Args – Argument types of the C++ callback
CtxArg – Type of the context argument in C callback; must be void*, used only to improve diagnostics
CRet – The return type of the C callback (see TranslateCall)
CArgs – Argument types of the C callback (see TranslateCall)
TranslateCall – A type of a stateless functor that translates C arguments to C++, invokes the C++ callback target and translates the return value (or exceptions) to C return value.
SingleUse – If true, the callable object can only be called once and, upon invocation, the callable object wrapped by this Callback will be destroyed.
-
class ColorSpec
- #include <ColorSpec.hpp>
Class for color specification.
This class encapsulates various properties related to color space and encoding.
-
template<typename Handle, typename Actual>
class CoreResource : private nvcv::SharedHandle<Handle> - #include <CoreResource.hpp>
CRTP base for resources based on reference-counting handles
This class adds constructors and assignment with the
Actual
type, so that Actual doesn’t need to tediously reimplement them, but can simply reexpose them withusing
.It also exposes the
handle
with aget
and re-exposesreset
andrelease
functions.- Template Parameters:
Handle – The handle type, e.g. NVCVImageHandle
Actual – The actual class, e.g. Image
-
class CudaMemAllocator : public nvcv::detail::MemAllocatorWithKind<NVCV_RESOURCE_MEM_CUDA>
- #include <Allocator.hpp>
Encapsulates a CUDA memory allocator descriptor
-
template<typename ...ResourceAllocators>
class CustomAllocator : public nvcv::Allocator - #include <Allocator.hpp>
A helper clas for defining custom allocators.
This class aggregates custom resource allocators.
Note
Direct use of this class is recommended only in C++ 17 and newer. For older standards, use CreateCustomAllocator function insted.
- Template Parameters:
ResourceAllocators –
-
template<typename AllocatorType>
class CustomMemAllocator - #include <Allocator.hpp>
Marshals a set of allocation/deallocation functions as NVCVResourceAllocator
A
CustomMemAllocator
is passed as a constructor argument toCustomAllocator
.Note
This class should not be used directly. Use one of the following typedefs:
CustomHostMemAllocator
CustomHostPinnedMemAllocator
CustomCudaMemAllocator
- Template Parameters:
AllocatorType – the type of the allocator (one of: HostMemAllocator, HostPinnedMemAllocator, CudaMemAllocator)
-
class DataType
- #include <DataType.hpp>
-
class Exception : public exception
- #include <Exception.hpp>
Custom exception class to represent errors specific to this application.
This class extends the standard exception class and is designed to encapsulate error codes and messages specific to this application’s context.
-
class HostMemAllocator : public nvcv::detail::MemAllocatorWithKind<NVCV_RESOURCE_MEM_HOST>
- #include <Allocator.hpp>
Encapsulates a host memory allocator descriptor
-
class HostPinnedMemAllocator : public nvcv::detail::MemAllocatorWithKind<NVCV_RESOURCE_MEM_HOST_PINNED>
- #include <Allocator.hpp>
Encapsulates a host pinned memory allocator descriptor
-
class Image : public nvcv::CoreResource<NVCVImageHandle, Image>
- #include <Image.hpp>
Represents an image resource managed by NVCV.
This class wraps the NVCVImageHandle and provides a high-level interface to manage images, including their allocation, deallocation, and querying of various properties like size and format.
-
class ImageBatch : public nvcv::CoreResource<NVCVImageBatchHandle, ImageBatch>
- #include <ImageBatch.hpp>
Represents a batch of images managed by NVCV.
This class wraps the NVCVImageBatchHandle and provides a high-level interface to manage batches of images, including querying of various properties like capacity and number of images.
Subclassed by nvcv::ImageBatchVarShape
-
class ImageBatchData
- #include <ImageBatchData.hpp>
Represents the underlying data of an image batch.
This class provides an interface to access and manipulate the data associated with a batch of images. It also allows casting the data to a derived type.
Subclassed by nvcv::ImageBatchVarShapeData
-
class ImageBatchVarShape : public nvcv::ImageBatch
- #include <ImageBatch.hpp>
Represents a batch of images with variable shapes.
Extends the functionality provided by the
ImageBatch
class to support batches of images where each image might have a different shape or size.
-
class ImageBatchVarShapeData : public nvcv::ImageBatchData
- #include <ImageBatchData.hpp>
Represents the data of a variable shaped image batch.
This class provides an interface to access and manipulate the data associated with a batch of variable shaped images. It extends the base ImageBatchData class.
Subclassed by nvcv::ImageBatchVarShapeDataStrided
-
class ImageBatchVarShapeDataStrided : public nvcv::ImageBatchVarShapeData
- #include <ImageBatchData.hpp>
Represents the strided data of a variable shaped image batch.
This class extends ImageBatchVarShapeData to provide access to strided data.
Subclassed by nvcv::ImageBatchVarShapeDataStridedCuda
-
class ImageBatchVarShapeDataStridedCuda : public nvcv::ImageBatchVarShapeDataStrided
- #include <ImageBatchData.hpp>
Represents the strided data of a variable shaped image batch in CUDA.
This class extends ImageBatchVarShapeDataStrided to provide access to CUDA-specific strided data.
-
class ImageData
- #include <ImageData.hpp>
Represents image data encapsulated in a convenient interface.
This class provides methods to access and manipulate image data. It abstracts the underlying image data representation and provides an interface for higher-level operations.
Subclassed by nvcv::ImageDataCudaArray, nvcv::ImageDataStrided
-
class ImageDataCudaArray : public nvcv::ImageData
- #include <ImageData.hpp>
Represents image data stored in a CUDA array format.
This class extends the ImageData class, providing additional methods and attributes specific to the CUDA array format.
-
class ImageDataStrided : public nvcv::ImageData
- #include <ImageData.hpp>
Represents strided image data.
This class extends the ImageData class, providing additional methods and attributes specific to the strided image format.
Subclassed by nvcv::ImageDataStridedCuda, nvcv::ImageDataStridedHost
-
class ImageDataStridedCuda : public nvcv::ImageDataStrided
- #include <ImageData.hpp>
Represents strided image data specifically for CUDA.
This class extends the ImageDataStrided class, offering methods and functionalities tailored for CUDA.
-
class ImageDataStridedHost : public nvcv::ImageDataStrided
- #include <ImageData.hpp>
Represents strided image data specifically for host.
This class extends the ImageDataStrided class, offering methods and functionalities tailored for the host environment.
-
class ImageFormat
- #include <ImageFormat.hpp>
-
class MemAlignment
- #include <Allocator.hpp>
-
class MemAllocator : public nvcv::ResourceAllocator
- #include <Allocator.hpp>
Encapculates a memory allocator (NVCV_RESOURCE_MEM_*)
Subclassed by nvcv::detail::MemAllocatorWithKind< NVCV_RESOURCE_MEM_CUDA >, nvcv::detail::MemAllocatorWithKind< NVCV_RESOURCE_MEM_HOST >, nvcv::detail::MemAllocatorWithKind< NVCV_RESOURCE_MEM_HOST_PINNED >, nvcv::detail::MemAllocatorWithKind< KIND >
-
template<typename Resource>
class NonOwningResource - #include <CoreResource.hpp>
A non-owning wrapper around a handle which can be trivially converted to a reference-counting wrapper
Motivation: When implementing functions that take handles as arguments, but do not take ownership of the object passed by handle, it’s beneficial to have some way of wrapping the handle into a CoreResource but avoid the calls to incRef/decRef. This class bypasses these calls in construction/destruction. Internally this object store the actual resource and can return a reference to it, so it can be seamlessly used with C++ APIs that operate on the resource class reference. The original resource’s interface is not (fully) reexposed.
Example:
void bar(const Image &img) // takes a reference to the Image shared handle wrapper { doStuff(img); } void foo(NVCVImageHandle handle) { NonOwningResource<Image> img(handle); // no incRef on construction bar(img); // no incRef/decRef when converting to Image } // no decRef on destruction
-
struct NullOptT
- #include <Optional.hpp>
-
template<class T>
class Optional - #include <Optional.hpp>
A container object that may or may not contain a value of a given type.
This is a simplified version of the
std::optional
type introduced in C++17. It provides a mechanism to represent non-value states without resorting to pointers, dynamic allocation, or custom ‘null’ values.- Template Parameters:
T – The type of the value to be stored.
-
struct PackingParams
- #include <DataLayout.hpp>
-
class Requirements
- #include <Requirements.hpp>
-
class ResourceAllocator
- #include <Allocator.hpp>
A base class that encapsulates an NVCVResourceAllocator struct
This class is a convenience wrapper around NVCVResourceAllocator. The derived classes expose additional functionality, specific to the resource type being allocated.
Warning
ResourceAllocator does not own the context object pointed to by cdata().ctx. The destruction of ResourceAllocator does not call the cleanup function.
Subclassed by nvcv::MemAllocator
-
template<class T, int N>
class Shape - #include <Shape.hpp>
Template class representing an N-dimensional shape.
This class is designed to encapsulate the shape of an N-dimensional tensor, where the size in each dimension is of type T.
- Template Parameters:
T – The type of the size in each dimension (e.g., int, size_t).
N – The maximum number of dimensions this shape can represent.
- #include <HandleWrapper.hpp>
A handle wrapper that behaves similarly shared_ptr.
Copying a SharedHandle increments the reference count. Destroying a SharedHandle decrements the reference count. Swap (and, to some, extent, move) are very simple operations on the handle value.
- Template Parameters:
HandleType – The type of the managed handle
HandleOps – The set of handle operations - can be customized e.g. to add extra operation tracking
-
struct Size2D : public NVCVSize2D
- #include <Size.hpp>
-
class Tensor : public nvcv::CoreResource<NVCVTensorHandle, Tensor>
- #include <Tensor.hpp>
Represents a tensor as a core resource in the system.
The Tensor class is built upon the CoreResource utility class, which handles the resource management of the tensor. This class provides various interfaces to access and manage tensor properties such as rank, shape, data type, and layout.
-
class TensorBatch : public nvcv::CoreResource<NVCVTensorBatchHandle, TensorBatch>
- #include <TensorBatch.hpp>
Handle to a tensor batch object.
Tensor batch is a container type that can hold a list of non-uniformly shaped tensors. Rank, data type and layout must be consistent between the tensors.
-
class TensorBatchData
- #include <TensorBatchData.hpp>
General type represenitng data of any tensor batch.
Subclassed by nvcv::TensorBatchDataStrided
-
class TensorBatchDataStrided : public nvcv::TensorBatchData
- #include <TensorBatchData.hpp>
Data of batches of tensors with strides.
Subclassed by nvcv::TensorBatchDataStridedCuda
-
class TensorBatchDataStridedCuda : public nvcv::TensorBatchDataStrided
- #include <TensorBatchData.hpp>
Data of batches of CUDA tensors with strides.
-
class TensorData
- #include <TensorData.hpp>
Represents data for a tensor in the system.
The TensorData class provides an interface to access and manage the underlying data of a tensor. It offers functionalities to retrieve tensor shape, layout, data type, and other properties. The tensor’s data is encapsulated in an
NVCVTensorData
object.Subclassed by nvcv::TensorDataStrided
-
class TensorDataAccessStrided : public nvcv::detail::TensorDataAccessStridedImpl<TensorShapeInfo>
- #include <TensorDataAccess.hpp>
Provides access to tensor data with a strided memory layout.
This class is an interface for accessing tensor data that is stored in a strided memory layout. It provides utilities for checking compatibility and creating instances of the class.
-
class TensorDataAccessStridedImage : public nvcv::detail::TensorDataAccessStridedImageImpl<TensorShapeInfoImage>
- #include <TensorDataAccess.hpp>
Provides access to image tensor data with a strided memory layout.
This class extends
TensorDataAccessStrided
and provides specialized utilities for accessing image tensor data.
-
class TensorDataAccessStridedImagePlanar : public nvcv::detail::TensorDataAccessStridedImagePlanarImpl<TensorShapeInfoImagePlanar>
- #include <TensorDataAccess.hpp>
Provides access to planar image tensor data with a strided memory layout.
This class extends
TensorDataAccessStridedImage
and offers specific utilities for accessing the data in planar image tensors using a strided memory layout.
-
class TensorDataStrided : public nvcv::TensorData
- #include <TensorData.hpp>
Represents strided tensor data in the system.
The
TensorDataStrided
class extendsTensorData
to handle tensor data that is stored in a strided manner. Strided tensor data allows non-contiguous storage in memory, where each dimension can have its own stride and the stride is the amount of bytes to jump each element in that dimension.Subclassed by nvcv::TensorDataStridedCuda
-
class TensorDataStridedCuda : public nvcv::TensorDataStrided
- #include <TensorData.hpp>
Represents strided tensor data specifically for CUDA.
The
TensorDataStridedCuda
class extendsTensorDataStrided
to handle tensor data stored in a strided manner on CUDA devices. It provides methods specific to CUDA strided tensor data.
-
class TensorLayout
- #include <TensorLayout.hpp>
Represents the layout of a tensor.
This class wraps around the NVCVTensorLayout structure and provides additional functionality for handling and manipulating tensor layouts. The class allows for easy construction from character descriptions or from other tensor layout structures. It also supports a range of operations including subsetting and checking for prefixes or suffixes.
-
class TensorLayoutInfo
- #include <TensorLayoutInfo.hpp>
Provides information and utility functions related to tensor layouts.
The TensorLayoutInfo class provides a series of utility functions to inspect and work with tensor layouts. It allows checking the compatibility of a given layout, creating instances from a layout, and querying specific properties of the layout, such as whether it represents a batch or an image.
Subclassed by nvcv::TensorLayoutInfoImage
-
class TensorLayoutInfoImage : public nvcv::TensorLayoutInfo
- #include <TensorLayoutInfo.hpp>
This class provides more information about tensor layout for image tensors.
The class inherits from TensorLayoutInfo and adds functions specific to image tensors. It provides detailed information about the tensor layout such as the number of spatial dimensions, the index of various dimensions (channel, width, height, depth), and whether the layout is row-major. It also provides functions to check whether the channel is in the first or last position.
-
class TensorShape
- #include <TensorShape.hpp>
The TensorShape class represents the shape and layout of a tensor.
-
class TensorShapeInfo : public nvcv::detail::TensorShapeInfoImpl<TensorLayoutInfo>
- #include <TensorShapeInfo.hpp>
This class provides information about the shape of a tensor.
It inherits from TensorShapeInfoImpl and is specialized for the base tensor layout type, providing functions to retrieve the shape, layout, and whether the tensor is batched or corresponds to an image.
-
class TensorShapeInfoImage : public nvcv::detail::TensorShapeInfoImpl<TensorLayoutInfoImage>
- #include <TensorShapeInfo.hpp>
This class provides detailed information about the shape of an image tensor.
It inherits from TensorShapeInfoImpl and is specialized for the image tensor layout type, offering additional functionality tailored to image tensors, such as retrieving the number of channels, rows, columns, and the overall size.
Subclassed by nvcv::TensorShapeInfoImagePlanar
-
class TensorShapeInfoImagePlanar : public nvcv::TensorShapeInfoImage
- #include <TensorShapeInfo.hpp>
This class provides information about the shape of a planar image tensor.
It inherits from TensorShapeInfoImage and is specialized for planar image tensors. The class provides functions to check the compatibility of a given tensor shape and to retrieve the number of planes in the tensor.
-
struct TranslateArrayDataCleanup
- #include <Array.hpp>
-
struct TranslateImageDataCleanup
- #include <Image.hpp>
-
struct TranslateImageToHandle
- #include <ImageBatch.hpp>
-
struct TranslateTensorDataCleanup
- #include <Tensor.hpp>
-
template<typename HandleType, typename HandleOps = detail::UniqueHandleOps<HandleType>>
class UniqueHandle - #include <HandleWrapper.hpp>
A handle wrapper that behaves like a unique_ptr.
- Template Parameters:
HandleType – The type of the managed handle
HandleOps – The set of handle operations - can be customized e.g. to add extra tracking or suppress object deletion.
-
namespace cfg
Functions
-
inline void SetMaxImageCount(int32_t maxCount)
Sets the maximum number of image handles that can be created.
- Parameters:
maxCount – The maximum number of image handles. If negative, dynamic allocation is used and no hard limit is defined.
- Throws:
An – exception is thrown if the nvcvConfigSetMaxImageCount function fails.
-
inline void SetMaxImageBatchCount(int32_t maxCount)
Sets the maximum number of image batch handles that can be created.
- Parameters:
maxCount – The maximum number of image batch handles. If negative, dynamic allocation is used and no hard limit is defined.
- Throws:
An – exception is thrown if the nvcvConfigSetMaxImageBatchCount function fails.
-
inline void SetMaxTensorCount(int32_t maxCount)
Sets the maximum number of tensor handles that can be created.
- Parameters:
maxCount – The maximum number of tensor handles. If negative, dynamic allocation is used and no hard limit is defined.
- Throws:
An – exception is thrown if the nvcvConfigSetMaxTensorCount function fails.
-
inline void SetMaxArrayCount(int32_t maxCount)
Sets the maximum number of array handles that can be created.
- Parameters:
maxCount – The maximum number of array handles. If negative, dynamic allocation is used and no hard limit is defined.
- Throws:
An – exception is thrown if the nvcvConfigSetMaxArrayCount function fails.
-
inline void SetMaxAllocatorCount(int32_t maxCount)
Sets the maximum number of allocator handles that can be created.
- Parameters:
maxCount – The maximum number of allocator handles. If negative, dynamic allocation is used and no hard limit is defined.
- Throws:
An – exception is thrown if the nvcvConfigSetMaxAllocatorCount function fails.
-
inline void SetMaxImageCount(int32_t maxCount)
-
namespace cuda
Typedefs
-
template<typename T, int64_t... Strides>
using TensorBatchWrap = TensorBatchWrapT<T, int64_t, Strides...>
-
template<typename T, int32_t... Strides>
using TensorBatchWrap32 = TensorBatchWrapT<T, int32_t, Strides...>
-
template<typename T, typename StrideType = int64_t>
using TensorBatch1DWrap = TensorBatchWrapT<T, StrideType, sizeof(T)>
-
template<typename T, typename StrideType = int64_t>
using TensorBatch2DWrap = TensorBatchWrapT<T, StrideType, -1, sizeof(T)>
-
template<typename T, typename StrideType = int64_t>
using TensorBatch3DWrap = TensorBatchWrapT<T, StrideType, -1, -1, sizeof(T)>
-
template<typename T, typename StrideType = int64_t>
using TensorBatch4DWrap = TensorBatchWrapT<T, StrideType, -1, -1, -1, sizeof(T)>
-
template<typename T, typename StrideType = int64_t>
using TensorBatch5DWrap = TensorBatchWrapT<T, StrideType, -1, -1, -1, -1, sizeof(T)>
-
template<typename T, int N, typename StrideType = int64_t>
using TensorBatchNDWrap = std::conditional_t<N == 1, TensorBatch1DWrap<T, StrideType>, std::conditional_t<N == 2, TensorBatch2DWrap<T, StrideType>, std::conditional_t<N == 3, TensorBatch3DWrap<T, StrideType>, std::conditional_t<N == 4, TensorBatch4DWrap<T, StrideType>, std::conditional_t<N == 5, TensorBatch5DWrap<T, StrideType>, void>>>>>
-
template<typename T, int64_t... Strides>
using TensorWrap = TensorWrapT<T, int64_t, Strides...>
-
template<typename T, typename StrideType = int64_t>
using Tensor1DWrap = TensorWrapT<T, StrideType, sizeof(T)>
-
template<typename T, typename StrideType = int64_t>
using Tensor2DWrap = TensorWrapT<T, StrideType, -1, sizeof(T)>
-
template<typename T, typename StrideType = int64_t>
using Tensor3DWrap = TensorWrapT<T, StrideType, -1, -1, sizeof(T)>
-
template<typename T, typename StrideType = int64_t>
using Tensor4DWrap = TensorWrapT<T, StrideType, -1, -1, -1, sizeof(T)>
-
template<typename T, typename StrideType = int64_t>
using Tensor5DWrap = TensorWrapT<T, StrideType, -1, -1, -1, -1, sizeof(T)>
-
template<typename T, int N, typename StrideType = int64_t>
using TensorNDWrap = std::conditional_t<N == 1, Tensor1DWrap<T, StrideType>, std::conditional_t<N == 2, Tensor2DWrap<T, StrideType>, std::conditional_t<N == 3, Tensor3DWrap<T, StrideType>, std::conditional_t<N == 4, Tensor4DWrap<T, StrideType>, std::conditional_t<N == 5, Tensor5DWrap<T, StrideType>, void>>>>>
-
template<class T, class = Require<HasTypeTraits<T>>>
using BaseType = typename TypeTraits<T>::base_type Metatype to get the base type of a CUDA compound types.
using DataType = ...; using ChannelType = nvcv::cuda::BaseType<DataType>;
Note
This is identity for regular C types.
- Template Parameters:
T – Type to get the base type from.
-
template<class T, int C, class = Require<HasTypeTraits<T>>>
using MakeType = detail::MakeType_t<T, C> Metatype to make a type from a base type and number of components.
When number of components is zero, it yields the identity (regular C) type, and when it is between 1 and 4 it yields the CUDA compound type.
using RGB8Type = MakeType<unsigned char, 3>; // yields uchar3
Note
Note that T=char might yield uchar1..4 types when char is equal unsigned char, i.e. CHAR_MIN == 0.
- Template Parameters:
T – Base type to make the type from.
C – Number of components to make the type.
-
template<class BT, class T, class = Require<HasTypeTraits<BT, T>>>
using ConvertBaseTypeTo = detail::ConvertBaseTypeTo_t<BT, T> Metatype to convert the base type of a type.
The base type of target type
T
is replaced to beBT
.using DataType = ...; using FloatDataType = ConvertBaseTypeTo<float, DataType>; // yields float1..4
- Template Parameters:
BT – Base type to use in the conversion.
T – Target type to convert its base type.
Enums
Functions
- template<typename T, class OP, class = Require<std::is_floating_point_v<T>>> __device__ void AtomicOp (T *address, T val, OP op)
Metafunction to do a generic atomic operation in floating-point types.
- Template Parameters:
T – Type of the values used in the atomic operation.
OP – Operation class that defines the operator call to be used as atomics.
- Parameters:
address – [inout] First value to be used in the atomic operation.
val – [in] Second value to be used.
op – [in] Operation to be used.
- template<typename T> inline __device__ void AtomicMin (T &a, T b)
Metafunction to do a atomic minimum operation that accepts floating-point types.
- Template Parameters:
T – Type of the values used in the atomic operation.
- Parameters:
a – [inout] First value to be used in the atomic operation.
b – [in] Second value to be used.
- template<typename T> inline __device__ void AtomicMax (T &a, T b)
Metafunction to do a atomic maximum operation that accepts floating-point types.
- Template Parameters:
T – Type of the values used in the atomic operation.
- Parameters:
a – [inout] First value to be used in the atomic operation.
b – [in] Second value to be used.
- template<bool Active = true, typename T> inline constexpr bool __host__ __device__ IsOutside (T c, T s)
Function to check if given coordinate is outside range defined by given size.
- Template Parameters:
Active – Flag to turn this function active.
T – Type of the values given to this function.
- Parameters:
c – [in] Coordinate to check if it is outside the range [0, s).
s – [in] Size that defines the inside range [0, s).
- Returns:
True if given coordinate is outside given size.
- template<NVCVBorderType B, bool Active = true, typename T> inline constexpr T __host__ __device__ GetIndexWithBorder (T c, T s)
Function to get a border-aware index considering the range defined by given size.
Note
This function does not work for NVCV_BORDER_CONSTANT.
- Template Parameters:
B – It is a NVCVBorderType indicating the border to be used.
Active – Flag to turn this function active.
T – Type of the values given to this function.
- Parameters:
c – [in] Coordinate (input index) to put back inside valid range [0, s).
s – [in] Size that defines the valid range [0, s).
-
template<typename T, NVCVBorderType B, typename StrideType = int64_t, class = Require<HasTypeTraits<T>>>
__host__ auto CreateBorderWrapNHW(const TensorDataStridedCuda &tensor, T borderValue = {}) Factory function to create an NHW border wrap given a tensor data.
The output BorderWrap wraps an NHW 3D tensor allowing to access data per batch (N), per row (H) and per column (W) of the input tensor border aware in rows (or height H) and columns (or width W). The input tensor data must have either NHWC or HWC layout, where the channel C is inside the given template type
T
, e.g. T=uchar4 for RGBA8. The active dimensions are H (second) and W (third).See also
- Template Parameters:
T – Type of the values to be accessed in the border wrap.
B – Border extension to be used when accessing H and W, one of NVCVBorderType
StrideType – Type of the strdies used in the underlying TensorWrap.
- Parameters:
tensor – [in] Reference to the tensor that will be wrapped.
borderValue – [in] Border value to be used when accessing outside elements in constant border type
- Returns:
Border wrap useful to access tensor data border aware in H and W in CUDA kernels.
-
template<typename T, NVCVBorderType B, typename StrideType = int64_t, class = Require<HasTypeTraits<T>>>
__host__ auto CreateBorderWrapNHWC(const TensorDataStridedCuda &tensor, T borderValue = {}) Factory function to create an NHWC border wrap given a tensor data.
The output BorderWrap wraps an NHWC 4D tensor allowing to access data per batch (N), per row (H), per column (W) and per channel (C) of the input tensor border aware in rows (or height H) and columns (or width W). The input tensor data must have either NHWC or HWC layout, where the channel C is of type
T
, e.g. T=uchar for each channel of either RGB8 or RGBA8. The active dimensions are H (second) and W (third).See also
- Template Parameters:
T – Type of the values to be accessed in the border wrap.
B – Border extension to be used when accessing H and W, one of NVCVBorderType
StrideType – Type of the strdies used in the underlying TensorWrap.
- Parameters:
tensor – [in] Reference to the tensor that will be wrapped.
borderValue – [in] Border value to be used when accessing outside elements in constant border type
- Returns:
Border wrap useful to access tensor data border aware in H and W in CUDA kernels.
- template<int N, typename T, class = Require<HasEnoughComponents<T, N>>> __host__ __device__ auto DropCast (T v)
Metafunction to drop components of a compound value.
The template parameter
N
defines the number of components to cast the CUDA compound typeT
passed as function argumentv
. This is done by dropping the last components afterN
fromv
. For instance, an uint3 can have its z component dropped by passing it as function argument to DropCast and the number 2 as template argument (see example below). The typeT
is not needed as it is inferred from the argumentv
. It is a requirement of the DropCast function that the typeT
has at least N components.uint2 dstIdx = DropCast<2>(blockIdx * blockDim + threadIdx);
- Template Parameters:
N – Number of components to return.
- Parameters:
v – [in] Value to drop components from.
- Returns:
The compound value with N components dropping the last, extra components.
- template<NVCVInterpolationType I, int Position = 1, typename IndexType = int64_t> inline constexpr IndexType __host__ __device__ GetIndexForInterpolation (float c)
Function to get an integer index from a float coordinate for interpolation purpose.
- Template Parameters:
I – Interpolation type, one of NVCVInterpolationType.
Position – Interpolation position, 1 for the first index and 2 for the second index.
IndexType – Type of the returned value
- Parameters:
c – [in] Coordinate in floating-point to convert to index in integer.
- Returns:
Index in integer suitable for interpolation computation.
- inline void __host__ __device__ GetCubicCoeffs (float delta, float &w0, float &w1, float &w2, float &w3)
-
template<typename T, NVCVBorderType B, NVCVInterpolationType I, typename StrideType = int64_t, class = Require<HasTypeTraits<T>>>
__host__ auto CreateInterpolationWrapNHW(const TensorDataStridedCuda &tensor, T borderValue = {}, float scaleX = {}, float scaleY = {}) Factory function to create an NHW interpolation wrap given a tensor data.
The output InterpolationWrap wraps an NHW 3D tensor allowing to access data per batch (N), per row (H) and per column (W) of the input tensor interpolation-border aware in rows (or height H) and columns (or width W). The input tensor data must have either NHWC or HWC layout, where the channel C is inside the given template type
T
, e.g. T=uchar4 for RGBA8. The active dimensions are H (second) and W (third).See also
- Template Parameters:
T – Type of the values to be accessed in the interpolation wrap.
B – Border extension to be used when accessing H and W, one of NVCVBorderType
I – Interpolation to be used when accessing H and W, one of NVCVInterpolationType
StrideType – Stride type used when accessing underlying tensor data
- Parameters:
tensor – [in] Reference to the tensor that will be wrapped.
borderValue – [in] Border value to be used when accessing outside elements in constant border type
scaleX – [in] Scale X value to be used when interpolation elements with area type
scaleY – [in] Scale Y value to be used when interpolation elements with area type
- Returns:
Interpolation wrap useful to access tensor data interpolation-border aware in H and W in CUDA kernels.
-
template<typename T, NVCVBorderType B, NVCVInterpolationType I, typename StrideType = int64_t, class = Require<HasTypeTraits<T>>>
__host__ auto CreateInterpolationWrapNHWC(const TensorDataStridedCuda &tensor, T borderValue = {}, float scaleX = {}, float scaleY = {}) Factory function to create an NHWC interpolation wrap given a tensor data.
The output InterpolationWrap wraps an NHWC 4D tensor allowing to access data per batch (N), per row (H), per column (W) and per channel (C) of the input tensor interpolation-border aware in rows (or height H) and columns (or width W). The input tensor data must have either NHWC or HWC layout, where the channel C is of type
T
, e.g. T=uchar for each channel of either RGB8 or RGBA8. The active dimensions are H (second) and W (third).See also
- Template Parameters:
T – Type of the values to be accessed in the interpolation wrap.
B – Border extension to be used when accessing H and W, one of NVCVBorderType
I – Interpolation to be used when accessing H and W, one of NVCVInterpolationType
StrideType – Stride type used when accessing underlying tensor data
- Parameters:
tensor – [in] Reference to the tensor that will be wrapped.
borderValue – [in] Border value to be used when accessing outside elements in constant border type
scaleX – [in] Scale X value to be used when interpolation elements with area type
scaleY – [in] Scale Y value to be used when interpolation elements with area type
- Returns:
Interpolation wrap useful to access tensor data interpolation-border aware in H and W in CUDA kernels.
- template<typename T, typename U, class = nvcv::cuda::Require<nvcv::cuda::detail::IsSameCompound<T, U>>> inline __host__ __device__ auto dot (T a, U b)
- template<RoundMode RM, typename T, typename U, class = Require<(!std::is_same_v<T, U>)&&((NumComponents<T> == NumComponents<U>) || (NumComponents<T> == 0 && HasTypeTraits<U>))>> inline __host__ __device__ auto round (U u)
Metafunction to round all elements of the input.
This function rounds all elements of the input and returns the result with the same type as the input. Optionally, the base type of the result may be specified by the template argument type
T
. For instance, a float4 can have its 4 elements rounded into a float4 result, or to a different result type, such as T=int or T=int4, where the result will be int4 with the rounded results (see example below). Also optionally, the round modeRM
can be specified, as one of RoundMode, e.g. RoundMode::DOWN. It is a requirement of round that the input source type has type traits and the optional result typeT
is either a regular C type or has the same number of components as the input type.using FloatType = MakeType<float, 4>; FloatType res = ...; FloatType float_rounded = round(res); ConvertBaseTypeTo<int, FloatType> int_rounded = round<int>(res);
- Template Parameters:
- Parameters:
u – [in] Source value to round all elements with its same type or
T
.- Returns:
The value with all elements rounded.
- template<typename T, typename U, class = Require<(!std::is_same_v<T, U>)&&((NumComponents<T> == NumComponents<U>) || (NumComponents<T> == 0 && HasTypeTraits<U>))>> inline __host__ __device__ auto round (U u)
Overload of round function.
It does specifies target round type
T
and uses default round mode RoundMode::DEFAULT.
- template<RoundMode RM, typename U> inline __host__ __device__ auto round (U u)
Overload of round function.
It does not specify target round type
T
, using input source typeU
instead.
- template<typename U> inline __host__ __device__ auto round (U u)
Overload of round function.
It does not specify target round type
T
, using input source typeU
instead, and uses default round mode RoundMode::DEFAULT.
- template<typename U, class = Require<HasTypeTraits<U>>> inline __host__ __device__ U min (U a, U b)
Metafunction to compute the minimum of two inputs per element.
This function finds the minimum of two inputs per element and returns the result with the same type as the input. For instance, two int4 inputs {1, 2, 3, 4} and {4, 3, 2, 1} yield the minimum {1, 2, 2, 1} as int4 as well (see example below). It is a requirement of min that the input source type has type traits.
using IntType = MakeType<int, 4>; IntType a = {1, 2, 3, 4}, b = {4, 3, 2, 1}; IntType ab_min = min(a, b); // = {1, 2, 2, 1}
- Template Parameters:
U – Type of the two source arguments and the return type.
- Parameters:
u – [in] Input value to compute \( min(x_a, x_b) \) where \( x_a \) ( \( x_b \)) is each element of \( a \) ( \( b \)).
- Returns:
The return value with one minimum per element.
- template<typename U, class = Require<HasTypeTraits<U>>> inline __host__ __device__ U max (U a, U b)
Metafunction to compute the maximum of two inputs per element.
This function finds the maximum of two inputs per element and returns the result with the same type as the input. For instance, two int4 inputs {1, 2, 3, 4} and {4, 3, 2, 1} yield the maximum {4, 3, 3, 4} as int4 as well (see example below). It is a requirement of max that the input source type has type traits.
using IntType = MakeType<int, 4>; IntType a = {1, 2, 3, 4}, b = {4, 3, 2, 1}; IntType ab_max = max(a, b); // = {4, 3, 3, 4}
- Template Parameters:
U – Type of the two source arguments and the return type.
- Parameters:
u – [in] Input value to compute \( max(x_a, x_b) \) where \( x_a \) ( \( x_b \)) is each element of \( a \) ( \( b \)).
- Returns:
The return value with maximums per element.
- template<typename U, typename S, class = Require<(NumComponents<U> == NumComponents<S>) || (HasTypeTraits<U> && NumComponents<S> == 0)>> inline __host__ __device__ U pow (U x, S y)
Metafunction to compute the power of all elements of the input.
This function computes the power of all elements of the input
x
and returns the result with the same type as the input. It is a requirement of pow that the inputx
has the same number of components of the powery
ory
is a scalar (and the type ofx
has type traits).- Template Parameters:
U – Type of the source argument
x
and the return type.S – Type of the source argument
y
power (use a regular C type for scalar).
- Parameters:
x – [in] Input value to compute \( x^y \).
y – [in] Input power to compute \( x^y \).
- Returns:
The return value with all elements as the result of the power.
- template<typename U, class = Require<HasTypeTraits<U>>> inline __host__ __device__ U exp (U u)
Metafunction to compute the natural (base e) exponential of all elements of the input.
This function computes the natural (base e) exponential of all elements of the input and returns the result with the same type as the input. It is a requirement of exp that the input source type has type traits.
- Template Parameters:
U – Type of the source argument and the return type.
- Parameters:
u – [in] Input value to compute \( e^x \) where \( x \) is each element of \( u \).
- Returns:
The return value with all elements as the result of the natural (base e) exponential.
- template<typename U, class = Require<HasTypeTraits<U>>> inline __host__ __device__ U sqrt (U u)
Metafunction to compute the square root of all elements of the input.
This function computes the square root of all elements of the input and returns the result with the same type as the input. It is a requirement of sqrt that the input source type has type traits.
- Template Parameters:
U – Type of the source argument and the return type.
- Parameters:
u – [in] Input value to compute \( \sqrt{x} \) where \( x \) is each element of \( u \).
- Returns:
The return value with all elements as the result of the square root.
- template<typename U, class = Require<HasTypeTraits<U>>> inline __host__ __device__ U abs (U u)
Metafunction to compute the absolute value of all elements of the input.
This function computes the absolute value of all elements of the input and returns the result with the same type as the input. For instance, an int4 input {-1, 2, -3, 4} yields the absolute {1, 2, 3, 4} as int4 as well (see example below). It is a requirement of abs that the input source type has type traits.
using IntType = MakeType<int, 4>; IntType a = {-1, 2, -3, 4}; IntType a_abs = abs(a); // = {1, 2, 3, 4}
- Template Parameters:
U – Type of the source argument and the return type.
- Parameters:
u – [in] Input value to compute \( |x| \) where \( x \) is each element of \( u \).
- Returns:
The return value with the absolute of all elements.
- template<typename U, typename S, class = Require<(NumComponents<U> == NumComponents<S>) || (HasTypeTraits<U> && NumComponents<S> == 0)>> inline __host__ __device__ U clamp (U u, S lo, S hi)
Metafunction to clamp all elements of the input.
This function clamps all elements of the input
u
betweenlo
andhi
and returns the result with the same type as the input. It is a requirement of clamp that the inputu
has the same number of components of the range valueslo
andhi
or both are scalars (and the type ofu
has type traits).- Template Parameters:
U – Type of the source argument
u
and the return type.S – Type of the source argument
lo
andhi
(use a regular C type for scalar).
- Parameters:
u – [in] Input value to clamp.
lo – [in] Input clamp range low value.
hi – [in] Input clamp range high value.
- Returns:
The return value with all elements clamped.
- template<typename T, typename U, class = Require<HasTypeTraits<T, U> && !IsCompound<T>>> __host__ __device__ auto RangeCast (U u)
Metafunction to range cast (scale) all elements to a target range.
This function range casts (that is scales) all elements to the range defined by the template argument type
T
. For instance, a float4 with all elements between 0 and 1 can be casted to an uchar4 with scaling of each element to be in between 0 and 255 (see example below). It is a requirement of RangeCast that both types have type traits and typeT
must be a regular C type. Several examples of possible target range giving a source range, depending on the limits of regular C types, for the RangeCast function are as follows:Source type U
Target type T
Source range
Target range
signed char
float
[-128, 127]
[-1, 1]
float
unsigned char
[0, 1]
[0, 255]
short
unsigned int
[-32768, 32767]
[0, 4294967295]
double
int
[-1, 1]
[-2147483648, 2147483647]
unsigned short
double
[0, 65535]
[0, 1]
using DataType = MakeType<uchar, 4>; using FloatDataType = ConvertBaseTypeTo<float, DataType>; FloatDataType res = ...; // res component values are in [0, 1] DataType pix = RangeCast<BaseType<DataType>>(res); // pix are in [0, 255]
- Template Parameters:
T – Type that defines the target range to cast.
U – Type of the source value (with 1 to 4 elements) passed as argument.
- Parameters:
u – [in] Source value to cast all elements to range of type
T
.- Returns:
The value with all elements scaled.
- template<typename T, typename U, class = Require<(NumComponents<T> == NumComponents<U>) || (NumComponents<T> == 0 && HasTypeTraits<U>)>> __host__ __device__ auto SaturateCast (U u)
Metafunction to saturate cast all elements to a target type.
This function saturate casts (clamping with potential rounding) all elements to the range defined by the template argument type
T
. For instance, a float4 with any values (can be below 0 and above 255) can be casted to an uchar4 rounding-then-saturating each value to be in between 0 and 255 (see example below). It is a requirement of SaturateCast that both types have the same number of components orT
is a regular C type.using DataType = MakeType<uchar, 4>; using FloatDataType = ConvertBaseTypeTo<float, DataType>; FloatDataType res = ...; // res component values are in [0, 1] DataType pix = SaturateCast<DataType>(res); // pix are in [0, 255]
- Template Parameters:
T – Type that defines the target range to cast.
U – Type of the source value (with 1 to 4 elements) passed as argument.
- Parameters:
u – [in] Source value to cast all elements to range of base type of
T
- Returns:
The value with all elements clamped and potentially rounded.
- template<typename T, typename U, class = Require<HasTypeTraits<T, U> && !IsCompound<T>>> __host__ __device__ auto StaticCast (U u)
Metafunction to static cast all values of a compound to a target type.
The template parameter
T
defines the base type (regular C type) to cast all components of the CUDA compound typeU
passed as function argumentu
to the typeT
. The static cast return type has the base typeT
and the number of components as the compound typeU
. For instance, an uint3 can be casted to int3 by passing it as function argument of StaticCast and the type int as template argument (see example below). The typeU
is not needed as it is inferred from the argument \u. It is a requirement of the StaticCast function that the typeT
is of regular C type and the typeU
is of CUDA compound type.int3 idx = StaticCast<int>(blockIdx * blockDim + threadIdx);
- Template Parameters:
T – Type to do static cast on each component of
u
.- Parameters:
u – [in] Compound value to static cast each of its components to target type
T
.- Returns:
The compound value with all components static casted to type
T
.
-
template<typename T, typename StrideType = int64_t, class = Require<HasTypeTraits<T> && IsStrideType<StrideType>>>
__host__ auto CreateTensorWrapNHW(const TensorDataStridedCuda &tensor) Factory function to create an NHW tensor wrap given a tensor data.
The output TensorWrap is an NHW 3D tensor allowing to access data per batch (N), per row (H) and per column (W) of the input tensor. The input tensor data must have either NHWC or HWC layout, where the channel C is inside
T
, e.g. T=uchar3 for RGB8.See also
- Template Parameters:
T – Type of the values to be accessed in the tensor wrap.
StrideType – Type of the stride used in the tensor wrap.
- Parameters:
tensor – [in] Reference to the tensor that will be wrapped.
- Returns:
Tensor wrap useful to access tensor data in CUDA kernels.
-
template<typename T, typename StrideType = int64_t, class = Require<HasTypeTraits<T> && IsStrideType<StrideType>>>
__host__ auto CreateTensorWrapNHWC(const TensorDataStridedCuda &tensor) Factory function to create an NHWC tensor wrap given a tensor data.
The output TensorWrap is an NHWC 4D tensor allowing to access data per batch (N), per row (H), per column (W) and per channel (C) of the input tensor. The input tensor data must have either NHWC or HWC layout, where the channel C is of type
T
, e.g. T=uchar for each channel of either RGB8 or RGBA8.See also
- Template Parameters:
T – Type of the values to be accessed in the tensor wrap.
StrideType – Type of the stride used in the tensor wrap.
- Parameters:
tensor – [in] Reference to the tensor that will be wrapped.
- Returns:
Tensor wrap useful to access tensor data in CUDA kernels.
-
template<typename T, typename StrideType = int64_t, class = Require<HasTypeTraits<T> && IsStrideType<StrideType>>>
__host__ auto CreateTensorWrapNCHW(const TensorDataStridedCuda &tensor) Factory function to create an NCHW tensor wrap given a tensor data.
The output TensorWrap is an NCHW 4D tensor allowing to access data per batch (N), per channel (C), per row (H), and per column (W) of the input tensor. The input tensor data must have either NCHW or CHW layout, where the channel C is of type
T
, e.g. T=uchar for each channel of either RGB8 or RGBA8.See also
- Template Parameters:
T – Type of the values to be accessed in the tensor wrap.
- Parameters:
tensor – [in] Reference to the tensor that will be wrapped.
- Returns:
Tensor wrap useful to access tensor data in CUDA kernels.
- template<typename T, typename RT = detail::CopyConstness_t<T, std::conditional_t<IsCompound<T>, BaseType<T>, T>>, class = Require<HasTypeTraits<T>>> __host__ __device__ RT & GetElement (T &v, int eidx)
Metafunction to get an element by reference from a given value reference.
The value may be of CUDA compound type with 1 to 4 elements, where the corresponding element index is 0 to 3, and the return is a reference to the element with the base type of the compound type, copying the constness (that is the return reference is constant if the input value is constant). The value may be a regular C type, in which case the element index is ignored and the identity is returned. It is a requirement of the GetElement function that the type
T
has type traits.using PixelRGB8Type = MakeType<unsigned char, 3>; PixelRGB8Type pix = ...; auto green = GetElement(pix, 1); // yields unsigned char
- Template Parameters:
T – Type of the value to get the element from.
- Parameters:
v – [in] Value of type T to get an element from.
eidx – [in] Element index in [0, 3] inside the compound value to get the reference from. This element index is ignored in case the value is not of a CUDA compound type.
- Returns:
The reference of the value’s element.
- template<int EIDX, typename T, typename RT = detail::CopyConstness_t<T, std::conditional_t<IsCompound<T>, BaseType<T>, T>>, class = Require<HasTypeTraits<T>>> __host__ __device__ RT & GetElement (T &v)
- template<typename T, class = Require<HasTypeTraits<T>>> __host__ __device__ T SetAll (BaseType< T > x)
Metafunction to set all elements to the same value.
Set all elements to the value
x
passed as argument. For instance, an int3 can have all its elements set to zero by calling SetAll and passing int3 as template argument and zero as argument (see example below). Another way to set all elements to a value is by using the type of the argument as base type and passing the number of channels of the return type (see example below).auto idx = SetAll<int3>(0); // sets to zero all elements of an int3 index idx: {0, 0, 0} unsigned char ch = 127; auto pix = SetAll<4>(ch); // sets all elements of an uchar3 pixel pix: {127, 127, 127, 127}
- Template Parameters:
T – Type to be returned with all elements set to the given value
x
.N – Number of components as a second option instead of passing the type
T
.
- Parameters:
x – [in] Value to set all elements to.
- Returns:
The object of type T with all elements set to
x
.
- template<int N, typename BT, typename RT = MakeType<BT, N>, class = Require<HasTypeTraits<BT>>> __host__ __device__ RT SetAll (BT x)
- template<class T, class = Require<HasTypeTraits<T>>> const __host__ char * GetTypeName ()
Metafunction to get the name of a type.
Unfortunately typeid().name() in C/C++ typeinfo yields different names depending on the platform. This function returns the name of the type resembling the CUDA compound type, that may be useful for debug printing.
std::cout << GetTypeName<DataType>();
- Template Parameters:
T – Type to get the name from.
- Returns:
String with the name of the type.
Variables
-
template<typename ...Ts>
constexpr bool HasTypeTraits = (detail::HasTypeTraits_t<Ts>::value && ...)
-
template<class T, class = Require<HasTypeTraits<T>>>
constexpr bool IsCompound = TypeTraits<T>::components >= 1
-
template<typename T, int N, class = Require<HasTypeTraits<T>>>
constexpr bool HasEnoughComponents = N <= TypeTraits<T>::components
-
template<typename T>
constexpr bool IsStrideType = std::is_same_v<T, int32_t> || std::is_same_v<T, int64_t>
-
template<typename T, typename StrideType>
constexpr bool IsIndexType = std::is_integral_v<T> && (TypeTraits<T>::max <= TypeTraits<StrideType>::max)
-
template<class T, class = Require<HasTypeTraits<T>>>
constexpr int NumComponents = TypeTraits<T>::components Metavariable to get the number of components of a type.
using DataType = ...; int nc = nvcv::cuda::NumComponents<DataType>;
Note
This is zero for regular C types.
- Template Parameters:
T – Type to get the number of components from.
-
template<class T, class = Require<HasTypeTraits<T>>>
constexpr int NumElements = TypeTraits<T>::elements Metavariable to get the number of elements of a type.
using DataType = ...; for (int e = 0; e < nvcv::cuda::NumElements<DataType>; ++e) // ...
Note
This is one for regular C types and one to four for CUDA compound types.
- Template Parameters:
T – Type to get the number of elements from.
-
template<typename ValueType>
class ArrayWrap - #include <ArrayWrap.hpp>
-
template<typename T, NVCVBorderType B>
class BorderVarShapeWrap : public nvcv::cuda::detail::BorderIWImpl<T, B> - #include <BorderVarShapeWrap.hpp>
Border var-shape wrapper class used to wrap an ImageBatchVarShapeWrap adding border handling to it.
This class wraps an ImageBatchVarShapeWrap to add border handling functionality. It provides the methods
ptr
andoperator
[] to do the same semantic access (pointer or reference) in the wrapped ImageBatchVarShapeWrap but border aware on width and height as active dimensions.using PixelType = ...; using ImageBatchWrap = ImageBatchVarShapeWrap<PixelType>; using BorderVarShape = BorderVarShapeWrap<PixelType, NVCV_BORDER_REPLICATE>; ImageBatchWrap dst(...); ImageBatchWrap srcImageBatch(...); BorderVarShape src(srcImageBatch); dim3 grid{...}, block{...}; int2 fillBorderSize{2, 2}; FillBorder<<<grid, block>>>(dst, src, src.numImages(), fillBorderSize); template<typename T, NVCVBorderType B> __global__ void FillBorder(ImageBatchVarShapeWrap<T> dst, BorderVarShapeWrap<T, B> src, int ns, int2 bs) { int3 dstCoord = StaticCast<int>(blockIdx * blockDim + threadIdx); if (dstCoord.x >= dst.width(dstCoord.z) || dstCoord.y >= dst.height(dstCoord.z) || dstCoord.z >= ns) return; int3 srcCoord = {dstCoord.x - bs.x, dstCoord.y - bs.y, dstCoord.z}; dst[dstCoord] = src[srcCoord]; }
- Template Parameters:
T – Type (it can be const) of each element inside the image batch var-shape wrapper.
B – It is a NVCVBorderType indicating the border to be used.
-
template<typename T>
class BorderVarShapeWrap<T, NVCV_BORDER_CONSTANT> : public nvcv::cuda::detail::BorderIWImpl<T, NVCV_BORDER_CONSTANT> - #include <BorderVarShapeWrap.hpp>
Border var-shape wrapper class specialized for NVCV_BORDER_CONSTANT.
- Template Parameters:
T – Type (it can be const) of each element inside the image batch var-shape wrapper.
-
template<typename T, NVCVBorderType B>
class BorderVarShapeWrapNHWC : public nvcv::cuda::detail::BorderIWImpl<T, B> - #include <BorderVarShapeWrap.hpp>
-
template<typename T>
class BorderVarShapeWrapNHWC<T, NVCV_BORDER_CONSTANT> : public nvcv::cuda::detail::BorderIWImpl<T, NVCV_BORDER_CONSTANT> - #include <BorderVarShapeWrap.hpp>
Border var-shape wrapper class specialized for NVCV_BORDER_CONSTANT.
- Template Parameters:
T – Type (it can be const) of each element inside the image batch var-shape wrapper.
-
template<class TW, NVCVBorderType B, bool... ActiveDimensions>
class BorderWrap : public nvcv::cuda::detail::BorderWrapImpl<TW, B, ActiveDimensions...> - #include <BorderWrap.hpp>
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.
-
template<class TW, bool... ActiveDimensions>
class BorderWrap<TW, NVCV_BORDER_CONSTANT, ActiveDimensions...> : public nvcv::cuda::detail::BorderWrapImpl<TW, NVCV_BORDER_CONSTANT, ActiveDimensions...> - #include <BorderWrap.hpp>
Border wrapper class specialized for NVCV_BORDER_CONSTANT.
- Template Parameters:
TW – It is a TensorWrap class with any dimension and type.
ActiveDimensions – Flags to inform active (true) or inactive (false) dimensions.
-
template<typename T, int N>
class FullTensorWrap - #include <FullTensorWrap.hpp>
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.
-
template<typename T>
class ImageBatchVarShapeWrap - #include <ImageBatchVarShapeWrap.hpp>
Image batch var-shape wrapper class to wrap ImageBatchVarShapeDataStridedCuda.
ImageBatchVarShapeWrap is a wrapper of an image batch (or a list of images) of variable shapes. The template parameter
T
is the type of each element inside the wrapper, and it can be compound type to represent a pixel type, e.g. uchar4 for RGBA images.cudaStream_t stream; cudaStreamCreate(&stream); nvcv::ImageBatchVarShape imageBatch(samples); auto *imageBatchData = imageBatch.exportData<nvcv::ImageBatchVarShapeDataStridedCuda>(stream) nvcv::cuda::ImageBatchVarShapeWrap<uchar4> wrap(*imageBatchData); // Now wrap can be used in device code to access elements of the image batch via operator[] or ptr method.
Image batch var-shape wrapper class to wrap ImageBatchVarShapeDataStridedCuda.
This class is specialized for non-constant value type.
- Template Parameters:
T – Type (it can be const) of each element inside the image batch var-shape wrapper.
T – Type (non-const) of each element inside the image batch var-shape wrapper.
Subclassed by nvcv::cuda::ImageBatchVarShapeWrapNHWC< T >
-
template<typename T>
class ImageBatchVarShapeWrapNHWC : private nvcv::cuda::ImageBatchVarShapeWrap<T> - #include <ImageBatchVarShapeWrap.hpp>
Image batch var-shape wrapper NHWC class to wrap ImageBatchVarShapeDataStridedCuda and number of channels.
This class handles number of channels as a separate run-time parameter instead of built-in
T
. It considers interleaved channels, where they appear in a packed sequence at the last dimension (thus NHWC). It also considers each image in the batch has a single plane.Note
The class ImageBatchVarShapeWrap can be used with its template parameter
T
type as a compound type, where its number of elements yield the number of channels.- Template Parameters:
T – Type (it can be const) of each element inside this wrapper.
-
template<typename T, NVCVBorderType B, NVCVInterpolationType I>
class InterpolationVarShapeWrap : public nvcv::cuda::detail::InterpolationVarShapeWrapImpl<T, B, I> - #include <InterpolationVarShapeWrap.hpp>
Interpolation var-shape wrapper class used to wrap a BorderVarShapeWrap adding interpolation handling to it.
This class wraps a BorderVarShapeWrap to add interpolation handling functionality. It provides the operator[] to do the same semantic value access in the wrapped BorderVarShapeWrap but interpolation aware.
See also
NVCV_CPP_CUDATOOLS_INTERPOLATIONVARSHAPEWRAPS
Note
Each interpolation wrap class below is specialized for one interpolation type.
- Template Parameters:
T – Type (it can be const) of each element inside the border var-shape wrapper.
I – It is a NVCVInterpolationType defining the interpolation type to be used.
-
template<typename T, NVCVBorderType B>
class InterpolationVarShapeWrap<T, B, NVCV_INTERP_AREA> : public nvcv::cuda::detail::InterpolationVarShapeWrapImpl<T, B, NVCV_INTERP_AREA> - #include <InterpolationVarShapeWrap.hpp>
Interpolation var-shape wrapper class specialized for NVCV_INTERP_AREA.
- Template Parameters:
T – Type (it can be const) of each element inside the border var-shape wrapper.
-
template<typename T, NVCVBorderType B>
class InterpolationVarShapeWrap<T, B, NVCV_INTERP_CUBIC> : public nvcv::cuda::detail::InterpolationVarShapeWrapImpl<T, B, NVCV_INTERP_CUBIC> - #include <InterpolationVarShapeWrap.hpp>
Interpolation var-shape wrapper class specialized for NVCV_INTERP_CUBIC.
- Template Parameters:
T – Type (it can be const) of each element inside the border var-shape wrapper.
-
template<typename T, NVCVBorderType B>
class InterpolationVarShapeWrap<T, B, NVCV_INTERP_LINEAR> : public nvcv::cuda::detail::InterpolationVarShapeWrapImpl<T, B, NVCV_INTERP_LINEAR> - #include <InterpolationVarShapeWrap.hpp>
Interpolation var-shape wrapper class specialized for NVCV_INTERP_LINEAR.
- Template Parameters:
T – Type (it can be const) of each element inside the border var-shape wrapper.
-
template<typename T, NVCVBorderType B>
class InterpolationVarShapeWrap<T, B, NVCV_INTERP_NEAREST> : public nvcv::cuda::detail::InterpolationVarShapeWrapImpl<T, B, NVCV_INTERP_NEAREST> - #include <InterpolationVarShapeWrap.hpp>
Interpolation var-shape wrapper class specialized for NVCV_INTERP_NEAREST.
- Template Parameters:
T – Type (it can be const) of each element inside the border var-shape wrapper.
-
template<class BW, NVCVInterpolationType I>
class InterpolationWrap : public nvcv::cuda::detail::InterpolationWrapImpl<BW, I> - #include <InterpolationWrap.hpp>
Interpolation wrapper class used to wrap a BorderWrap adding interpolation handling to it.
This class wraps a BorderWrap to add interpolation handling functionality. It provides the operator[] to do the same semantic value access in the wrapped BorderWrap but interpolation aware.
using DataType = ...; using TensorWrap2D = TensorWrap<-1, -1, DataType>; using BorderWrap2D = BorderWrap<TensorWrap2D, NVCV_BORDER_REFLECT, true, true>; using InterpWrap2D = InterpolationWrap<BorderWrap2D, NVCV_INTERP_CUBIC>; TensorWrap2D tensorWrap(...); BorderWrap2D borderWrap(...); InterpWrap2D interpolationAwareTensor(borderWrap); // Now use interpolationAwareTensor instead of borderWrap or tensorWrap to access in-between elements with // on-the-fly interpolation, in this example grid-unaligned pixels use bi-cubic interpolation, grid-aligned // pixels that fall outside the tensor use reflect border extension and inside is the tensor value itself
See also
NVCV_CPP_CUDATOOLS_INTERPOLATIONWRAPS
Note
Each interpolation wrap class below is specialized for one interpolation type.
- Template Parameters:
BW – It is a BorderWrap class with any dimension and type.
I – It is a NVCVInterpolationType defining the interpolation type to be used.
-
template<class BW>
class InterpolationWrap<BW, NVCV_INTERP_AREA> : public nvcv::cuda::detail::InterpolationWrapImpl<BW, NVCV_INTERP_AREA> - #include <InterpolationWrap.hpp>
Interpolation wrapper class specialized for NVCV_INTERP_AREA.
- Template Parameters:
BW – It is a BorderWrap class with any dimension and type.
-
template<class BW>
class InterpolationWrap<BW, NVCV_INTERP_CUBIC> : public nvcv::cuda::detail::InterpolationWrapImpl<BW, NVCV_INTERP_CUBIC> - #include <InterpolationWrap.hpp>
Interpolation wrapper class specialized for NVCV_INTERP_CUBIC.
- Template Parameters:
BW – It is a BorderWrap class with any dimension and type.
-
template<class BW>
class InterpolationWrap<BW, NVCV_INTERP_LINEAR> : public nvcv::cuda::detail::InterpolationWrapImpl<BW, NVCV_INTERP_LINEAR> - #include <InterpolationWrap.hpp>
Interpolation wrapper class specialized for NVCV_INTERP_LINEAR.
- Template Parameters:
BW – It is a BorderWrap class with any dimension and type.
-
template<class BW>
class InterpolationWrap<BW, NVCV_INTERP_NEAREST> : public nvcv::cuda::detail::InterpolationWrapImpl<BW, NVCV_INTERP_NEAREST> - #include <InterpolationWrap.hpp>
Interpolation wrapper class specialized for NVCV_INTERP_NEAREST.
- Template Parameters:
BW – It is a BorderWrap class with any dimension and type.
-
template<typename T, typename StrideT, StrideT... Strides>
class TensorBatchWrapT - #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 theStrides
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.
See also
- 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, typename StrideT, StrideT... Strides>
class TensorBatchWrapT<const T, StrideT, Strides...> - #include <TensorBatchWrap.hpp>
-
template<typename T, typename StrideT, StrideT... Strides>
class TensorWrapT - #include <TensorWrap.hpp>
TensorWrap class is a non-owning wrap of a N-D tensor used for easy access of its elements in CUDA device.
TensorWrap is a wrapper of a multi-dimensional tensor 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 theStrides
template parameter.Template arguments:
T type of the values inside the tensor
StrideT type of the stride used in the byte offset calculation
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 an NHWC 4D tensor where each sample image in N has a run-time image pitch (first -1 in template argument), and 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 TensorWrap = TensorWrap<ChannelType, -1, -1, sizeof(DataType), sizeof(ChannelType)>; std::byte *imageData = ...; int imgStride = ...; int rowStride = ...; TensorWrap tensorWrap(imageData, imgStride, rowStride); // 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.
Tensor wrapper class specialized for non-constant value type.
See also
- 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 wrapper.
Strides – Each compile-time (use -1 for run-time) pitch in bytes from first to last dimension.
-
template<typename T, typename StrideT, StrideT... Strides>
class TensorWrapT<const T, StrideT, Strides...> - #include <TensorWrap.hpp>
-
namespace detail
Typedefs
-
template<typename T, NVCVBorderType B>
using BorderVarShapeWrapImpl = BorderIWImpl<ImageBatchVarShapeWrap<T>, B>
-
template<typename T, NVCVBorderType B>
using BorderVarShapeWrapNHWCImpl = BorderIWImpl<ImageBatchVarShapeWrapNHWC<T>, B>
-
template<class FROM, class TO>
using CopyConstness_t = typename CopyConstness<FROM, TO>::type
-
template<class BT, class T>
using ConvertBaseTypeTo_t = typename ConvertBaseTypeTo<BT, T>::type
Functions
- template<typename U> inline __host__ U RoundEvenImpl (U u)
- template<typename T, typename U, int RM = FE_TONEAREST> inline __host__ __device__ T RoundImpl (U u)
- template<typename U> inline __host__ __device__ U MinImpl (U a, U b)
- template<typename U> inline __host__ __device__ U MaxImpl (U a, U b)
- template<typename U, typename S> inline __host__ __device__ U PowImpl (U x, S y)
- template<typename U> inline __host__ __device__ U ExpImpl (U u)
- template<typename U> inline __host__ __device__ U SqrtImpl (U u)
- template<typename U> inline __host__ __device__ U AbsImpl (U u)
- template<typename U, typename S> inline __host__ __device__ U ClampImpl (U u, S lo, S hi)
- template<typename T, typename U> inline __host__ __device__ T RangeCastImpl (U u)
- template<typename T, typename U> inline __host__ __device__ T BaseSaturateCastImpl (U u)
- template<typename T, typename U> inline __host__ __device__ T SaturateCastImpl (U u)
- template<> __host__ __device__ __forceinline__ unsigned char SaturateCastImpl< unsigned char, signed char > (signed char u)
- template<> __host__ __device__ __forceinline__ unsigned char SaturateCastImpl< unsigned char, short > (short u)
- template<> __host__ __device__ __forceinline__ unsigned char SaturateCastImpl< unsigned char, unsigned short > (unsigned short u)
- template<> __host__ __device__ __forceinline__ unsigned char SaturateCastImpl< unsigned char, int > (int u)
- template<> __host__ __device__ __forceinline__ unsigned char SaturateCastImpl< unsigned char, unsigned int > (unsigned int u)
- template<> __host__ __device__ __forceinline__ unsigned char SaturateCastImpl< unsigned char, float > (float u)
- template<> __host__ __device__ __forceinline__ unsigned char SaturateCastImpl< unsigned char, double > (double u)
- template<> __host__ __device__ __forceinline__ signed char SaturateCastImpl< signed char, unsigned char > (unsigned char u)
- template<> __host__ __device__ __forceinline__ signed char SaturateCastImpl< signed char, short > (short u)
- template<> __host__ __device__ __forceinline__ signed char SaturateCastImpl< signed char, unsigned short > (unsigned short u)
- template<> __host__ __device__ __forceinline__ signed char SaturateCastImpl< signed char, int > (int u)
- template<> __host__ __device__ __forceinline__ signed char SaturateCastImpl< signed char, unsigned int > (unsigned int u)
- template<> __host__ __device__ __forceinline__ signed char SaturateCastImpl< signed char, float > (float u)
- template<> __host__ __device__ __forceinline__ signed char SaturateCastImpl< signed char, double > (double u)
- template<> __host__ __device__ __forceinline__ unsigned short SaturateCastImpl< unsigned short, signed char > (signed char u)
- template<> __host__ __device__ __forceinline__ unsigned short SaturateCastImpl< unsigned short, short > (short u)
- template<> __host__ __device__ __forceinline__ unsigned short SaturateCastImpl< unsigned short, int > (int u)
- template<> __host__ __device__ __forceinline__ unsigned short SaturateCastImpl< unsigned short, unsigned int > (unsigned int u)
- template<> __host__ __device__ __forceinline__ unsigned short SaturateCastImpl< unsigned short, float > (float u)
- template<> __host__ __device__ __forceinline__ unsigned short SaturateCastImpl< unsigned short, double > (double u)
- template<> __host__ __device__ __forceinline__ short SaturateCastImpl< short, unsigned short > (unsigned short u)
- template<> __host__ __device__ __forceinline__ short SaturateCastImpl< short, int > (int u)
- template<> __host__ __device__ __forceinline__ short SaturateCastImpl< short, unsigned int > (unsigned int u)
- template<> __host__ __device__ __forceinline__ short SaturateCastImpl< short, float > (float u)
- template<> __host__ __device__ __forceinline__ short SaturateCastImpl< short, double > (double u)
- template<> __host__ __device__ __forceinline__ int SaturateCastImpl< int, unsigned int > (unsigned int u)
- template<> __host__ __device__ __forceinline__ int SaturateCastImpl< int, float > (float u)
- template<> __host__ __device__ __forceinline__ int SaturateCastImpl< int, double > (double u)
- template<> __host__ __device__ __forceinline__ unsigned int SaturateCastImpl< unsigned int, signed char > (signed char u)
- template<> __host__ __device__ __forceinline__ unsigned int SaturateCastImpl< unsigned int, short > (short u)
- template<> __host__ __device__ __forceinline__ unsigned int SaturateCastImpl< unsigned int, int > (int u)
- template<> __host__ __device__ __forceinline__ unsigned int SaturateCastImpl< unsigned int, float > (float u)
- template<> __host__ __device__ __forceinline__ unsigned int SaturateCastImpl< unsigned int, double > (double u)
- template<typename T, typename U, typename RT, RoundMode RM> inline __host__ __device__ RT RoundImpl (U u)
Variables
-
template<class T, class U, class = Require<HasTypeTraits<T, U>>>
constexpr bool IsSameCompound = IsCompound<T> && TypeTraits<T>::components == TypeTraits<U>::components
-
template<typename T, typename U, class = Require<HasTypeTraits<T, U>>>
constexpr bool OneIsCompound = (TypeTraits<T>::components == 0 && TypeTraits<U>::components >= 1) || (TypeTraits<T>::components >= 1 && TypeTraits<U>::components == 0) || IsSameCompound<T, U>
-
template<typename T, class = Require<HasTypeTraits<T>>>
constexpr bool IsIntegral = std::is_integral_v<typename TypeTraits<T>::base_type>
-
template<typename T, typename U, class = Require<HasTypeTraits<T, U>>>
constexpr bool OneIsCompoundAndBothAreIntegral = OneIsCompound<T, U> && IsIntegral<T> && IsIntegral<U>
-
template<typename T, class = Require<HasTypeTraits<T>>>
constexpr bool IsIntegralCompound = IsIntegral<T> && IsCompound<T>
-
template<class IW, NVCVBorderType B>
class BorderIWImpl - #include <BorderVarShapeWrap.hpp>
Subclassed by nvcv::cuda::BorderVarShapeWrap< T, B >, nvcv::cuda::BorderVarShapeWrap< T, NVCV_BORDER_CONSTANT >, nvcv::cuda::BorderVarShapeWrapNHWC< T, B >, nvcv::cuda::BorderVarShapeWrapNHWC< T, NVCV_BORDER_CONSTANT >
-
template<class TW, NVCVBorderType B, bool... ActiveDimensions>
class BorderWrapImpl - #include <BorderWrap.hpp>
-
template<class BT, class T>
struct ConvertBaseTypeTo - #include <Metaprogramming.hpp>
-
template<class BT, class T>
struct ConvertBaseTypeTo<BT, volatile const T> - #include <Metaprogramming.hpp>
-
template<class FROM, class TO>
struct CopyConstness - #include <Metaprogramming.hpp>
-
template<typename T, typename = void>
struct HasTypeTraits_t : public false_type - #include <Metaprogramming.hpp>
- template<typename T> base_type > > : public true_type
- #include <Metaprogramming.hpp>
-
template<typename T, NVCVBorderType B, NVCVInterpolationType I>
class InterpolationVarShapeWrapImpl - #include <InterpolationVarShapeWrap.hpp>
Subclassed by nvcv::cuda::InterpolationVarShapeWrap< T, B, I >
-
template<class BW, NVCVInterpolationType I>
class InterpolationWrapImpl - #include <InterpolationWrap.hpp>
Subclassed by nvcv::cuda::InterpolationWrap< BW, I >
-
template<class T, int C>
struct MakeType - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<char, 0> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<char, 1> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<char, 2> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<char, 3> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<char, 4> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<double, 0> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<double, 1> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<double, 2> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<double, 3> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<double, 4> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<float, 0> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<float, 1> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<float, 2> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<float, 3> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<float, 4> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<int, 0> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<int, 1> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<int, 2> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<int, 3> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<int, 4> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<long long, 0> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<long long, 1> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<long long, 2> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<long long, 3> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<long long, 4> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<long, 0> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<long, 1> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<long, 2> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<long, 3> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<long, 4> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<short, 0> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<short, 1> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<short, 2> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<short, 3> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<short, 4> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<signed char, 0> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<signed char, 1> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<signed char, 2> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<signed char, 3> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<signed char, 4> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned char, 0> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned char, 1> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned char, 2> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned char, 3> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned char, 4> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned int, 0> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned int, 1> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned int, 2> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned int, 3> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned int, 4> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned long long, 0> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned long long, 1> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned long long, 2> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned long long, 3> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned long long, 4> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned long, 0> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned long, 1> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned long, 2> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned long, 3> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned long, 4> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned short, 0> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned short, 1> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned short, 2> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned short, 3> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned short, 4> - #include <Metaprogramming.hpp>
-
template<class T>
struct TypeTraits - #include <Metaprogramming.hpp>
Subclassed by nvcv::cuda::detail::TypeTraits< const T >, nvcv::cuda::detail::TypeTraits< const volatile T >, nvcv::cuda::detail::TypeTraits< volatile T >
-
template<>
struct TypeTraits<char> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<char1> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<char2> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<char3> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<char4> - #include <Metaprogramming.hpp>
-
template<class T>
struct TypeTraits<const T> : public nvcv::cuda::detail::TypeTraits<T> - #include <Metaprogramming.hpp>
-
template<class T>
struct TypeTraits<volatile const T> : public nvcv::cuda::detail::TypeTraits<T> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<dim3> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<double> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<double1> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<double2> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<double3> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<double4> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<float> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<float1> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<float2> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<float3> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<float4> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<int> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<int1> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<int2> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<int3> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<int4> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<long> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<long long> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<long1> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<long2> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<long3> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<long4> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<longlong1> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<longlong2> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<longlong3> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<longlong4> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<short> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<short1> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<short2> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<short3> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<short4> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<signed char> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<uchar1> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<uchar2> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<uchar3> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<uchar4> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<uint1> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<uint2> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<uint3> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<uint4> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<ulong1> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<ulong2> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<ulong3> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<ulong4> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<ulonglong1> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<ulonglong2> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<ulonglong3> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<ulonglong4> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<unsigned char> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<unsigned int> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<unsigned long> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<unsigned long long> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<unsigned short> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<ushort1> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<ushort2> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<ushort3> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<ushort4> - #include <Metaprogramming.hpp>
-
template<typename T, NVCVBorderType B>
-
namespace math
Functions
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > & operator+= (Vector< T, N > &lhs, const Vector< T, N > &rhs)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator+ (const Vector< T, N > &a, const Vector< T, N > &b)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > & operator+= (Vector< T, N > &lhs, T rhs)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator+ (const Vector< T, N > &a, T b)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator+ (T a, const Vector< T, N > &b)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > & operator-= (Vector< T, N > &lhs, const Vector< T, N > &rhs)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator- (const Vector< T, N > &a, const Vector< T, N > &b)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > & operator-= (Vector< T, N > &lhs, T rhs)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator- (const Vector< T, N > &a, T b)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator- (T a, const Vector< T, N > &b)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > & operator*= (Vector< T, N > &lhs, const T &rhs)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator* (const Vector< T, N > &a, const T &b)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator* (const T &a, const Vector< T, N > &b)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > & operator*= (Vector< T, N > &lhs, const Vector< T, N > &rhs)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator* (const Vector< T, N > &a, const Vector< T, N > &b)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > & operator/= (Vector< T, N > &lhs, const T &rhs)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator/ (const Vector< T, N > &a, const T &b)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator/ (T a, const Vector< T, N > &b)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > & operator/= (Vector< T, N > &lhs, const Vector< T, N > &rhs)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator/ (const Vector< T, N > &a, const Vector< T, N > &b)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator- (const Vector< T, N > &v)
- template<class T, int N> constexpr __host__ __device__ bool operator== (const Vector< T, N > &a, const Vector< T, N > &b)
- template<class T, int N> constexpr __host__ __device__ bool operator== (const T &a, const Vector< T, N > &b)
- template<class T, int N> constexpr __host__ __device__ bool operator== (const Vector< T, N > &a, const T &b)
- template<class T, int N> constexpr __host__ __device__ bool operator< (const Vector< T, N > &a, const Vector< T, N > &b)
- template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > operator* (const Matrix< T, M, N > &m, T val)
-
template<class T, int M, int N>
std::ostream &operator<<(std::ostream &out, const Matrix<T, M, N> &m)
- template<class T, int M, int N, int P> constexpr __host__ __device__ Matrix< T, M, P > operator* (const Matrix< T, M, N > &a, const Matrix< T, N, P > &b)
- template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > & operator*= (Matrix< T, M, N > &lhs, T rhs)
- template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > operator* (T val, const Matrix< T, M, N > &m)
- template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > & operator+= (Matrix< T, M, N > &lhs, const Matrix< T, M, N > &rhs)
- template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > operator+ (const Matrix< T, M, N > &lhs, const Matrix< T, M, N > &rhs)
- template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > & operator-= (Matrix< T, M, N > &lhs, const Matrix< T, M, N > &rhs)
- template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > operator- (const Matrix< T, M, N > &a, const Matrix< T, M, N > &b)
- template<class T, int M, int N> constexpr __host__ __device__ Vector< T, N > operator* (const Vector< T, M > &v, const Matrix< T, M, N > &m)
- template<class T, int M, int N> constexpr __host__ __device__ Vector< T, M > operator* (const Matrix< T, M, N > &m, const Vector< T, N > &v)
- template<class T, int M, int N, class = cuda::Require<(M == N && N > 1)>> constexpr __host__ __device__ Matrix< T, M, N > operator* (const Matrix< T, M, 1 > &m, const Vector< T, N > &v)
- template<class T, int M, int N> constexpr __host__ __device__ Vector< T, N > & operator*= (Vector< T, M > &v, const Matrix< T, M, M > &m)
- template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > & operator*= (Matrix< T, M, N > &lhs, const Matrix< T, N, N > &rhs)
- template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > operator- (const Matrix< T, M, N > &m)
- template<class T, int M, int N> constexpr __host__ __device__ bool operator== (const Matrix< T, M, N > &a, const Matrix< T, M, N > &b)
- template<class T, int M, int N> constexpr __host__ __device__ bool operator== (const T &a, const Matrix< T, M, N > &b)
- template<class T, int M, int N> constexpr __host__ __device__ bool operator== (const Matrix< T, M, N > &a, const T &b)
- template<class T, int M, int N> constexpr __host__ __device__ bool operator< (const Matrix< T, M, N > &a, const Matrix< T, M, N > &b)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > zeros ()
- template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > zeros ()
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > ones ()
- template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > ones ()
- template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > identity ()
- template<class T, int M> constexpr __host__ __device__ Matrix< T, M, M > vander (const Vector< T, M > &v)
- template<class T, int R> constexpr __host__ __device__ Matrix< T, R, R > compan (const Vector< T, R > &a)
- template<class T, int M> constexpr __host__ __device__ Matrix< T, M, M > diag (const Vector< T, M > &v)
- template<class T, int N> constexpr __host__ __device__ T dot (const Vector< T, N > &a, const Vector< T, N > &b)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > reverse (const Vector< T, N > &a)
- template<class T, int M> constexpr __host__ __device__ Matrix< T, M, M > & transp_inplace (Matrix< T, M, M > &m)
- template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, N, M > transp (const Matrix< T, M, N > &m)
- template<class T, int N> constexpr __host__ __device__ Matrix< T, N, 1 > transp (const Vector< T, N > &v)
- template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > flip_rows (const Matrix< T, M, N > &m)
- template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > flip_cols (const Matrix< T, M, N > &m)
- template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > flip (const Matrix< T, M, N > &m)
-
template<class T, int M, int N = M>
class Matrix - #include <LinAlg.hpp>
Matrix class to represent small matrices.
It uses the Vector class to stores each row, storing elements in row-major order, i.e. it has M row vectors where each vector has N elements.
- Template Parameters:
T – Matrix value type.
M – Number of rows.
N – Number of columns. Default is M (a square matrix).
-
template<class T, int N>
class Vector - #include <LinAlg.hpp>
Vector class to represent small vectors.
- Template Parameters:
T – Vector value type.
N – Number of elements.
-
namespace detail
Functions
- template<class T> constexpr __host__ __device__ void swap (T &a, T &b)
-
template<typename T, int64_t... Strides>
-
namespace detail
Typedefs
-
template<typename Func>
using AddContext_t = typename AddContext<Func>::type
-
template<class IT>
using IsRandomAccessIterator = typename std::enable_if<std::is_same<typename std::iterator_traits<IT>::iterator_category, std::random_access_iterator_tag>::value>::type
-
template<std::size_t N>
using MakeIndexSequence = typename MakeIndexSequenceImpl<N>::type
-
template<bool Cond, typename If, typename Else>
using Conditional_t = typename std::conditional<Cond, If, Else>::type
-
template<typename T>
using RemoveCVRef_t = RemoveCV_t<RemoveRef_t<T>>
Functions
-
template<typename T>
constexpr T AlignDown(T value, T alignment_pow2) Aligns the
value
down to a multiple ofalignment_pow2
.The function operates by masking the least significant bits of the value. If the alignment is not a power of two, the behavior is undefined.
Remark
Negative values are aligned down, not towards zero.
- Template Parameters:
T – an integral type
- Parameters:
value – a value to align
alignment_pow2 – the alignment, must be a positive power of 2
- Returns:
constexpr T the value aligned down to a multiple of
alignment_pow2
-
template<typename T>
constexpr T AlignUp(T value, T alignment_pow2) Aligns the
value
up to a multiple ofalignment_pow2
.The function operates by adding alignment-1 to the value and masking the least significant bits. If the alignment is not a power of two, the behavior is undefined.
Remark
Negative values are aligned up, that is, towards zero.
- Template Parameters:
T – an integral type
- Parameters:
value – a value to align
alignment_pow2 – the alignment, must be a positive power of 2
- Returns:
constexpr T the value aligned up to a multiple of
alignment_pow2
-
template<typename T>
constexpr bool IsAligned(T value, T alignment_pow2) Checks if the value is a multiple of alignment.
- Template Parameters:
T – an integral type
- Parameters:
value – the value whose alignment is checked
alignment_pow2 – the alignment, must be a power of 2
- Returns:
true if value is a multiple of alignment_pow2
- Returns:
false otherwise
-
inline bool IsAligned(const void *ptr, uintptr_t alignment_pow2)
Checks if a pointer is aligned to a multiple of
alignment_pow2
bytes.- Parameters:
ptr – the pointer whose alignment is checked
alignment_pow2 – the alignment, must be a power of 2
- Returns:
true if value is a multiple of alignment_pow2
- Returns:
false otherwise
-
template<class IFACE, class H>
void SetObjectAssociation(NVCVStatus (*setUserPointer)(H, void*), IFACE *obj, H handle)
-
template<class IFACE, class H>
IFACE *CastImpl(NVCVStatus (*getUserPointer)(H, void**), NVCVStatus (*setUserPointer)(H, void*), H handle)
-
inline void ThrowException(NVCVStatus status)
-
inline void CheckThrow(NVCVStatus status)
-
inline NVCVImageHandle GetImageHandleForPushBack(NVCVImageHandle imgHandle)
- template<typename R, typename... Args, typename F> std::is_convertible< decltype(std::declval< F >)(std::declval< Args >)...)), R > IsInvocableRF (F *)
-
template<typename R, typename ...Args>
std::false_type IsInvocableRF(...)
-
template<typename ...Args, typename F, typename = decltype(std::declval<F>()(std::declval<Args>()...))>
std::true_type IsInvocableF(F*)
-
template<typename ...Args>
std::false_type IsInvocableF(...)
-
std::false_type IsStdFunctionF(...)
-
std::false_type IsRefWrapperF(...)
-
template<typename Func>
struct AddContext - #include <Callback.hpp>
-
template<typename ArrayDataType, typename = typename std::enable_if<std::is_base_of<ArrayData, ArrayDataType>::value>::type>
class ArrayDataAccessImpl - #include <ArrayDataAccess.hpp>
-
template<class T, int ID = 0>
class BaseFromMember - #include <BaseFromMember.hpp>
-
template<typename...>
struct Conjunction : public true_type - #include <TypeTraits.hpp>
-
template<typename T, typename ...Ts>
struct Conjunction<T, Ts...> : public nvcv::detail::ConjunctionImpl<T::value, Ts...> - #include <TypeTraits.hpp>
-
template<bool, typename...>
struct ConjunctionImpl - #include <TypeTraits.hpp>
-
template<typename ...Ts>
struct ConjunctionImpl<false, Ts...> : public false_type - #include <TypeTraits.hpp>
-
template<typename ...Ts>
struct ConjunctionImpl<true, Ts...> : public nvcv::detail::Conjunction<Ts...> - #include <TypeTraits.hpp>
-
template<typename...>
struct Disjunction : public false_type - #include <TypeTraits.hpp>
-
template<typename T, typename ...Ts>
struct Disjunction<T, Ts...> : public nvcv::detail::DisjunctionImpl<T::value, Ts...> - #include <TypeTraits.hpp>
-
template<bool, typename...>
struct DisjunctionImpl - #include <TypeTraits.hpp>
-
template<typename ...Ts>
struct DisjunctionImpl<false, Ts...> : public nvcv::detail::Disjunction<Ts...> - #include <TypeTraits.hpp>
-
template<typename ...Ts>
struct DisjunctionImpl<true, Ts...> : public true_type - #include <TypeTraits.hpp>
-
template<class T>
struct DynamicCast - #include <CastsImpl.hpp>
-
template<std::size_t... II>
struct IndexSequence - #include <IndexSequence.hpp>
-
struct InPlaceT
- #include <InPlace.hpp>
-
template<typename TypeExpression>
struct invoke_result : public std::result_of<TypeExpression> - #include <ArrayDataAccess.hpp>
-
template<typename X>
struct IsCallback : public false_type - #include <Callback.hpp>
-
template<typename Cpp, typename C, typename Tr, bool SingleUse>
struct IsCallback<Callback<Cpp, C, Tr, SingleUse>> : public true_type - #include <Callback.hpp>
-
template<typename Callable, typename ...Args>
struct IsInvocable : public decltypeIsInvocableFAddPointer_t<Callable> - #include <TypeTraits.hpp>
-
template<typename R, typename Callable, typename ...Args>
struct IsInvocableR : public decltypeIsInvocableRFAddPointer_t<Callable> - #include <TypeTraits.hpp>
-
template<typename X>
struct IsRefWrapper : public decltypeIsRefWrapperFstd::declval<X*> - #include <TypeTraits.hpp>
-
template<typename X>
struct IsStdFunction : public decltypeIsStdFunctionFstd::declval<X*> - #include <TypeTraits.hpp>
-
template<std::size_t N, std::size_t... II>
struct MakeIndexSequenceImpl - #include <IndexSequence.hpp>
-
template<NVCVResourceType KIND>
class MemAllocatorWithKind : public nvcv::MemAllocator - #include <Allocator.hpp>
Provides a common implementation for different memory allocator wrappers
-
struct NoTranslation
- #include <Callback.hpp>
- #include <HandleWrapper.hpp>
-
template<class T>
struct StaticCast - #include <CastsImpl.hpp>
-
template<typename ShapeInfo>
class TensorDataAccessStridedImageImpl : public nvcv::detail::TensorDataAccessStridedImpl<ShapeInfo> - #include <TensorDataAccess.hpp>
Provides specialized access methods for strided tensor data representing images.
This class is an extension of TensorDataAccessStridedImpl and offers specific utilities for accessing the data in image tensors using a strided memory layout. It provides methods to retrieve the number of columns, rows, channels, and other image-specific properties. Furthermore, it provides utility methods to compute strides and access specific rows, channels, etc.
- Template Parameters:
ShapeInfo – The type that contains shape information for the image tensor.
Subclassed by nvcv::detail::TensorDataAccessStridedImagePlanarImpl< ShapeInfo >
-
template<typename ShapeInfo>
class TensorDataAccessStridedImagePlanarImpl : public nvcv::detail::TensorDataAccessStridedImageImpl<ShapeInfo> - #include <TensorDataAccess.hpp>
Provides specialized access methods for strided tensor data representing planar images.
This class is an extension of
TensorDataAccessStridedImageImpl
and offers specific utilities for accessing the data in planar image tensors using a strided memory layout. It provides methods to retrieve the number of planes, compute the stride for the plane dimension, and access specific planes of the image tensor.- Template Parameters:
ShapeInfo – The type that contains shape information for the planar image tensor.
-
template<typename ShapeInfo, typename LayoutInfo = typename ShapeInfo::LayoutInfo>
class TensorDataAccessStridedImpl - #include <TensorDataAccess.hpp>
Provides access to strided tensor data, allowing for more efficient memory access patterns.
This class offers utilities for accessing the data in a tensor using a strided memory layout. It provides functions to retrieve the number of samples, data type, layout, and shape of the tensor. It also contains utilities for computing strides and accessing specific samples.
- Template Parameters:
ShapeInfo – The type that contains shape information for the tensor.
LayoutInfo – The type that contains layout information for the tensor. By default, it is derived from ShapeInfo.
-
template<typename LAYOUT_INFO>
class TensorShapeInfoImpl - #include <TensorShapeInfo.hpp>
This class provides detailed information about the shape of a tensor.
The class is templated on the layout information type, which allows it to be adapted to various tensor layout schemes. It provides functions to retrieve the shape, layout, and additional metadata about the tensor.
- Template Parameters:
LAYOUT_INFO – The type that contains layout information for the tensor.
-
template<typename HandleType>
struct UniqueHandleOps - #include <HandleWrapper.hpp>
-
template<typename Func>
-
using CustomHostMemAllocator = CustomMemAllocator<HostMemAllocator>
-
namespace cuda
Typedefs
-
template<typename T, int64_t... Strides>
using TensorBatchWrap = TensorBatchWrapT<T, int64_t, Strides...>
-
template<typename T, int32_t... Strides>
using TensorBatchWrap32 = TensorBatchWrapT<T, int32_t, Strides...>
-
template<typename T, typename StrideType = int64_t>
using TensorBatch1DWrap = TensorBatchWrapT<T, StrideType, sizeof(T)>
-
template<typename T, typename StrideType = int64_t>
using TensorBatch2DWrap = TensorBatchWrapT<T, StrideType, -1, sizeof(T)>
-
template<typename T, typename StrideType = int64_t>
using TensorBatch3DWrap = TensorBatchWrapT<T, StrideType, -1, -1, sizeof(T)>
-
template<typename T, typename StrideType = int64_t>
using TensorBatch4DWrap = TensorBatchWrapT<T, StrideType, -1, -1, -1, sizeof(T)>
-
template<typename T, typename StrideType = int64_t>
using TensorBatch5DWrap = TensorBatchWrapT<T, StrideType, -1, -1, -1, -1, sizeof(T)>
-
template<typename T, int N, typename StrideType = int64_t>
using TensorBatchNDWrap = std::conditional_t<N == 1, TensorBatch1DWrap<T, StrideType>, std::conditional_t<N == 2, TensorBatch2DWrap<T, StrideType>, std::conditional_t<N == 3, TensorBatch3DWrap<T, StrideType>, std::conditional_t<N == 4, TensorBatch4DWrap<T, StrideType>, std::conditional_t<N == 5, TensorBatch5DWrap<T, StrideType>, void>>>>>
-
template<typename T, int64_t... Strides>
using TensorWrap = TensorWrapT<T, int64_t, Strides...>
-
template<typename T, int32_t... Strides>
using TensorWrap32 = TensorWrapT<T, int32_t, Strides...>
-
template<typename T, typename StrideType = int64_t>
using Tensor1DWrap = TensorWrapT<T, StrideType, sizeof(T)>
-
template<typename T, typename StrideType = int64_t>
using Tensor2DWrap = TensorWrapT<T, StrideType, -1, sizeof(T)>
-
template<typename T, typename StrideType = int64_t>
using Tensor3DWrap = TensorWrapT<T, StrideType, -1, -1, sizeof(T)>
-
template<typename T, typename StrideType = int64_t>
using Tensor4DWrap = TensorWrapT<T, StrideType, -1, -1, -1, sizeof(T)>
-
template<typename T, typename StrideType = int64_t>
using Tensor5DWrap = TensorWrapT<T, StrideType, -1, -1, -1, -1, sizeof(T)>
-
template<typename T, int N, typename StrideType = int64_t>
using TensorNDWrap = std::conditional_t<N == 1, Tensor1DWrap<T, StrideType>, std::conditional_t<N == 2, Tensor2DWrap<T, StrideType>, std::conditional_t<N == 3, Tensor3DWrap<T, StrideType>, std::conditional_t<N == 4, Tensor4DWrap<T, StrideType>, std::conditional_t<N == 5, Tensor5DWrap<T, StrideType>, void>>>>>
-
template<bool B>
using Require = std::enable_if_t<B>
-
template<class T, class = Require<HasTypeTraits<T>>>
using BaseType = typename TypeTraits<T>::base_type Metatype to get the base type of a CUDA compound types.
using DataType = ...; using ChannelType = nvcv::cuda::BaseType<DataType>;
Note
This is identity for regular C types.
- Template Parameters:
T – Type to get the base type from.
-
template<class T, int C, class = Require<HasTypeTraits<T>>>
using MakeType = detail::MakeType_t<T, C> Metatype to make a type from a base type and number of components.
When number of components is zero, it yields the identity (regular C) type, and when it is between 1 and 4 it yields the CUDA compound type.
using RGB8Type = MakeType<unsigned char, 3>; // yields uchar3
Note
Note that T=char might yield uchar1..4 types when char is equal unsigned char, i.e. CHAR_MIN == 0.
- Template Parameters:
T – Base type to make the type from.
C – Number of components to make the type.
-
template<class BT, class T, class = Require<HasTypeTraits<BT, T>>>
using ConvertBaseTypeTo = detail::ConvertBaseTypeTo_t<BT, T> Metatype to convert the base type of a type.
The base type of target type
T
is replaced to beBT
.using DataType = ...; using FloatDataType = ConvertBaseTypeTo<float, DataType>; // yields float1..4
- Template Parameters:
BT – Base type to use in the conversion.
T – Target type to convert its base type.
Enums
-
enum class RoundMode : int
Values:
-
enumerator NEAREST
-
enumerator DOWN
-
enumerator UP
-
enumerator ZERO
-
enumerator DEFAULT
-
enumerator NEAREST
Functions
- template<typename T, class OP, class = Require<std::is_floating_point_v<T>>> __device__ void AtomicOp (T *address, T val, OP op)
Metafunction to do a generic atomic operation in floating-point types.
- Template Parameters:
T – Type of the values used in the atomic operation.
OP – Operation class that defines the operator call to be used as atomics.
- Parameters:
address – [inout] First value to be used in the atomic operation.
val – [in] Second value to be used.
op – [in] Operation to be used.
- template<typename T> inline __device__ void AtomicMin (T &a, T b)
Metafunction to do a atomic minimum operation that accepts floating-point types.
- Template Parameters:
T – Type of the values used in the atomic operation.
- Parameters:
a – [inout] First value to be used in the atomic operation.
b – [in] Second value to be used.
- template<typename T> inline __device__ void AtomicMax (T &a, T b)
Metafunction to do a atomic maximum operation that accepts floating-point types.
- Template Parameters:
T – Type of the values used in the atomic operation.
- Parameters:
a – [inout] First value to be used in the atomic operation.
b – [in] Second value to be used.
- template<bool Active = true, typename T> inline constexpr bool __host__ __device__ IsOutside (T c, T s)
Function to check if given coordinate is outside range defined by given size.
- Template Parameters:
Active – Flag to turn this function active.
T – Type of the values given to this function.
- Parameters:
c – [in] Coordinate to check if it is outside the range [0, s).
s – [in] Size that defines the inside range [0, s).
- Returns:
True if given coordinate is outside given size.
- template<NVCVBorderType B, bool Active = true, typename T> inline constexpr T __host__ __device__ GetIndexWithBorder (T c, T s)
Function to get a border-aware index considering the range defined by given size.
Note
This function does not work for NVCV_BORDER_CONSTANT.
- Template Parameters:
B – It is a NVCVBorderType indicating the border to be used.
Active – Flag to turn this function active.
T – Type of the values given to this function.
- Parameters:
c – [in] Coordinate (input index) to put back inside valid range [0, s).
s – [in] Size that defines the valid range [0, s).
-
template<typename T, NVCVBorderType B, typename StrideType = int64_t, class = Require<HasTypeTraits<T>>>
__host__ auto CreateBorderWrapNHW(const TensorDataStridedCuda &tensor, T borderValue = {}) Factory function to create an NHW border wrap given a tensor data.
The output BorderWrap wraps an NHW 3D tensor allowing to access data per batch (N), per row (H) and per column (W) of the input tensor border aware in rows (or height H) and columns (or width W). The input tensor data must have either NHWC or HWC layout, where the channel C is inside the given template type
T
, e.g. T=uchar4 for RGBA8. The active dimensions are H (second) and W (third).See also
- Template Parameters:
T – Type of the values to be accessed in the border wrap.
B – Border extension to be used when accessing H and W, one of NVCVBorderType
StrideType – Type of the strdies used in the underlying TensorWrap.
- Parameters:
tensor – [in] Reference to the tensor that will be wrapped.
borderValue – [in] Border value to be used when accessing outside elements in constant border type
- Returns:
Border wrap useful to access tensor data border aware in H and W in CUDA kernels.
-
template<typename T, NVCVBorderType B, typename StrideType = int64_t, class = Require<HasTypeTraits<T>>>
__host__ auto CreateBorderWrapNHWC(const TensorDataStridedCuda &tensor, T borderValue = {}) Factory function to create an NHWC border wrap given a tensor data.
The output BorderWrap wraps an NHWC 4D tensor allowing to access data per batch (N), per row (H), per column (W) and per channel (C) of the input tensor border aware in rows (or height H) and columns (or width W). The input tensor data must have either NHWC or HWC layout, where the channel C is of type
T
, e.g. T=uchar for each channel of either RGB8 or RGBA8. The active dimensions are H (second) and W (third).See also
- Template Parameters:
T – Type of the values to be accessed in the border wrap.
B – Border extension to be used when accessing H and W, one of NVCVBorderType
StrideType – Type of the strdies used in the underlying TensorWrap.
- Parameters:
tensor – [in] Reference to the tensor that will be wrapped.
borderValue – [in] Border value to be used when accessing outside elements in constant border type
- Returns:
Border wrap useful to access tensor data border aware in H and W in CUDA kernels.
- template<int N, typename T, class = Require<HasEnoughComponents<T, N>>> __host__ __device__ auto DropCast (T v)
Metafunction to drop components of a compound value.
The template parameter
N
defines the number of components to cast the CUDA compound typeT
passed as function argumentv
. This is done by dropping the last components afterN
fromv
. For instance, an uint3 can have its z component dropped by passing it as function argument to DropCast and the number 2 as template argument (see example below). The typeT
is not needed as it is inferred from the argumentv
. It is a requirement of the DropCast function that the typeT
has at least N components.uint2 dstIdx = DropCast<2>(blockIdx * blockDim + threadIdx);
- Template Parameters:
N – Number of components to return.
- Parameters:
v – [in] Value to drop components from.
- Returns:
The compound value with N components dropping the last, extra components.
- template<NVCVInterpolationType I, int Position = 1, typename IndexType = int64_t> inline constexpr IndexType __host__ __device__ GetIndexForInterpolation (float c)
Function to get an integer index from a float coordinate for interpolation purpose.
- Template Parameters:
I – Interpolation type, one of NVCVInterpolationType.
Position – Interpolation position, 1 for the first index and 2 for the second index.
IndexType – Type of the returned value
- Parameters:
c – [in] Coordinate in floating-point to convert to index in integer.
- Returns:
Index in integer suitable for interpolation computation.
- inline void __host__ __device__ GetCubicCoeffs (float delta, float &w0, float &w1, float &w2, float &w3)
-
template<typename T, NVCVBorderType B, NVCVInterpolationType I, typename StrideType = int64_t, class = Require<HasTypeTraits<T>>>
__host__ auto CreateInterpolationWrapNHW(const TensorDataStridedCuda &tensor, T borderValue = {}, float scaleX = {}, float scaleY = {}) Factory function to create an NHW interpolation wrap given a tensor data.
The output InterpolationWrap wraps an NHW 3D tensor allowing to access data per batch (N), per row (H) and per column (W) of the input tensor interpolation-border aware in rows (or height H) and columns (or width W). The input tensor data must have either NHWC or HWC layout, where the channel C is inside the given template type
T
, e.g. T=uchar4 for RGBA8. The active dimensions are H (second) and W (third).See also
- Template Parameters:
T – Type of the values to be accessed in the interpolation wrap.
B – Border extension to be used when accessing H and W, one of NVCVBorderType
I – Interpolation to be used when accessing H and W, one of NVCVInterpolationType
StrideType – Stride type used when accessing underlying tensor data
- Parameters:
tensor – [in] Reference to the tensor that will be wrapped.
borderValue – [in] Border value to be used when accessing outside elements in constant border type
scaleX – [in] Scale X value to be used when interpolation elements with area type
scaleY – [in] Scale Y value to be used when interpolation elements with area type
- Returns:
Interpolation wrap useful to access tensor data interpolation-border aware in H and W in CUDA kernels.
-
template<typename T, NVCVBorderType B, NVCVInterpolationType I, typename StrideType = int64_t, class = Require<HasTypeTraits<T>>>
__host__ auto CreateInterpolationWrapNHWC(const TensorDataStridedCuda &tensor, T borderValue = {}, float scaleX = {}, float scaleY = {}) Factory function to create an NHWC interpolation wrap given a tensor data.
The output InterpolationWrap wraps an NHWC 4D tensor allowing to access data per batch (N), per row (H), per column (W) and per channel (C) of the input tensor interpolation-border aware in rows (or height H) and columns (or width W). The input tensor data must have either NHWC or HWC layout, where the channel C is of type
T
, e.g. T=uchar for each channel of either RGB8 or RGBA8. The active dimensions are H (second) and W (third).See also
- Template Parameters:
T – Type of the values to be accessed in the interpolation wrap.
B – Border extension to be used when accessing H and W, one of NVCVBorderType
I – Interpolation to be used when accessing H and W, one of NVCVInterpolationType
StrideType – Stride type used when accessing underlying tensor data
- Parameters:
tensor – [in] Reference to the tensor that will be wrapped.
borderValue – [in] Border value to be used when accessing outside elements in constant border type
scaleX – [in] Scale X value to be used when interpolation elements with area type
scaleY – [in] Scale Y value to be used when interpolation elements with area type
- Returns:
Interpolation wrap useful to access tensor data interpolation-border aware in H and W in CUDA kernels.
- template<typename T, typename U, class = nvcv::cuda::Require<nvcv::cuda::detail::IsSameCompound<T, U>>> inline __host__ __device__ auto dot (T a, U b)
- template<RoundMode RM, typename T, typename U, class = Require<(!std::is_same_v<T, U>)&&((NumComponents<T> == NumComponents<U>) || (NumComponents<T> == 0 && HasTypeTraits<U>))>> inline __host__ __device__ auto round (U u)
Metafunction to round all elements of the input.
This function rounds all elements of the input and returns the result with the same type as the input. Optionally, the base type of the result may be specified by the template argument type
T
. For instance, a float4 can have its 4 elements rounded into a float4 result, or to a different result type, such as T=int or T=int4, where the result will be int4 with the rounded results (see example below). Also optionally, the round modeRM
can be specified, as one of RoundMode, e.g. RoundMode::DOWN. It is a requirement of round that the input source type has type traits and the optional result typeT
is either a regular C type or has the same number of components as the input type.using FloatType = MakeType<float, 4>; FloatType res = ...; FloatType float_rounded = round(res); ConvertBaseTypeTo<int, FloatType> int_rounded = round<int>(res);
- Template Parameters:
- Parameters:
u – [in] Source value to round all elements with its same type or
T
.- Returns:
The value with all elements rounded.
- template<typename T, typename U, class = Require<(!std::is_same_v<T, U>)&&((NumComponents<T> == NumComponents<U>) || (NumComponents<T> == 0 && HasTypeTraits<U>))>> inline __host__ __device__ auto round (U u)
Overload of round function.
It does specifies target round type
T
and uses default round mode RoundMode::DEFAULT.
- template<RoundMode RM, typename U> inline __host__ __device__ auto round (U u)
Overload of round function.
It does not specify target round type
T
, using input source typeU
instead.
- template<typename U> inline __host__ __device__ auto round (U u)
Overload of round function.
It does not specify target round type
T
, using input source typeU
instead, and uses default round mode RoundMode::DEFAULT.
- template<typename U, class = Require<HasTypeTraits<U>>> inline __host__ __device__ U min (U a, U b)
Metafunction to compute the minimum of two inputs per element.
This function finds the minimum of two inputs per element and returns the result with the same type as the input. For instance, two int4 inputs {1, 2, 3, 4} and {4, 3, 2, 1} yield the minimum {1, 2, 2, 1} as int4 as well (see example below). It is a requirement of min that the input source type has type traits.
using IntType = MakeType<int, 4>; IntType a = {1, 2, 3, 4}, b = {4, 3, 2, 1}; IntType ab_min = min(a, b); // = {1, 2, 2, 1}
- Template Parameters:
U – Type of the two source arguments and the return type.
- Parameters:
u – [in] Input value to compute \( min(x_a, x_b) \) where \( x_a \) ( \( x_b \)) is each element of \( a \) ( \( b \)).
- Returns:
The return value with one minimum per element.
- template<typename U, class = Require<HasTypeTraits<U>>> inline __host__ __device__ U max (U a, U b)
Metafunction to compute the maximum of two inputs per element.
This function finds the maximum of two inputs per element and returns the result with the same type as the input. For instance, two int4 inputs {1, 2, 3, 4} and {4, 3, 2, 1} yield the maximum {4, 3, 3, 4} as int4 as well (see example below). It is a requirement of max that the input source type has type traits.
using IntType = MakeType<int, 4>; IntType a = {1, 2, 3, 4}, b = {4, 3, 2, 1}; IntType ab_max = max(a, b); // = {4, 3, 3, 4}
- Template Parameters:
U – Type of the two source arguments and the return type.
- Parameters:
u – [in] Input value to compute \( max(x_a, x_b) \) where \( x_a \) ( \( x_b \)) is each element of \( a \) ( \( b \)).
- Returns:
The return value with maximums per element.
- template<typename U, typename S, class = Require<(NumComponents<U> == NumComponents<S>) || (HasTypeTraits<U> && NumComponents<S> == 0)>> inline __host__ __device__ U pow (U x, S y)
Metafunction to compute the power of all elements of the input.
This function computes the power of all elements of the input
x
and returns the result with the same type as the input. It is a requirement of pow that the inputx
has the same number of components of the powery
ory
is a scalar (and the type ofx
has type traits).- Template Parameters:
U – Type of the source argument
x
and the return type.S – Type of the source argument
y
power (use a regular C type for scalar).
- Parameters:
x – [in] Input value to compute \( x^y \).
y – [in] Input power to compute \( x^y \).
- Returns:
The return value with all elements as the result of the power.
- template<typename U, class = Require<HasTypeTraits<U>>> inline __host__ __device__ U exp (U u)
Metafunction to compute the natural (base e) exponential of all elements of the input.
This function computes the natural (base e) exponential of all elements of the input and returns the result with the same type as the input. It is a requirement of exp that the input source type has type traits.
- Template Parameters:
U – Type of the source argument and the return type.
- Parameters:
u – [in] Input value to compute \( e^x \) where \( x \) is each element of \( u \).
- Returns:
The return value with all elements as the result of the natural (base e) exponential.
- template<typename U, class = Require<HasTypeTraits<U>>> inline __host__ __device__ U sqrt (U u)
Metafunction to compute the square root of all elements of the input.
This function computes the square root of all elements of the input and returns the result with the same type as the input. It is a requirement of sqrt that the input source type has type traits.
- Template Parameters:
U – Type of the source argument and the return type.
- Parameters:
u – [in] Input value to compute \( \sqrt{x} \) where \( x \) is each element of \( u \).
- Returns:
The return value with all elements as the result of the square root.
- template<typename U, class = Require<HasTypeTraits<U>>> inline __host__ __device__ U abs (U u)
Metafunction to compute the absolute value of all elements of the input.
This function computes the absolute value of all elements of the input and returns the result with the same type as the input. For instance, an int4 input {-1, 2, -3, 4} yields the absolute {1, 2, 3, 4} as int4 as well (see example below). It is a requirement of abs that the input source type has type traits.
using IntType = MakeType<int, 4>; IntType a = {-1, 2, -3, 4}; IntType a_abs = abs(a); // = {1, 2, 3, 4}
- Template Parameters:
U – Type of the source argument and the return type.
- Parameters:
u – [in] Input value to compute \( |x| \) where \( x \) is each element of \( u \).
- Returns:
The return value with the absolute of all elements.
- template<typename U, typename S, class = Require<(NumComponents<U> == NumComponents<S>) || (HasTypeTraits<U> && NumComponents<S> == 0)>> inline __host__ __device__ U clamp (U u, S lo, S hi)
Metafunction to clamp all elements of the input.
This function clamps all elements of the input
u
betweenlo
andhi
and returns the result with the same type as the input. It is a requirement of clamp that the inputu
has the same number of components of the range valueslo
andhi
or both are scalars (and the type ofu
has type traits).- Template Parameters:
U – Type of the source argument
u
and the return type.S – Type of the source argument
lo
andhi
(use a regular C type for scalar).
- Parameters:
u – [in] Input value to clamp.
lo – [in] Input clamp range low value.
hi – [in] Input clamp range high value.
- Returns:
The return value with all elements clamped.
- template<typename T, typename U, class = Require<HasTypeTraits<T, U> && !IsCompound<T>>> __host__ __device__ auto RangeCast (U u)
Metafunction to range cast (scale) all elements to a target range.
This function range casts (that is scales) all elements to the range defined by the template argument type
T
. For instance, a float4 with all elements between 0 and 1 can be casted to an uchar4 with scaling of each element to be in between 0 and 255 (see example below). It is a requirement of RangeCast that both types have type traits and typeT
must be a regular C type. Several examples of possible target range giving a source range, depending on the limits of regular C types, for the RangeCast function are as follows:Source type U
Target type T
Source range
Target range
signed char
float
[-128, 127]
[-1, 1]
float
unsigned char
[0, 1]
[0, 255]
short
unsigned int
[-32768, 32767]
[0, 4294967295]
double
int
[-1, 1]
[-2147483648, 2147483647]
unsigned short
double
[0, 65535]
[0, 1]
using DataType = MakeType<uchar, 4>; using FloatDataType = ConvertBaseTypeTo<float, DataType>; FloatDataType res = ...; // res component values are in [0, 1] DataType pix = RangeCast<BaseType<DataType>>(res); // pix are in [0, 255]
- Template Parameters:
T – Type that defines the target range to cast.
U – Type of the source value (with 1 to 4 elements) passed as argument.
- Parameters:
u – [in] Source value to cast all elements to range of type
T
.- Returns:
The value with all elements scaled.
- template<typename T, typename U, class = Require<(NumComponents<T> == NumComponents<U>) || (NumComponents<T> == 0 && HasTypeTraits<U>)>> __host__ __device__ auto SaturateCast (U u)
Metafunction to saturate cast all elements to a target type.
This function saturate casts (clamping with potential rounding) all elements to the range defined by the template argument type
T
. For instance, a float4 with any values (can be below 0 and above 255) can be casted to an uchar4 rounding-then-saturating each value to be in between 0 and 255 (see example below). It is a requirement of SaturateCast that both types have the same number of components orT
is a regular C type.using DataType = MakeType<uchar, 4>; using FloatDataType = ConvertBaseTypeTo<float, DataType>; FloatDataType res = ...; // res component values are in [0, 1] DataType pix = SaturateCast<DataType>(res); // pix are in [0, 255]
- Template Parameters:
T – Type that defines the target range to cast.
U – Type of the source value (with 1 to 4 elements) passed as argument.
- Parameters:
u – [in] Source value to cast all elements to range of base type of
T
- Returns:
The value with all elements clamped and potentially rounded.
- template<typename T, typename U, class = Require<HasTypeTraits<T, U> && !IsCompound<T>>> __host__ __device__ auto StaticCast (U u)
Metafunction to static cast all values of a compound to a target type.
The template parameter
T
defines the base type (regular C type) to cast all components of the CUDA compound typeU
passed as function argumentu
to the typeT
. The static cast return type has the base typeT
and the number of components as the compound typeU
. For instance, an uint3 can be casted to int3 by passing it as function argument of StaticCast and the type int as template argument (see example below). The typeU
is not needed as it is inferred from the argument \u. It is a requirement of the StaticCast function that the typeT
is of regular C type and the typeU
is of CUDA compound type.int3 idx = StaticCast<int>(blockIdx * blockDim + threadIdx);
- Template Parameters:
T – Type to do static cast on each component of
u
.- Parameters:
u – [in] Compound value to static cast each of its components to target type
T
.- Returns:
The compound value with all components static casted to type
T
.
-
template<typename T, typename StrideType = int64_t, class = Require<HasTypeTraits<T> && IsStrideType<StrideType>>>
__host__ auto CreateTensorWrapNHW(const TensorDataStridedCuda &tensor) Factory function to create an NHW tensor wrap given a tensor data.
The output TensorWrap is an NHW 3D tensor allowing to access data per batch (N), per row (H) and per column (W) of the input tensor. The input tensor data must have either NHWC or HWC layout, where the channel C is inside
T
, e.g. T=uchar3 for RGB8.See also
- Template Parameters:
T – Type of the values to be accessed in the tensor wrap.
StrideType – Type of the stride used in the tensor wrap.
- Parameters:
tensor – [in] Reference to the tensor that will be wrapped.
- Returns:
Tensor wrap useful to access tensor data in CUDA kernels.
-
template<typename T, typename StrideType = int64_t, class = Require<HasTypeTraits<T> && IsStrideType<StrideType>>>
__host__ auto CreateTensorWrapNHWC(const TensorDataStridedCuda &tensor) Factory function to create an NHWC tensor wrap given a tensor data.
The output TensorWrap is an NHWC 4D tensor allowing to access data per batch (N), per row (H), per column (W) and per channel (C) of the input tensor. The input tensor data must have either NHWC or HWC layout, where the channel C is of type
T
, e.g. T=uchar for each channel of either RGB8 or RGBA8.See also
- Template Parameters:
T – Type of the values to be accessed in the tensor wrap.
StrideType – Type of the stride used in the tensor wrap.
- Parameters:
tensor – [in] Reference to the tensor that will be wrapped.
- Returns:
Tensor wrap useful to access tensor data in CUDA kernels.
-
template<typename T, typename StrideType = int64_t, class = Require<HasTypeTraits<T> && IsStrideType<StrideType>>>
__host__ auto CreateTensorWrapNCHW(const TensorDataStridedCuda &tensor) Factory function to create an NCHW tensor wrap given a tensor data.
The output TensorWrap is an NCHW 4D tensor allowing to access data per batch (N), per channel (C), per row (H), and per column (W) of the input tensor. The input tensor data must have either NCHW or CHW layout, where the channel C is of type
T
, e.g. T=uchar for each channel of either RGB8 or RGBA8.See also
- Template Parameters:
T – Type of the values to be accessed in the tensor wrap.
- Parameters:
tensor – [in] Reference to the tensor that will be wrapped.
- Returns:
Tensor wrap useful to access tensor data in CUDA kernels.
- template<typename T, typename RT = detail::CopyConstness_t<T, std::conditional_t<IsCompound<T>, BaseType<T>, T>>, class = Require<HasTypeTraits<T>>> __host__ __device__ RT & GetElement (T &v, int eidx)
Metafunction to get an element by reference from a given value reference.
The value may be of CUDA compound type with 1 to 4 elements, where the corresponding element index is 0 to 3, and the return is a reference to the element with the base type of the compound type, copying the constness (that is the return reference is constant if the input value is constant). The value may be a regular C type, in which case the element index is ignored and the identity is returned. It is a requirement of the GetElement function that the type
T
has type traits.using PixelRGB8Type = MakeType<unsigned char, 3>; PixelRGB8Type pix = ...; auto green = GetElement(pix, 1); // yields unsigned char
- Template Parameters:
T – Type of the value to get the element from.
- Parameters:
v – [in] Value of type T to get an element from.
eidx – [in] Element index in [0, 3] inside the compound value to get the reference from. This element index is ignored in case the value is not of a CUDA compound type.
- Returns:
The reference of the value’s element.
- template<int EIDX, typename T, typename RT = detail::CopyConstness_t<T, std::conditional_t<IsCompound<T>, BaseType<T>, T>>, class = Require<HasTypeTraits<T>>> __host__ __device__ RT & GetElement (T &v)
- template<typename T, class = Require<HasTypeTraits<T>>> __host__ __device__ T SetAll (BaseType< T > x)
Metafunction to set all elements to the same value.
Set all elements to the value
x
passed as argument. For instance, an int3 can have all its elements set to zero by calling SetAll and passing int3 as template argument and zero as argument (see example below). Another way to set all elements to a value is by using the type of the argument as base type and passing the number of channels of the return type (see example below).auto idx = SetAll<int3>(0); // sets to zero all elements of an int3 index idx: {0, 0, 0} unsigned char ch = 127; auto pix = SetAll<4>(ch); // sets all elements of an uchar3 pixel pix: {127, 127, 127, 127}
- Template Parameters:
T – Type to be returned with all elements set to the given value
x
.N – Number of components as a second option instead of passing the type
T
.
- Parameters:
x – [in] Value to set all elements to.
- Returns:
The object of type T with all elements set to
x
.
- template<int N, typename BT, typename RT = MakeType<BT, N>, class = Require<HasTypeTraits<BT>>> __host__ __device__ RT SetAll (BT x)
- template<class T, class = Require<HasTypeTraits<T>>> const __host__ char * GetTypeName ()
Metafunction to get the name of a type.
Unfortunately typeid().name() in C/C++ typeinfo yields different names depending on the platform. This function returns the name of the type resembling the CUDA compound type, that may be useful for debug printing.
std::cout << GetTypeName<DataType>();
- Template Parameters:
T – Type to get the name from.
- Returns:
String with the name of the type.
Variables
-
template<typename ...Ts>
constexpr bool HasTypeTraits = (detail::HasTypeTraits_t<Ts>::value && ...)
-
template<class T, class = Require<HasTypeTraits<T>>>
constexpr bool IsCompound = TypeTraits<T>::components >= 1
-
template<typename T, int N, class = Require<HasTypeTraits<T>>>
constexpr bool HasEnoughComponents = N <= TypeTraits<T>::components
-
template<typename T>
constexpr bool IsStrideType = std::is_same_v<T, int32_t> || std::is_same_v<T, int64_t>
-
template<typename T, typename StrideType>
constexpr bool IsIndexType = std::is_integral_v<T> && (TypeTraits<T>::max <= TypeTraits<StrideType>::max)
-
template<class T, class = Require<HasTypeTraits<T>>>
constexpr int NumComponents = TypeTraits<T>::components Metavariable to get the number of components of a type.
using DataType = ...; int nc = nvcv::cuda::NumComponents<DataType>;
Note
This is zero for regular C types.
- Template Parameters:
T – Type to get the number of components from.
-
template<class T, class = Require<HasTypeTraits<T>>>
constexpr int NumElements = TypeTraits<T>::elements Metavariable to get the number of elements of a type.
using DataType = ...; for (int e = 0; e < nvcv::cuda::NumElements<DataType>; ++e) // ...
Note
This is one for regular C types and one to four for CUDA compound types.
- Template Parameters:
T – Type to get the number of elements from.
-
template<typename ValueType>
class ArrayWrap - #include <ArrayWrap.hpp>
-
template<typename T, NVCVBorderType B>
class BorderVarShapeWrap : public nvcv::cuda::detail::BorderIWImpl<T, B> - #include <BorderVarShapeWrap.hpp>
Border var-shape wrapper class used to wrap an ImageBatchVarShapeWrap adding border handling to it.
This class wraps an ImageBatchVarShapeWrap to add border handling functionality. It provides the methods
ptr
andoperator
[] to do the same semantic access (pointer or reference) in the wrapped ImageBatchVarShapeWrap but border aware on width and height as active dimensions.using PixelType = ...; using ImageBatchWrap = ImageBatchVarShapeWrap<PixelType>; using BorderVarShape = BorderVarShapeWrap<PixelType, NVCV_BORDER_REPLICATE>; ImageBatchWrap dst(...); ImageBatchWrap srcImageBatch(...); BorderVarShape src(srcImageBatch); dim3 grid{...}, block{...}; int2 fillBorderSize{2, 2}; FillBorder<<<grid, block>>>(dst, src, src.numImages(), fillBorderSize); template<typename T, NVCVBorderType B> __global__ void FillBorder(ImageBatchVarShapeWrap<T> dst, BorderVarShapeWrap<T, B> src, int ns, int2 bs) { int3 dstCoord = StaticCast<int>(blockIdx * blockDim + threadIdx); if (dstCoord.x >= dst.width(dstCoord.z) || dstCoord.y >= dst.height(dstCoord.z) || dstCoord.z >= ns) return; int3 srcCoord = {dstCoord.x - bs.x, dstCoord.y - bs.y, dstCoord.z}; dst[dstCoord] = src[srcCoord]; }
- Template Parameters:
T – Type (it can be const) of each element inside the image batch var-shape wrapper.
B – It is a NVCVBorderType indicating the border to be used.
-
template<typename T>
class BorderVarShapeWrap<T, NVCV_BORDER_CONSTANT> : public nvcv::cuda::detail::BorderIWImpl<T, NVCV_BORDER_CONSTANT> - #include <BorderVarShapeWrap.hpp>
Border var-shape wrapper class specialized for NVCV_BORDER_CONSTANT.
- Template Parameters:
T – Type (it can be const) of each element inside the image batch var-shape wrapper.
-
template<typename T, NVCVBorderType B>
class BorderVarShapeWrapNHWC : public nvcv::cuda::detail::BorderIWImpl<T, B> - #include <BorderVarShapeWrap.hpp>
-
template<typename T>
class BorderVarShapeWrapNHWC<T, NVCV_BORDER_CONSTANT> : public nvcv::cuda::detail::BorderIWImpl<T, NVCV_BORDER_CONSTANT> - #include <BorderVarShapeWrap.hpp>
Border var-shape wrapper class specialized for NVCV_BORDER_CONSTANT.
- Template Parameters:
T – Type (it can be const) of each element inside the image batch var-shape wrapper.
-
template<class TW, NVCVBorderType B, bool... ActiveDimensions>
class BorderWrap : public nvcv::cuda::detail::BorderWrapImpl<TW, B, ActiveDimensions...> - #include <BorderWrap.hpp>
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.
-
template<class TW, bool... ActiveDimensions>
class BorderWrap<TW, NVCV_BORDER_CONSTANT, ActiveDimensions...> : public nvcv::cuda::detail::BorderWrapImpl<TW, NVCV_BORDER_CONSTANT, ActiveDimensions...> - #include <BorderWrap.hpp>
Border wrapper class specialized for NVCV_BORDER_CONSTANT.
- Template Parameters:
TW – It is a TensorWrap class with any dimension and type.
ActiveDimensions – Flags to inform active (true) or inactive (false) dimensions.
-
template<typename T, int N>
class FullTensorWrap - #include <FullTensorWrap.hpp>
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.
-
template<typename T>
class ImageBatchVarShapeWrap - #include <ImageBatchVarShapeWrap.hpp>
Image batch var-shape wrapper class to wrap ImageBatchVarShapeDataStridedCuda.
ImageBatchVarShapeWrap is a wrapper of an image batch (or a list of images) of variable shapes. The template parameter
T
is the type of each element inside the wrapper, and it can be compound type to represent a pixel type, e.g. uchar4 for RGBA images.cudaStream_t stream; cudaStreamCreate(&stream); nvcv::ImageBatchVarShape imageBatch(samples); auto *imageBatchData = imageBatch.exportData<nvcv::ImageBatchVarShapeDataStridedCuda>(stream) nvcv::cuda::ImageBatchVarShapeWrap<uchar4> wrap(*imageBatchData); // Now wrap can be used in device code to access elements of the image batch via operator[] or ptr method.
Image batch var-shape wrapper class to wrap ImageBatchVarShapeDataStridedCuda.
This class is specialized for non-constant value type.
- Template Parameters:
T – Type (it can be const) of each element inside the image batch var-shape wrapper.
T – Type (non-const) of each element inside the image batch var-shape wrapper.
Subclassed by nvcv::cuda::ImageBatchVarShapeWrapNHWC< T >
-
template<typename T>
class ImageBatchVarShapeWrap<const T> - #include <ImageBatchVarShapeWrap.hpp>
-
template<typename T>
class ImageBatchVarShapeWrapNHWC : private nvcv::cuda::ImageBatchVarShapeWrap<T> - #include <ImageBatchVarShapeWrap.hpp>
Image batch var-shape wrapper NHWC class to wrap ImageBatchVarShapeDataStridedCuda and number of channels.
This class handles number of channels as a separate run-time parameter instead of built-in
T
. It considers interleaved channels, where they appear in a packed sequence at the last dimension (thus NHWC). It also considers each image in the batch has a single plane.Note
The class ImageBatchVarShapeWrap can be used with its template parameter
T
type as a compound type, where its number of elements yield the number of channels.- Template Parameters:
T – Type (it can be const) of each element inside this wrapper.
-
template<typename T, NVCVBorderType B, NVCVInterpolationType I>
class InterpolationVarShapeWrap : public nvcv::cuda::detail::InterpolationVarShapeWrapImpl<T, B, I> - #include <InterpolationVarShapeWrap.hpp>
Interpolation var-shape wrapper class used to wrap a BorderVarShapeWrap adding interpolation handling to it.
This class wraps a BorderVarShapeWrap to add interpolation handling functionality. It provides the operator[] to do the same semantic value access in the wrapped BorderVarShapeWrap but interpolation aware.
See also
NVCV_CPP_CUDATOOLS_INTERPOLATIONVARSHAPEWRAPS
Note
Each interpolation wrap class below is specialized for one interpolation type.
- Template Parameters:
T – Type (it can be const) of each element inside the border var-shape wrapper.
I – It is a NVCVInterpolationType defining the interpolation type to be used.
-
template<typename T, NVCVBorderType B>
class InterpolationVarShapeWrap<T, B, NVCV_INTERP_AREA> : public nvcv::cuda::detail::InterpolationVarShapeWrapImpl<T, B, NVCV_INTERP_AREA> - #include <InterpolationVarShapeWrap.hpp>
Interpolation var-shape wrapper class specialized for NVCV_INTERP_AREA.
- Template Parameters:
T – Type (it can be const) of each element inside the border var-shape wrapper.
-
template<typename T, NVCVBorderType B>
class InterpolationVarShapeWrap<T, B, NVCV_INTERP_CUBIC> : public nvcv::cuda::detail::InterpolationVarShapeWrapImpl<T, B, NVCV_INTERP_CUBIC> - #include <InterpolationVarShapeWrap.hpp>
Interpolation var-shape wrapper class specialized for NVCV_INTERP_CUBIC.
- Template Parameters:
T – Type (it can be const) of each element inside the border var-shape wrapper.
-
template<typename T, NVCVBorderType B>
class InterpolationVarShapeWrap<T, B, NVCV_INTERP_LINEAR> : public nvcv::cuda::detail::InterpolationVarShapeWrapImpl<T, B, NVCV_INTERP_LINEAR> - #include <InterpolationVarShapeWrap.hpp>
Interpolation var-shape wrapper class specialized for NVCV_INTERP_LINEAR.
- Template Parameters:
T – Type (it can be const) of each element inside the border var-shape wrapper.
-
template<typename T, NVCVBorderType B>
class InterpolationVarShapeWrap<T, B, NVCV_INTERP_NEAREST> : public nvcv::cuda::detail::InterpolationVarShapeWrapImpl<T, B, NVCV_INTERP_NEAREST> - #include <InterpolationVarShapeWrap.hpp>
Interpolation var-shape wrapper class specialized for NVCV_INTERP_NEAREST.
- Template Parameters:
T – Type (it can be const) of each element inside the border var-shape wrapper.
-
template<class BW, NVCVInterpolationType I>
class InterpolationWrap : public nvcv::cuda::detail::InterpolationWrapImpl<BW, I> - #include <InterpolationWrap.hpp>
Interpolation wrapper class used to wrap a BorderWrap adding interpolation handling to it.
This class wraps a BorderWrap to add interpolation handling functionality. It provides the operator[] to do the same semantic value access in the wrapped BorderWrap but interpolation aware.
using DataType = ...; using TensorWrap2D = TensorWrap<-1, -1, DataType>; using BorderWrap2D = BorderWrap<TensorWrap2D, NVCV_BORDER_REFLECT, true, true>; using InterpWrap2D = InterpolationWrap<BorderWrap2D, NVCV_INTERP_CUBIC>; TensorWrap2D tensorWrap(...); BorderWrap2D borderWrap(...); InterpWrap2D interpolationAwareTensor(borderWrap); // Now use interpolationAwareTensor instead of borderWrap or tensorWrap to access in-between elements with // on-the-fly interpolation, in this example grid-unaligned pixels use bi-cubic interpolation, grid-aligned // pixels that fall outside the tensor use reflect border extension and inside is the tensor value itself
See also
NVCV_CPP_CUDATOOLS_INTERPOLATIONWRAPS
Note
Each interpolation wrap class below is specialized for one interpolation type.
- Template Parameters:
BW – It is a BorderWrap class with any dimension and type.
I – It is a NVCVInterpolationType defining the interpolation type to be used.
-
template<class BW>
class InterpolationWrap<BW, NVCV_INTERP_AREA> : public nvcv::cuda::detail::InterpolationWrapImpl<BW, NVCV_INTERP_AREA> - #include <InterpolationWrap.hpp>
Interpolation wrapper class specialized for NVCV_INTERP_AREA.
- Template Parameters:
BW – It is a BorderWrap class with any dimension and type.
-
template<class BW>
class InterpolationWrap<BW, NVCV_INTERP_CUBIC> : public nvcv::cuda::detail::InterpolationWrapImpl<BW, NVCV_INTERP_CUBIC> - #include <InterpolationWrap.hpp>
Interpolation wrapper class specialized for NVCV_INTERP_CUBIC.
- Template Parameters:
BW – It is a BorderWrap class with any dimension and type.
-
template<class BW>
class InterpolationWrap<BW, NVCV_INTERP_LINEAR> : public nvcv::cuda::detail::InterpolationWrapImpl<BW, NVCV_INTERP_LINEAR> - #include <InterpolationWrap.hpp>
Interpolation wrapper class specialized for NVCV_INTERP_LINEAR.
- Template Parameters:
BW – It is a BorderWrap class with any dimension and type.
-
template<class BW>
class InterpolationWrap<BW, NVCV_INTERP_NEAREST> : public nvcv::cuda::detail::InterpolationWrapImpl<BW, NVCV_INTERP_NEAREST> - #include <InterpolationWrap.hpp>
Interpolation wrapper class specialized for NVCV_INTERP_NEAREST.
- Template Parameters:
BW – It is a BorderWrap class with any dimension and type.
-
template<typename T, typename StrideT, StrideT... Strides>
class TensorBatchWrapT - #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 theStrides
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.
See also
- 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, typename StrideT, StrideT... Strides>
class TensorBatchWrapT<const T, StrideT, Strides...> - #include <TensorBatchWrap.hpp>
-
template<typename T, typename StrideT, StrideT... Strides>
class TensorWrapT - #include <TensorWrap.hpp>
TensorWrap class is a non-owning wrap of a N-D tensor used for easy access of its elements in CUDA device.
TensorWrap is a wrapper of a multi-dimensional tensor 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 theStrides
template parameter.Template arguments:
T type of the values inside the tensor
StrideT type of the stride used in the byte offset calculation
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 an NHWC 4D tensor where each sample image in N has a run-time image pitch (first -1 in template argument), and 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 TensorWrap = TensorWrap<ChannelType, -1, -1, sizeof(DataType), sizeof(ChannelType)>; std::byte *imageData = ...; int imgStride = ...; int rowStride = ...; TensorWrap tensorWrap(imageData, imgStride, rowStride); // 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.
Tensor wrapper class specialized for non-constant value type.
See also
- 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 wrapper.
Strides – Each compile-time (use -1 for run-time) pitch in bytes from first to last dimension.
-
template<typename T, typename StrideT, StrideT... Strides>
class TensorWrapT<const T, StrideT, Strides...> - #include <TensorWrap.hpp>
-
namespace detail
Typedefs
-
template<typename T, NVCVBorderType B>
using BorderVarShapeWrapImpl = BorderIWImpl<ImageBatchVarShapeWrap<T>, B>
-
template<typename T, NVCVBorderType B>
using BorderVarShapeWrapNHWCImpl = BorderIWImpl<ImageBatchVarShapeWrapNHWC<T>, B>
-
template<class FROM, class TO>
using CopyConstness_t = typename CopyConstness<FROM, TO>::type
-
template<class BT, class T>
using ConvertBaseTypeTo_t = typename ConvertBaseTypeTo<BT, T>::type
Functions
- template<typename U> inline __host__ U RoundEvenImpl (U u)
- template<typename T, typename U, int RM = FE_TONEAREST> inline __host__ __device__ T RoundImpl (U u)
- template<typename U> inline __host__ __device__ U MinImpl (U a, U b)
- template<typename U> inline __host__ __device__ U MaxImpl (U a, U b)
- template<typename U, typename S> inline __host__ __device__ U PowImpl (U x, S y)
- template<typename U> inline __host__ __device__ U ExpImpl (U u)
- template<typename U> inline __host__ __device__ U SqrtImpl (U u)
- template<typename U> inline __host__ __device__ U AbsImpl (U u)
- template<typename U, typename S> inline __host__ __device__ U ClampImpl (U u, S lo, S hi)
- template<typename T, typename U> inline __host__ __device__ T RangeCastImpl (U u)
- template<typename T, typename U> inline __host__ __device__ T BaseSaturateCastImpl (U u)
- template<typename T, typename U> inline __host__ __device__ T SaturateCastImpl (U u)
- template<> __host__ __device__ __forceinline__ unsigned char SaturateCastImpl< unsigned char, signed char > (signed char u)
- template<> __host__ __device__ __forceinline__ unsigned char SaturateCastImpl< unsigned char, short > (short u)
- template<> __host__ __device__ __forceinline__ unsigned char SaturateCastImpl< unsigned char, unsigned short > (unsigned short u)
- template<> __host__ __device__ __forceinline__ unsigned char SaturateCastImpl< unsigned char, int > (int u)
- template<> __host__ __device__ __forceinline__ unsigned char SaturateCastImpl< unsigned char, unsigned int > (unsigned int u)
- template<> __host__ __device__ __forceinline__ unsigned char SaturateCastImpl< unsigned char, float > (float u)
- template<> __host__ __device__ __forceinline__ unsigned char SaturateCastImpl< unsigned char, double > (double u)
- template<> __host__ __device__ __forceinline__ signed char SaturateCastImpl< signed char, unsigned char > (unsigned char u)
- template<> __host__ __device__ __forceinline__ signed char SaturateCastImpl< signed char, short > (short u)
- template<> __host__ __device__ __forceinline__ signed char SaturateCastImpl< signed char, unsigned short > (unsigned short u)
- template<> __host__ __device__ __forceinline__ signed char SaturateCastImpl< signed char, int > (int u)
- template<> __host__ __device__ __forceinline__ signed char SaturateCastImpl< signed char, unsigned int > (unsigned int u)
- template<> __host__ __device__ __forceinline__ signed char SaturateCastImpl< signed char, float > (float u)
- template<> __host__ __device__ __forceinline__ signed char SaturateCastImpl< signed char, double > (double u)
- template<> __host__ __device__ __forceinline__ unsigned short SaturateCastImpl< unsigned short, signed char > (signed char u)
- template<> __host__ __device__ __forceinline__ unsigned short SaturateCastImpl< unsigned short, short > (short u)
- template<> __host__ __device__ __forceinline__ unsigned short SaturateCastImpl< unsigned short, int > (int u)
- template<> __host__ __device__ __forceinline__ unsigned short SaturateCastImpl< unsigned short, unsigned int > (unsigned int u)
- template<> __host__ __device__ __forceinline__ unsigned short SaturateCastImpl< unsigned short, float > (float u)
- template<> __host__ __device__ __forceinline__ unsigned short SaturateCastImpl< unsigned short, double > (double u)
- template<> __host__ __device__ __forceinline__ short SaturateCastImpl< short, unsigned short > (unsigned short u)
- template<> __host__ __device__ __forceinline__ short SaturateCastImpl< short, int > (int u)
- template<> __host__ __device__ __forceinline__ short SaturateCastImpl< short, unsigned int > (unsigned int u)
- template<> __host__ __device__ __forceinline__ short SaturateCastImpl< short, float > (float u)
- template<> __host__ __device__ __forceinline__ short SaturateCastImpl< short, double > (double u)
- template<> __host__ __device__ __forceinline__ int SaturateCastImpl< int, unsigned int > (unsigned int u)
- template<> __host__ __device__ __forceinline__ int SaturateCastImpl< int, float > (float u)
- template<> __host__ __device__ __forceinline__ int SaturateCastImpl< int, double > (double u)
- template<> __host__ __device__ __forceinline__ unsigned int SaturateCastImpl< unsigned int, signed char > (signed char u)
- template<> __host__ __device__ __forceinline__ unsigned int SaturateCastImpl< unsigned int, short > (short u)
- template<> __host__ __device__ __forceinline__ unsigned int SaturateCastImpl< unsigned int, int > (int u)
- template<> __host__ __device__ __forceinline__ unsigned int SaturateCastImpl< unsigned int, float > (float u)
- template<> __host__ __device__ __forceinline__ unsigned int SaturateCastImpl< unsigned int, double > (double u)
- template<typename T, typename U, typename RT, RoundMode RM> inline __host__ __device__ RT RoundImpl (U u)
Variables
-
template<class T, class U, class = Require<HasTypeTraits<T, U>>>
constexpr bool IsSameCompound = IsCompound<T> && TypeTraits<T>::components == TypeTraits<U>::components
-
template<typename T, typename U, class = Require<HasTypeTraits<T, U>>>
constexpr bool OneIsCompound = (TypeTraits<T>::components == 0 && TypeTraits<U>::components >= 1) || (TypeTraits<T>::components >= 1 && TypeTraits<U>::components == 0) || IsSameCompound<T, U>
-
template<typename T, class = Require<HasTypeTraits<T>>>
constexpr bool IsIntegral = std::is_integral_v<typename TypeTraits<T>::base_type>
-
template<typename T, typename U, class = Require<HasTypeTraits<T, U>>>
constexpr bool OneIsCompoundAndBothAreIntegral = OneIsCompound<T, U> && IsIntegral<T> && IsIntegral<U>
-
template<typename T, class = Require<HasTypeTraits<T>>>
constexpr bool IsIntegralCompound = IsIntegral<T> && IsCompound<T>
-
template<class IW, NVCVBorderType B>
class BorderIWImpl - #include <BorderVarShapeWrap.hpp>
Subclassed by nvcv::cuda::BorderVarShapeWrap< T, B >, nvcv::cuda::BorderVarShapeWrap< T, NVCV_BORDER_CONSTANT >, nvcv::cuda::BorderVarShapeWrapNHWC< T, B >, nvcv::cuda::BorderVarShapeWrapNHWC< T, NVCV_BORDER_CONSTANT >
-
template<class TW, NVCVBorderType B, bool... ActiveDimensions>
class BorderWrapImpl - #include <BorderWrap.hpp>
-
template<class BT, class T>
struct ConvertBaseTypeTo - #include <Metaprogramming.hpp>
-
template<class BT, class T>
struct ConvertBaseTypeTo<BT, volatile const T> - #include <Metaprogramming.hpp>
-
template<class FROM, class TO>
struct CopyConstness - #include <Metaprogramming.hpp>
-
template<typename T, typename = void>
struct HasTypeTraits_t : public false_type - #include <Metaprogramming.hpp>
- template<typename T> base_type > > : public true_type
- #include <Metaprogramming.hpp>
-
template<typename T, NVCVBorderType B, NVCVInterpolationType I>
class InterpolationVarShapeWrapImpl - #include <InterpolationVarShapeWrap.hpp>
Subclassed by nvcv::cuda::InterpolationVarShapeWrap< T, B, I >
-
template<class BW, NVCVInterpolationType I>
class InterpolationWrapImpl - #include <InterpolationWrap.hpp>
Subclassed by nvcv::cuda::InterpolationWrap< BW, I >
-
template<class T, int C>
struct MakeType - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<char, 0> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<char, 1> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<char, 2> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<char, 3> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<char, 4> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<double, 0> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<double, 1> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<double, 2> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<double, 3> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<double, 4> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<float, 0> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<float, 1> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<float, 2> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<float, 3> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<float, 4> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<int, 0> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<int, 1> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<int, 2> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<int, 3> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<int, 4> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<long long, 0> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<long long, 1> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<long long, 2> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<long long, 3> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<long long, 4> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<long, 0> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<long, 1> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<long, 2> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<long, 3> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<long, 4> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<short, 0> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<short, 1> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<short, 2> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<short, 3> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<short, 4> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<signed char, 0> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<signed char, 1> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<signed char, 2> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<signed char, 3> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<signed char, 4> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned char, 0> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned char, 1> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned char, 2> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned char, 3> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned char, 4> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned int, 0> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned int, 1> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned int, 2> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned int, 3> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned int, 4> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned long long, 0> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned long long, 1> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned long long, 2> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned long long, 3> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned long long, 4> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned long, 0> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned long, 1> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned long, 2> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned long, 3> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned long, 4> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned short, 0> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned short, 1> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned short, 2> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned short, 3> - #include <Metaprogramming.hpp>
-
template<>
struct MakeType<unsigned short, 4> - #include <Metaprogramming.hpp>
-
template<class T>
struct TypeTraits - #include <Metaprogramming.hpp>
Subclassed by nvcv::cuda::detail::TypeTraits< const T >, nvcv::cuda::detail::TypeTraits< const volatile T >, nvcv::cuda::detail::TypeTraits< volatile T >
-
template<>
struct TypeTraits<char> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<char1> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<char2> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<char3> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<char4> - #include <Metaprogramming.hpp>
-
template<class T>
struct TypeTraits<const T> : public nvcv::cuda::detail::TypeTraits<T> - #include <Metaprogramming.hpp>
-
template<class T>
struct TypeTraits<volatile const T> : public nvcv::cuda::detail::TypeTraits<T> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<dim3> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<double> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<double1> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<double2> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<double3> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<double4> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<float> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<float1> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<float2> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<float3> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<float4> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<int> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<int1> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<int2> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<int3> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<int4> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<long> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<long long> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<long1> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<long2> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<long3> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<long4> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<longlong1> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<longlong2> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<longlong3> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<longlong4> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<short> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<short1> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<short2> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<short3> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<short4> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<signed char> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<uchar1> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<uchar2> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<uchar3> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<uchar4> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<uint1> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<uint2> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<uint3> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<uint4> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<ulong1> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<ulong2> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<ulong3> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<ulong4> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<ulonglong1> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<ulonglong2> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<ulonglong3> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<ulonglong4> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<unsigned char> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<unsigned int> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<unsigned long> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<unsigned long long> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<unsigned short> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<ushort1> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<ushort2> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<ushort3> - #include <Metaprogramming.hpp>
-
template<>
struct TypeTraits<ushort4> - #include <Metaprogramming.hpp>
-
template<typename T, NVCVBorderType B>
-
namespace math
Functions
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > & operator+= (Vector< T, N > &lhs, const Vector< T, N > &rhs)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator+ (const Vector< T, N > &a, const Vector< T, N > &b)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > & operator+= (Vector< T, N > &lhs, T rhs)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator+ (const Vector< T, N > &a, T b)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator+ (T a, const Vector< T, N > &b)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > & operator-= (Vector< T, N > &lhs, const Vector< T, N > &rhs)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator- (const Vector< T, N > &a, const Vector< T, N > &b)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > & operator-= (Vector< T, N > &lhs, T rhs)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator- (const Vector< T, N > &a, T b)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator- (T a, const Vector< T, N > &b)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > & operator*= (Vector< T, N > &lhs, const T &rhs)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator* (const Vector< T, N > &a, const T &b)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator* (const T &a, const Vector< T, N > &b)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > & operator*= (Vector< T, N > &lhs, const Vector< T, N > &rhs)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator* (const Vector< T, N > &a, const Vector< T, N > &b)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > & operator/= (Vector< T, N > &lhs, const T &rhs)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator/ (const Vector< T, N > &a, const T &b)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator/ (T a, const Vector< T, N > &b)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > & operator/= (Vector< T, N > &lhs, const Vector< T, N > &rhs)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator/ (const Vector< T, N > &a, const Vector< T, N > &b)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator- (const Vector< T, N > &v)
- template<class T, int N> constexpr __host__ __device__ bool operator== (const Vector< T, N > &a, const Vector< T, N > &b)
- template<class T, int N> constexpr __host__ __device__ bool operator== (const T &a, const Vector< T, N > &b)
- template<class T, int N> constexpr __host__ __device__ bool operator== (const Vector< T, N > &a, const T &b)
- template<class T, int N> constexpr __host__ __device__ bool operator< (const Vector< T, N > &a, const Vector< T, N > &b)
- template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > operator* (const Matrix< T, M, N > &m, T val)
-
template<class T, int M, int N>
std::ostream &operator<<(std::ostream &out, const Matrix<T, M, N> &m)
- template<class T, int M, int N, int P> constexpr __host__ __device__ Matrix< T, M, P > operator* (const Matrix< T, M, N > &a, const Matrix< T, N, P > &b)
- template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > & operator*= (Matrix< T, M, N > &lhs, T rhs)
- template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > operator* (T val, const Matrix< T, M, N > &m)
- template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > & operator+= (Matrix< T, M, N > &lhs, const Matrix< T, M, N > &rhs)
- template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > operator+ (const Matrix< T, M, N > &lhs, const Matrix< T, M, N > &rhs)
- template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > & operator-= (Matrix< T, M, N > &lhs, const Matrix< T, M, N > &rhs)
- template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > operator- (const Matrix< T, M, N > &a, const Matrix< T, M, N > &b)
- template<class T, int M, int N> constexpr __host__ __device__ Vector< T, N > operator* (const Vector< T, M > &v, const Matrix< T, M, N > &m)
- template<class T, int M, int N> constexpr __host__ __device__ Vector< T, M > operator* (const Matrix< T, M, N > &m, const Vector< T, N > &v)
- template<class T, int M, int N, class = cuda::Require<(M == N && N > 1)>> constexpr __host__ __device__ Matrix< T, M, N > operator* (const Matrix< T, M, 1 > &m, const Vector< T, N > &v)
- template<class T, int M, int N> constexpr __host__ __device__ Vector< T, N > & operator*= (Vector< T, M > &v, const Matrix< T, M, M > &m)
- template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > & operator*= (Matrix< T, M, N > &lhs, const Matrix< T, N, N > &rhs)
- template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > operator- (const Matrix< T, M, N > &m)
- template<class T, int M, int N> constexpr __host__ __device__ bool operator== (const Matrix< T, M, N > &a, const Matrix< T, M, N > &b)
- template<class T, int M, int N> constexpr __host__ __device__ bool operator== (const T &a, const Matrix< T, M, N > &b)
- template<class T, int M, int N> constexpr __host__ __device__ bool operator== (const Matrix< T, M, N > &a, const T &b)
- template<class T, int M, int N> constexpr __host__ __device__ bool operator< (const Matrix< T, M, N > &a, const Matrix< T, M, N > &b)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > zeros ()
- template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > zeros ()
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > ones ()
- template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > ones ()
- template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > identity ()
- template<class T, int M> constexpr __host__ __device__ Matrix< T, M, M > vander (const Vector< T, M > &v)
- template<class T, int R> constexpr __host__ __device__ Matrix< T, R, R > compan (const Vector< T, R > &a)
- template<class T, int M> constexpr __host__ __device__ Matrix< T, M, M > diag (const Vector< T, M > &v)
- template<class T, int N> constexpr __host__ __device__ T dot (const Vector< T, N > &a, const Vector< T, N > &b)
- template<class T, int N> constexpr __host__ __device__ Vector< T, N > reverse (const Vector< T, N > &a)
- template<class T, int M> constexpr __host__ __device__ Matrix< T, M, M > & transp_inplace (Matrix< T, M, M > &m)
- template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, N, M > transp (const Matrix< T, M, N > &m)
- template<class T, int N> constexpr __host__ __device__ Matrix< T, N, 1 > transp (const Vector< T, N > &v)
- template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > flip_rows (const Matrix< T, M, N > &m)
- template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > flip_cols (const Matrix< T, M, N > &m)
- template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > flip (const Matrix< T, M, N > &m)
-
template<class T, int M, int N = M>
class Matrix - #include <LinAlg.hpp>
Matrix class to represent small matrices.
It uses the Vector class to stores each row, storing elements in row-major order, i.e. it has M row vectors where each vector has N elements.
- Template Parameters:
T – Matrix value type.
M – Number of rows.
N – Number of columns. Default is M (a square matrix).
-
template<class T, int N>
class Vector - #include <LinAlg.hpp>
Vector class to represent small vectors.
- Template Parameters:
T – Vector value type.
N – Number of elements.
-
namespace detail
Functions
- template<class T> constexpr __host__ __device__ void swap (T &a, T &b)
-
template<typename T, int64_t... Strides>